server/install.sh was broken after moving into server/: SCRIPT_DIR now resolves to the server/ subdirectory, so requirements path, log dir, and systemd WorkingDirectory all pointed at wrong locations. Introduce REPO_DIR (parent of SCRIPT_DIR) and use it throughout. client/install.sh creates a venv at client/.venv, installs client/requirements.txt, and writes a client/run.sh launcher. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
2.1 KiB
Bash
Executable File
68 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CLIENT installer — sets up the we_monitor GUI client.
|
|
# Does NOT install the server (see server/install.sh).
|
|
#
|
|
# Fresh install:
|
|
# chmod +x install.sh
|
|
# ./install.sh
|
|
#
|
|
# Update (code already pulled via git):
|
|
# ./install.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
VENV="$SCRIPT_DIR/.venv"
|
|
PYTHON="$VENV/bin/python"
|
|
|
|
IS_UPDATE=false
|
|
if [[ -x "$PYTHON" ]]; then
|
|
IS_UPDATE=true
|
|
fi
|
|
|
|
if $IS_UPDATE; then
|
|
echo "==> we_monitor GUI updater"
|
|
else
|
|
echo "==> we_monitor GUI installer"
|
|
fi
|
|
echo " Project : $REPO_DIR"
|
|
echo " User : $USER"
|
|
echo ""
|
|
|
|
# ── 1. virtual environment ────────────────────────────────────────────────────
|
|
if [[ ! -x "$PYTHON" ]]; then
|
|
echo "==> Creating virtual environment : $VENV"
|
|
python3 -m venv "$VENV"
|
|
else
|
|
echo "==> Virtual environment exists : $VENV"
|
|
fi
|
|
|
|
echo "==> Installing / updating dependencies"
|
|
"$VENV/bin/pip" install --quiet --upgrade pip
|
|
"$VENV/bin/pip" install --quiet --upgrade -r "$SCRIPT_DIR/requirements.txt"
|
|
echo " Python : $PYTHON"
|
|
echo ""
|
|
|
|
# ── 2. launcher script ────────────────────────────────────────────────────────
|
|
LAUNCHER="$SCRIPT_DIR/run.sh"
|
|
cat > "$LAUNCHER" <<EOF
|
|
#!/usr/bin/env bash
|
|
exec "$PYTHON" "$SCRIPT_DIR/gui_client.py" "\$@"
|
|
EOF
|
|
chmod +x "$LAUNCHER"
|
|
echo "==> Launcher written : $LAUNCHER"
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
if $IS_UPDATE; then
|
|
echo " Update complete."
|
|
else
|
|
echo " Installation complete."
|
|
echo ""
|
|
echo " Start the GUI:"
|
|
echo " $LAUNCHER"
|
|
fi
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|