Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:41:44

0001 #!/usr/bin/env bash
0002 # swf-alarms install — creates venv, installs package, prepares log dir.
0003 # Alarm state lives in swf-remote's Postgres; schema is owned by
0004 # swf-remote's Django migrations and applied by its deploy script, not here.
0005 #
0006 # Usage:  bash deploy/install.sh
0007 set -euo pipefail
0008 
0009 HERE=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
0010 VENV="$HERE/.venv"
0011 CONFIG="$HERE/config.toml"
0012 LOG_DIR="/var/log/swf-alarms"
0013 
0014 echo "[swf-alarms install] repo dir:  $HERE"
0015 
0016 if [ ! -d "$VENV" ]; then
0017     echo "[swf-alarms install] creating venv"
0018     python3 -m venv "$VENV"
0019 fi
0020 "$VENV/bin/pip" install --upgrade pip >/dev/null
0021 "$VENV/bin/pip" install -e "$HERE" >/dev/null
0022 
0023 if [ ! -f "$CONFIG" ]; then
0024     echo "[swf-alarms install] no config.toml yet — copying config.toml.example"
0025     cp "$HERE/config.toml.example" "$CONFIG"
0026     echo "[swf-alarms install] edit $CONFIG before first run"
0027 fi
0028 
0029 sudo mkdir -p "$LOG_DIR"
0030 sudo chown admin:admin "$LOG_DIR"
0031 sudo chmod 775 "$LOG_DIR"
0032 
0033 echo "[swf-alarms install] done."
0034 echo "  venv:    $VENV"
0035 echo "  config:  $CONFIG"
0036 echo "  logs:    $LOG_DIR/"
0037 echo
0038 echo "Schema: swf-remote's migrations own alarm_run / alarm_check_run /"
0039 echo "  alarm_firing / alarm_firing_event. Ensure they're applied:"
0040 echo "  cd /home/admin/github/swf-remote/src &&"
0041 echo "  /var/www/swf-remote/.venv/bin/python manage.py migrate remote_app"
0042 echo
0043 echo "Next:"
0044 echo "  1. edit $CONFIG  (thresholds, recipients)"
0045 echo "  2. one-shot test: $VENV/bin/swf-alarms-run --config $CONFIG --dry-run -v"
0046 echo "  3. install cron:  see deploy/crontab.example"