51 lines
1.9 KiB
Bash
Executable File
51 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Deploy Portal Auth Dashboard to root@10.110.60.210 by uploading from this PC via SSH/rsync.
|
|
# LXC has no direct access to Git; run this script from your PC.
|
|
set -e
|
|
TARGET="root@10.110.60.210"
|
|
APP_DIR="/opt/portal-auth-dashboard"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
echo "=== Uploading project to $TARGET via rsync ==="
|
|
ssh "$TARGET" "mkdir -p $APP_DIR; command -v rsync >/dev/null 2>&1 || (apt-get update -qq && apt-get install -y rsync)"
|
|
rsync -av \
|
|
--exclude '.env' \
|
|
--exclude '.git' \
|
|
--exclude '__pycache__' \
|
|
--exclude '*.pyc' \
|
|
--exclude 'venv' \
|
|
"$PROJECT_DIR/" \
|
|
"$TARGET:$APP_DIR/"
|
|
|
|
echo "=== Setting up on server ==="
|
|
ssh "$TARGET" "set -e
|
|
APP_DIR='$APP_DIR'
|
|
cd \"\$APP_DIR\"
|
|
if [ ! -d venv ] || [ ! -f venv/bin/pip ]; then
|
|
echo 'Creating venv and installing dependencies...'
|
|
rm -rf venv
|
|
apt-get update -qq
|
|
command -v python3 >/dev/null 2>&1 || apt-get install -y python3
|
|
apt-get install -y python3-venv python3-pip
|
|
python3 -m venv venv
|
|
./venv/bin/pip install -r requirements.txt
|
|
else
|
|
echo 'Updating dependencies...'
|
|
./venv/bin/pip install -q -r requirements.txt
|
|
fi
|
|
if [ ! -f .env ]; then
|
|
[ -f deploy/.env.server ] && cp deploy/.env.server .env || true
|
|
grep -q 'REPLACE_WITH' .env 2>/dev/null && echo 'Edit .env on server: DB_AUTH_PASSWORD and SECRET_KEY' || true
|
|
fi
|
|
cp deploy/portal-auth-dashboard.service /etc/systemd/system/
|
|
systemctl daemon-reload
|
|
systemctl enable portal-auth-dashboard
|
|
systemctl restart portal-auth-dashboard
|
|
echo '=== Status ==='
|
|
systemctl status portal-auth-dashboard --no-pager"
|
|
|
|
echo ""
|
|
echo "Done. Dashboard: http://10.110.60.210:5000"
|
|
echo "To set DB credentials on first deploy: ssh $TARGET 'nano $APP_DIR/.env' then systemctl restart portal-auth-dashboard"
|