80 lines
3.1 KiB
Bash
Executable file
80 lines
3.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# ══════════════════════════════════════════════════════════════════
|
|
# Greendale Media Centre — Export to Unraid
|
|
#
|
|
# Usage:
|
|
# chmod +x export-to-unraid.sh
|
|
# ./export-to-unraid.sh [unraid-user@unraid-ip] [destination-path]
|
|
#
|
|
# Examples:
|
|
# ./export-to-unraid.sh root@192.168.86.10
|
|
# ./export-to-unraid.sh root@192.168.86.10 /mnt/user/appdata/greendale
|
|
#
|
|
# What it does:
|
|
# 1. Builds the Docker image locally and saves it as a tarball
|
|
# 2. rsyncs the project files (minus secrets & cache) to Unraid
|
|
# 3. Copies the image tarball to Unraid
|
|
# 4. Loads the image on Unraid via SSH
|
|
# Leaves your .env on Unraid untouched if it already exists.
|
|
# ══════════════════════════════════════════════════════════════════
|
|
|
|
set -euo pipefail
|
|
|
|
REMOTE="${1:-}"
|
|
DEST="${2:-/mnt/user/appdata/greendale}"
|
|
IMAGE_NAME="arr-summary-arr-summary"
|
|
TARBALL="/tmp/greendale-image.tar"
|
|
|
|
if [[ -z "$REMOTE" ]]; then
|
|
echo "Usage: $0 <user@unraid-ip> [destination-path]"
|
|
echo "Example: $0 root@192.168.86.10 /mnt/user/appdata/greendale"
|
|
exit 1
|
|
fi
|
|
|
|
echo "▶ Building Docker image..."
|
|
docker compose build
|
|
|
|
echo "▶ Saving image to tarball (this may take a moment)..."
|
|
docker save "$IMAGE_NAME" -o "$TARBALL"
|
|
|
|
echo "▶ Syncing project files to $REMOTE:$DEST ..."
|
|
rsync -avz --progress \
|
|
--exclude='.env' \
|
|
--exclude='__pycache__' \
|
|
--exclude='*.pyc' \
|
|
--exclude='.git' \
|
|
--exclude='nginx' \
|
|
--exclude='export-to-unraid.sh' \
|
|
--exclude="$(basename "$TARBALL")" \
|
|
./ "$REMOTE:$DEST/"
|
|
|
|
echo "▶ Copying Docker image to Unraid..."
|
|
scp "$TARBALL" "$REMOTE:/tmp/greendale-image.tar"
|
|
|
|
echo "▶ Loading image on Unraid..."
|
|
ssh "$REMOTE" "docker load -i /tmp/greendale-image.tar && rm /tmp/greendale-image.tar"
|
|
|
|
echo "▶ Checking if .env exists on Unraid..."
|
|
if ssh "$REMOTE" "test -f $DEST/.env"; then
|
|
echo " ✓ .env already exists on Unraid — leaving it untouched."
|
|
else
|
|
echo " ⚠ No .env found. Copying .env.example as a starting point..."
|
|
ssh "$REMOTE" "cp $DEST/.env.example $DEST/.env"
|
|
echo " → Edit $DEST/.env on Unraid before starting the container!"
|
|
fi
|
|
|
|
echo ""
|
|
echo "══════════════════════════════════════════════════════════"
|
|
echo " ✅ Export complete!"
|
|
echo ""
|
|
echo " On Unraid, to start:"
|
|
echo " cd $DEST"
|
|
echo " nano .env # set LOGIN_PASSWORD, SECRET_KEY, etc."
|
|
echo " docker compose up -d"
|
|
echo ""
|
|
echo " Or add via Unraid's Docker UI:"
|
|
echo " Repository: arr-summary-arr-summary (already loaded)"
|
|
echo " Port mapping: HOST_PORT (default 5055) → 5000"
|
|
echo "══════════════════════════════════════════════════════════"
|
|
|
|
rm -f "$TARBALL"
|