Files
we_monitor/install_client.sh
T
jensandClaude Sonnet 4.6 4e2a22d35e installers: move to project root, share a single .venv
client/install.sh → install_client.sh
server/install.sh → install_server.sh

Both scripts now resolve REPO_DIR as their own directory (repo root)
and use a shared .venv at the repo root instead of per-subdirectory
virtual environments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 09:30:07 +02:00

83 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# CLIENT installer — sets up the we_monitor GUI client.
# Does NOT install the server (see install_server.sh).
#
# Fresh install:
# chmod +x install_client.sh
# ./install_client.sh
#
# Update (code already pulled via git):
# ./install_client.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$SCRIPT_DIR"
VENV="$REPO_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 "$REPO_DIR/client/requirements.txt"
echo " Python : $PYTHON"
echo ""
# ── 2. launcher script ────────────────────────────────────────────────────────
LAUNCHER="$REPO_DIR/client/run.sh"
cat > "$LAUNCHER" <<EOF
#!/usr/bin/env bash
exec "$PYTHON" "$REPO_DIR/client/gui_client.py" "\$@"
EOF
chmod +x "$LAUNCHER"
echo "==> Launcher written : $LAUNCHER"
# ── 3. system command ─────────────────────────────────────────────────────────
BIN_DIR="$HOME/.local/bin"
CMD="$BIN_DIR/we_monitor_gui"
mkdir -p "$BIN_DIR"
cat > "$CMD" <<EOF
#!/usr/bin/env bash
exec "$PYTHON" "$REPO_DIR/client/gui_client.py" "\$@"
EOF
chmod +x "$CMD"
echo "==> System command : $CMD"
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
echo " Note: $BIN_DIR is not in your PATH."
echo " Add to ~/.bashrc or ~/.profile: export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if $IS_UPDATE; then
echo " Update complete."
else
echo " Installation complete."
echo ""
echo " Start the GUI:"
echo " we_monitor_gui"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"