49 lines
1.6 KiB
Bash
Executable File
49 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
INSTALL_DIR="/opt/pve-cloud-backup"
|
|
BACKEND_DIR="$INSTALL_DIR/backend"
|
|
FRONTEND_DIR="$INSTALL_DIR/frontend"
|
|
STATIC_DIR="$INSTALL_DIR/static"
|
|
DATA_DIR="$INSTALL_DIR/data"
|
|
LOG_DIR="$INSTALL_DIR/logs"
|
|
|
|
if [[ "$(id -u)" -ne 0 ]]; then
|
|
echo "Run as root. The services need pvesh access and systemd installation." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d "$INSTALL_DIR" ]]; then
|
|
echo "$INSTALL_DIR does not exist. Copy the application files there first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$BACKEND_DIR" "$FRONTEND_DIR" "$STATIC_DIR" "$DATA_DIR" "$LOG_DIR" "$INSTALL_DIR/scripts"
|
|
|
|
command -v python3 >/dev/null || { echo "python3 is required" >&2; exit 1; }
|
|
command -v npm >/dev/null || { echo "npm is required to build the Vue frontend" >&2; exit 1; }
|
|
|
|
python3 -m venv "$BACKEND_DIR/.venv"
|
|
"$BACKEND_DIR/.venv/bin/pip" install --upgrade pip
|
|
"$BACKEND_DIR/.venv/bin/pip" install -r "$BACKEND_DIR/requirements.txt"
|
|
|
|
cd "$FRONTEND_DIR"
|
|
if [[ -f package-lock.json ]]; then
|
|
npm ci
|
|
else
|
|
npm install
|
|
fi
|
|
npm run build
|
|
|
|
cd "$BACKEND_DIR"
|
|
"$BACKEND_DIR/.venv/bin/python" -c 'from app.migrations import run_migrations; run_migrations()'
|
|
|
|
install -m 0644 "$INSTALL_DIR/systemd/pve-cloud-backup-web.service" /etc/systemd/system/pve-cloud-backup-web.service
|
|
install -m 0644 "$INSTALL_DIR/systemd/pve-cloud-backup-worker.service" /etc/systemd/system/pve-cloud-backup-worker.service
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable --now pve-cloud-backup-web.service
|
|
systemctl enable --now pve-cloud-backup-worker.service
|
|
|
|
echo "Installed. Open http://<server>:8080 and complete the setup wizard."
|