#!/usr/bin/env bash # install.sh — Idempotent Portable Installer for current-events-isopsephic-exegesis # Supports RHEL 8/9/10, Fedora, Rocky, AlmaLinux, Debian/Ubuntu, and macOS. # Pays strict attention to env TZ when registering the daily 00:00 GMT (UTC) cron job. set -euo pipefail BUNDLE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" HERMES_HOME="${HERMES_HOME:-$HOME/.hermes}" SKILLS_DEST="${HERMES_SKILLS_DIR:-$HERMES_HOME/skills/creative}" if [ -z "${WORKSPACE_DIR:-}" ]; then if [ -d "/workspace/ingglish-hyperdope-gematria" ]; then WORKSPACE_DIR="/workspace/ingglish-hyperdope-gematria" else WORKSPACE_DIR="/workspace" fi fi SCRIPTS_DEST="${HERMES_SCRIPTS_DIR:-$HERMES_HOME/scripts}" echo "[1/5] Detecting environment and timezone offset for 00:00 GMT target..." HOST_TZ="${TZ:-}" if [ -z "$HOST_TZ" ] && [ -f /etc/timezone ]; then HOST_TZ="$(cat /etc/timezone | tr -d '[:space:]')" elif [ -z "$HOST_TZ" ] && [ -L /etc/localtime ]; then HOST_TZ="$(readlink /etc/localtime | sed 's|.*/zoneinfo/||')" fi HOST_TZ="${HOST_TZ:-UTC}" # Compute local hour corresponding to 00:00 UTC using Python CRON_HOUR_LOCAL="$(python3 -c ' import datetime utc_midnight = datetime.datetime(2026, 11, 2, 0, 0, tzinfo=datetime.timezone.utc) local_dt = utc_midnight.astimezone() print(local_dt.hour) ')" CRON_MIN_LOCAL="$(python3 -c ' import datetime utc_midnight = datetime.datetime(2026, 11, 2, 0, 0, tzinfo=datetime.timezone.utc) local_dt = utc_midnight.astimezone() print(local_dt.minute) ')" CRON_EXPR="${CRON_MIN_LOCAL} ${CRON_HOUR_LOCAL} * * *" echo " -> Detected Host TZ: ${HOST_TZ} (00:00 GMT maps to local cron '${CRON_EXPR}')" echo "[2/5] Installing skills into ${SKILLS_DEST}..." mkdir -p "${SKILLS_DEST}" 2>/dev/null || true if [ -w "${SKILLS_DEST}" ]; then cp -a "${BUNDLE_DIR}/skills/"* "${SKILLS_DEST}/" echo " -> Installed 8 creative Ingglish AQ skills (phonetic-and-gematria-ciphers, hyperdope-ingglish-ci, bidirectional-aq-evaluation, aq-tier-list-visualizer, current-events-isopsephic-exegesis, isopsephic-humor-and-exegesis, isopsephic-lecture-synthesis, isopsephic-wire-report-synthesis)" else echo " -> ${SKILLS_DEST} is read-only (container mount); skipping skill copy." fi echo "[3/5] Unpacking offline-vendored ingglish npm runtime into ${WORKSPACE_DIR}/node_modules..." mkdir -p "${WORKSPACE_DIR}/node_modules" tar -xzf "${BUNDLE_DIR}/vendor/ingglish-vendor.tgz" -C "${WORKSPACE_DIR}/node_modules" echo "[4/5] Installing deterministic collector, CI, evaluation, tier-list, wire-report & lecture scripts..." mkdir -p "${WORKSPACE_DIR}/ingglish-aq-archive/scripts" for s in collect_news_aq.py ci_provision_ingglish.py manage_lecture_artifacts.py build_wire_report_pdf.py evaluate_aq.mjs generate_aq_tier_list.py pdf_create.py pdf_read.py; do cp -f "${BUNDLE_DIR}/scripts/${s}" "${WORKSPACE_DIR}/ingglish-aq-archive/scripts/${s}" chmod 0755 "${WORKSPACE_DIR}/ingglish-aq-archive/scripts/${s}" done if mkdir -p "${SCRIPTS_DEST}" 2>/dev/null && [ -w "${SCRIPTS_DEST}" ]; then cp -f "${BUNDLE_DIR}/scripts/collect_news_aq.py" "${SCRIPTS_DEST}/collect_news_aq.py" chmod 0755 "${SCRIPTS_DEST}/collect_news_aq.py" fi echo "[5/5] Verifying SELinux labels (RHEL/Fedora) & registering 00:00 GMT schedule..." if command -v chcon >/dev/null 2>&1 && [ -d /var/lib/ingglish-aq-archive ]; then chcon -Rt container_file_t /var/lib/ingglish-aq-archive 2>/dev/null || true fi if command -v hermes >/dev/null 2>&1; then echo " -> Registering via hermes cron..." hermes cron add --name "current-events-isopsephic-exegesis-daily-0000-gmt" \ --schedule "${CRON_EXPR}" \ --skill "current-events-isopsephic-exegesis" \ --skill "phonetic-and-gematria-ciphers" \ --prompt "Execute current-events-isopsephic-exegesis for the completed UTC day (TZ=UTC collect_news_aq.py --mode closing-bell)." 2>/dev/null || true fi echo "Installation complete. Verified offline Ingglish + Base-36 AQ readiness."