Add subspace-tv FastAPI service with Unraid deployment
Includes FastAPI application with device authentication, Docker configuration, Bruno API tests, and git-based deployment scripts for Unraid. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
97
setup-unraid.sh
Executable file
97
setup-unraid.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
UNRAID_HOST="root@192.168.2.61"
|
||||
REMOTE_PATH="/boot/config/plugins/compose.manager/projects/subspace-tv"
|
||||
GIT_HOST="git.michaelsimard.ca"
|
||||
GIT_PORT="28"
|
||||
GIT_REPO="git@git.michaelsimard.ca:msimard/subspace-tv.git"
|
||||
|
||||
echo "=== Subspace TV - Unraid Setup ==="
|
||||
echo ""
|
||||
|
||||
# Check local .env exists
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "ERROR: Local .env file not found"
|
||||
echo "Copy .env.example to .env and configure it first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Step 1: Checking SSH connectivity to Unraid..."
|
||||
if ! ssh -o ConnectTimeout=5 "$UNRAID_HOST" "echo 'Connected'" 2>/dev/null; then
|
||||
echo "ERROR: Cannot connect to Unraid at $UNRAID_HOST"
|
||||
echo "Ensure SSH is enabled and key-based auth is configured"
|
||||
exit 1
|
||||
fi
|
||||
echo " Connected to Unraid"
|
||||
|
||||
echo ""
|
||||
echo "Step 2: Configuring SSH for git server on Unraid..."
|
||||
ssh "$UNRAID_HOST" bash <<EOF
|
||||
# Create .ssh directory if needed
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
|
||||
# Check if SSH key exists
|
||||
if [ ! -f ~/.ssh/id_ed25519 ]; then
|
||||
echo " Generating SSH key..."
|
||||
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -q
|
||||
echo ""
|
||||
echo "=== ACTION REQUIRED ==="
|
||||
echo "Add this public key to Gitea:"
|
||||
echo ""
|
||||
cat ~/.ssh/id_ed25519.pub
|
||||
echo ""
|
||||
echo "========================"
|
||||
else
|
||||
echo " SSH key already exists"
|
||||
fi
|
||||
|
||||
# Configure SSH for git server
|
||||
if ! grep -q "Host $GIT_HOST" ~/.ssh/config 2>/dev/null; then
|
||||
echo " Adding git server to SSH config..."
|
||||
cat >> ~/.ssh/config <<SSHCONFIG
|
||||
|
||||
Host $GIT_HOST
|
||||
HostName $GIT_HOST
|
||||
Port $GIT_PORT
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_ed25519
|
||||
StrictHostKeyChecking accept-new
|
||||
SSHCONFIG
|
||||
chmod 600 ~/.ssh/config
|
||||
else
|
||||
echo " Git server already in SSH config"
|
||||
fi
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "Step 3: Creating project directory on Unraid..."
|
||||
ssh "$UNRAID_HOST" "mkdir -p $REMOTE_PATH"
|
||||
echo " Directory ready: $REMOTE_PATH"
|
||||
|
||||
echo ""
|
||||
echo "Step 4: Copying .env to Unraid..."
|
||||
scp -q ".env" "$UNRAID_HOST:$REMOTE_PATH/.env"
|
||||
echo " .env copied"
|
||||
|
||||
echo ""
|
||||
echo "Step 5: Testing git connectivity from Unraid..."
|
||||
if ssh "$UNRAID_HOST" "ssh -o ConnectTimeout=10 -p $GIT_PORT git@$GIT_HOST 2>&1 | grep -q 'successfully authenticated'"; then
|
||||
echo " Git server accessible"
|
||||
else
|
||||
echo ""
|
||||
echo "WARNING: Git authentication may not be configured"
|
||||
echo "Ensure the Unraid SSH public key is added to Gitea"
|
||||
echo ""
|
||||
echo "To view the public key, run:"
|
||||
echo " ssh $UNRAID_HOST 'cat ~/.ssh/id_ed25519.pub'"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Setup Complete ==="
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Ensure git push is up to date"
|
||||
echo " 2. Run ./deploy.sh to deploy"
|
||||
Reference in New Issue
Block a user