app
adom-courier
Public Made by Adomby adom
App-neutral Google Chat human-in-the-loop middleware for Adom apps. Two directions: apps POST /requests to ask a human (Marv posts via adom-gchat, the reply comes back with identity + attachment bytes
#!/usr/bin/env bash
# adom-courier — one-time bootstrap for a fresh default-light container (registry-update model).
# Idempotent. First-time order on a bare box:
# curl -fsSL https://wiki.adom.inc/download/adom/adom-wiki-cli/1.0.2/adom-wiki-cli-v1.0.2 \
# -o ~/.local/bin/adom-wiki && chmod +x ~/.local/bin/adom-wiki # the adom-wiki CLI
# adom-wiki pkg install adom/adom-courier # gets this package
# bash ~/project/adom_modules/adom/adom-courier/service/deploy.sh # this script
set -euo pipefail
PORT="${PORT:-8870}"; export PATH="$HOME/.local/bin:$PATH"
PKG_DIR="${ADOM_COURIER_PKG:-$HOME/project/adom_modules/adom/adom-courier}"
DATA="$HOME/.config/adom-courier"
say(){ printf '\n\033[1m== %s ==\033[0m\n' "$1"; }
say "1/6 Node.js"
command -v node >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y nodejs >/dev/null; }
node --version
say "2/6 adom-wiki CLI + adom-courier (+ deps, Adom OAuth provider, requests, cron)"
mkdir -p "$HOME/.local/bin"
command -v adom-wiki >/dev/null || { curl -fsSL https://wiki.adom.inc/download/adom/adom-wiki-cli/1.0.2/adom-wiki-cli-v1.0.2 -o "$HOME/.local/bin/adom-wiki" && chmod +x "$HOME/.local/bin/adom-wiki"; }
export PATH="$HOME/.local/bin:$PATH"
# adom-courier pulls adom/adom-google + adom/adom-gchat as deps; adom-google-adom = Adom OAuth provider (staff).
adom-wiki pkg install adom/adom-courier adom/adom-google-adom
python3 -c 'import requests' 2>/dev/null || sudo apt-get install -y python3-requests >/dev/null 2>&1 \
|| python3 -m pip install --user --break-system-packages requests >/dev/null 2>&1 || true
command -v crontab >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y cron >/dev/null; }
say "3/6 deployment config (external — survives updates) + cron watchdog"
mkdir -p "$DATA"
if [ ! -f "$DATA/config.json" ]; then cp "$PKG_DIR/config.json" "$DATA/config.json"; echo " seeded TEMPLATE -> $DATA/config.json — EDIT IT (add your spaces/apps)"; fi
( crontab -l 2>/dev/null | grep -v 'adom-courier/service/watchdog.sh'; \
echo "*/2 * * * * $PKG_DIR/service/watchdog.sh >> /tmp/adom-courier-watchdog.log 2>&1" ) | crontab -
pgrep -x cron >/dev/null || sudo service cron start 2>/dev/null || sudo cron 2>/dev/null || true
say "4/6 start service"
bash "$PKG_DIR/service/watchdog.sh"; sleep 3
say "5/6 health"
if curl -sf "http://127.0.0.1:$PORT/health"; then echo " — OK"; else echo "FAILED (see /tmp/adom-courier.log)"; exit 1; fi
say "6/6 MANUAL — interactive steps only you can do"
cat <<EOF
a) adom-google auth # authorize the READING identity (one consent)
b) adom-gchat setup # add each space's Marv webhook
c) edit $DATA/config.json # spaces -> {id,gchatSpace}; apps -> {dispatchUrl}
d) (from dev) adom-cli carbon containers port-add <slug> --port $PORT
Updates auto-pull from the registry: 'adom-wiki pkg publish' a new version -> watchdog runs
'adom-wiki pkg update' (≤15 min) -> restart. No git auth, no manual redeploy.
EOF