From ff6a43746ace069b21cd0d049a3598624d0c47d0 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 27 May 2026 18:48:34 +0200 Subject: [PATCH] Add client/install.sh; fix server/install.sh paths after move 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 --- client/install.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++ server/install.sh | 9 ++++--- 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100755 client/install.sh diff --git a/client/install.sh b/client/install.sh new file mode 100755 index 0000000..27c0a3b --- /dev/null +++ b/client/install.sh @@ -0,0 +1,67 @@ +#!/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" < 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 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" diff --git a/server/install.sh b/server/install.sh index 6167b26..733a0dc 100755 --- a/server/install.sh +++ b/server/install.sh @@ -15,12 +15,13 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_DIR="$(dirname "$SCRIPT_DIR")" SERVICE_NAME="we_monitor" CREDS_DIR="$HOME/.config/we_monitor" CREDS_FILE="$CREDS_DIR/credentials.json" SYSTEMD_DIR="$HOME/.config/systemd/user" SERVICE_FILE="$SYSTEMD_DIR/$SERVICE_NAME.service" -LOG_DIR="$SCRIPT_DIR/logs" +LOG_DIR="$REPO_DIR/logs" VENV="$SCRIPT_DIR/.venv" PYTHON="$VENV/bin/python" @@ -40,7 +41,7 @@ if $IS_UPDATE; then else echo "==> we_monitor installer" fi -echo " Project : $SCRIPT_DIR" +echo " Project : $REPO_DIR" echo " User : $USER" echo "" @@ -54,7 +55,7 @@ fi echo "==> Installing / updating dependencies" "$VENV/bin/pip" install --quiet --upgrade pip -"$VENV/bin/pip" install --quiet --upgrade -r "$SCRIPT_DIR/server/requirements.txt" +"$VENV/bin/pip" install --quiet --upgrade -r "$SCRIPT_DIR/requirements.txt" echo " Python : $PYTHON" echo "" @@ -100,7 +101,7 @@ Wants=network-online.target [Service] Type=simple -WorkingDirectory=$SCRIPT_DIR +WorkingDirectory=$REPO_DIR ExecStart=$PYTHON -m server.main -c $CREDS_FILE Restart=on-failure RestartSec=60