Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-26 08:40:21

0001 #!/usr/bin/env bash
0002 # swf-alarms install — creates venv, installs package, prepares log dir.
0003 # Alarm state lives in swf-monitor's Postgres; schema is owned by
0004 # swf-monitor'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 DEPLOY_ROOT="${SWF_MONITOR_DEPLOY_ROOT:-/opt/swf-monitor}"
0011 VENV="${SWF_ALARMS_VENV:-$DEPLOY_ROOT/shared/alarms-venv}"
0012 CONFIG_DIR="${SWF_ALARMS_CONFIG_DIR:-$DEPLOY_ROOT/config/alarms}"
0013 CONFIG="${SWF_ALARMS_CONFIG:-$CONFIG_DIR/config.toml}"
0014 LOG_DIR="${SWF_ALARMS_LOG_DIR:-$DEPLOY_ROOT/shared/logs/swf-alarms}"
0015 BUILD_DIR=$(mktemp -d)
0016 trap 'rm -rf "$BUILD_DIR"' EXIT
0017 
0018 echo "[swf-alarms install] repo dir:  $HERE"
0019 
0020 if [ ! -d "$VENV" ]; then
0021     echo "[swf-alarms install] creating venv"
0022     python3 -m venv "$VENV"
0023 fi
0024 mkdir -p "$CONFIG_DIR" "$LOG_DIR"
0025 chmod 775 "$CONFIG_DIR" "$LOG_DIR"
0026 "$VENV/bin/pip" install --upgrade pip >/dev/null
0027 cp -R "$HERE"/. "$BUILD_DIR"/
0028 "$VENV/bin/pip" install "$BUILD_DIR" >/dev/null
0029 chmod -R u+rwX,g+rwX,o+rX "$VENV"
0030 
0031 if [ ! -f "$CONFIG" ]; then
0032     echo "[swf-alarms install] no config.toml yet — copying config.toml.example"
0033     cp "$HERE/config.toml.example" "$CONFIG"
0034     echo "[swf-alarms install] edit $CONFIG before first run"
0035 fi
0036 
0037 chmod 775 "$LOG_DIR"
0038 
0039 echo "[swf-alarms install] done."
0040 echo "  venv:    $VENV"
0041 echo "  config:  $CONFIG"
0042 echo "  logs:    $LOG_DIR/"
0043 echo
0044 echo "Schema: swf-monitor's migrations own entry / entry_context / entry_version."
0045 echo "  Ensure they are applied by the normal swf-monitor deploy/migrate path."
0046 echo
0047 echo "Next:"
0048 echo "  1. edit $CONFIG  (thresholds, recipients)"
0049 echo "  2. one-shot test: $VENV/bin/swf-alarms-run --config $CONFIG --dry-run -v"
0050 echo "  3. install cron:  see deploy/crontab.example"