AkurAI Build
Menu

AkurAI-Build

public

Latest change b2fb6810b8844f39a9752f65118c05ffecf28160 - Fold AkurAI EC2 operations into Build CLI by Ólafur Búi Ólafsson

set -euo pipefail
domain="$1"; warn_days="$2"
sudo systemctl is-enabled --quiet bunfork-monitor.timer
sudo systemctl is-active --quiet bunfork-monitor.timer
sudo systemctl show bunfork-monitor.service -p Result --value | grep -qx success
sudo systemd-analyze verify /etc/systemd/system/bunfork-monitor.service \
  /etc/systemd/system/bunfork-monitor-alert@.service \
  /etc/systemd/system/bunfork-monitor.timer
[ "$(sudo systemctl show bunfork-monitor.service -p ProtectSystem --value)" = strict ]
[ "$(sudo systemctl show bunfork-monitor.service -p NoNewPrivileges --value)" = yes ]
[ "$(sudo systemctl show bunfork-monitor.service -p User --value)" = bunfork ]
sudo systemctl show bunfork-monitor.service -p OnFailure --value | \
  grep -qx bunfork-monitor-alert@bunfork-monitor.service.service
sudo systemctl show bunfork-monitor.timer -p TimersMonotonic --value | \
  grep -q 'OnUnitActiveUSec=15min'
sudo -u bunfork env BUNFORK_MONITOR_DOMAIN="$domain" BUNFORK_TLS_WARN_DAYS="$warn_days" \
  /usr/local/libexec/bunfork-monitor
if sudo -u bunfork env BUNFORK_MONITOR_DOMAIN="$domain" BUNFORK_TLS_WARN_DAYS=3650 \
  /usr/local/libexec/bunfork-monitor >/dev/null 2>&1; then
  echo "TLS threshold failure test unexpectedly passed" >&2
  exit 1
fi
sudo -u bunfork env BUNFORK_MONITOR_DOMAIN="$domain" BUNFORK_TLS_WARN_DAYS="$warn_days" \
  /usr/local/libexec/bunfork-monitor >/dev/null
next="$(systemctl show bunfork-monitor.timer -p NextElapseUSecMonotonic --value)"
[ -n "$next" ]
printf 'timer=active next=%s readiness=verified tls_threshold_days=%s\n' "$next" "$warn_days"