Files
unraid-dashboard/setup-unraid.sh
Michael Simard 8396fbcf6f Add Docker deployment for Unraid
- Dockerfile with nginx:alpine for static file serving
- docker-compose.yml with port 9113:80 mapping
- deploy.sh for git-based deployment to Unraid
- setup-unraid.sh for initial server configuration
- manage.sh for container operations (logs, status, restart, etc.)
- .gitignore to exclude config.js

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 09:43:02 -06:00

83 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# setup-unraid.sh - Initial Unraid setup for git-based deployment
set -e
UNRAID_HOST="${UNRAID_HOST:-root@192.168.2.61}"
REMOTE_PATH="/boot/config/plugins/compose.manager/projects/unraid-dash"
echo "Setting up Unraid server for git-based deployment..."
echo ""
# Setup SSH config on Unraid for git access
echo "1. Configuring SSH for git.michaelsimard.ca..."
ssh ${UNRAID_HOST} bash << 'EOF'
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Add SSH config for git server
if ! grep -q "git.michaelsimard.ca" ~/.ssh/config 2>/dev/null; then
cat >> ~/.ssh/config << 'SSHCONFIG'
Host git.michaelsimard.ca
Port 28
SSHCONFIG
chmod 600 ~/.ssh/config
echo "SSH config updated"
else
echo "SSH config already contains git.michaelsimard.ca"
fi
# Add host key
ssh-keyscan -p 28 git.michaelsimard.ca >> ~/.ssh/known_hosts 2>/dev/null || true
echo "Host key added to known_hosts"
EOF
echo ""
echo "2. Checking for SSH key on Unraid..."
ssh ${UNRAID_HOST} bash << 'EOF'
if [ ! -f ~/.ssh/id_rsa ] && [ ! -f ~/.ssh/id_ed25519 ]; then
echo "No SSH key found. Generating ed25519 key..."
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -C "unraid@unraid-dash"
echo ""
echo "=== PUBLIC KEY - Add this to your Gitea account ==="
cat ~/.ssh/id_ed25519.pub
echo "=== END PUBLIC KEY ==="
echo ""
echo "Add this key at: https://git.michaelsimard.ca/user/settings/keys"
echo "Press Enter when done..."
read
else
echo "SSH key exists"
if [ -f ~/.ssh/id_ed25519.pub ]; then
cat ~/.ssh/id_ed25519.pub
elif [ -f ~/.ssh/id_rsa.pub ]; then
cat ~/.ssh/id_rsa.pub
fi
fi
EOF
echo ""
echo "3. Testing git access..."
if ssh ${UNRAID_HOST} "git ls-remote git@git.michaelsimard.ca:msimard/unraid-dashboard.git HEAD" &>/dev/null; then
echo "Git access successful"
else
echo "Git access failed. Ensure SSH key is added to Gitea"
exit 1
fi
echo ""
echo "4. Creating config.js file on Unraid..."
if ssh ${UNRAID_HOST} "[ -f ${REMOTE_PATH}/config.js ]"; then
echo "config.js already exists on Unraid"
else
echo "Copying local config.js to Unraid..."
ssh ${UNRAID_HOST} "mkdir -p ${REMOTE_PATH}"
scp config.js ${UNRAID_HOST}:${REMOTE_PATH}/config.js
echo "config.js copied"
fi
echo ""
echo "=== Setup Complete ==="
echo "Run './deploy.sh' to deploy the dashboard"