crosscode: --json reports, --config, env templates, frpc tunnels, restart/export/uninstall/purge
- Every command takes --json (crosscode.script-report/1 on stdout, the log on stderr) and --config (the .env values by layer, from the agent). - .env files come from the release's env.template.json (lib/envtpl.js): written whole on install; on deploy only new variables are appended, and a new required one with no value stops the deploy at the checks. - install --frp: Hub-given ports, a marked frpc.ini block (backup, frpc verify, reload; [common] admin lines added once), no nginx. A database on another server via DB_ADMIN_URL. Refuses an existing database or role. Everything the run made is removed if it fails. - restart, export (crosscode.church-export/1 ZIP), uninstall (final backup, uploads and .env kept 30 days) and purge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,20 +31,28 @@ cmd_status() {
|
||||
[ "${#churches[@]}" -gt 0 ] || { info "No churches on this server ($CROSSCODE_SITES/*/church.env)."; return 0; }
|
||||
fi
|
||||
local c
|
||||
STATUS_JSON=""
|
||||
for c in "${churches[@]}"; do status_church "$c" "$fetch"; done
|
||||
report_result_json churches "[$STATUS_JSON]"
|
||||
}
|
||||
|
||||
STATUS_JSON=""
|
||||
# jstr <text>: a JSON string.
|
||||
jstr() { node -e 'process.stdout.write(JSON.stringify(process.argv[1]))' "$1"; }
|
||||
|
||||
status_church() {
|
||||
local church="$1" fetch="$2" p dir user ref latest url json version db jobs backup line
|
||||
load_church "$church"
|
||||
echo
|
||||
step "$church ($(cenv ADDRESS '(no address)'))"
|
||||
local pj="" hj
|
||||
# shellcheck disable=SC2046 # PRODUCTS is a space-separated list of names
|
||||
for p in $(in_product_order $(cenv PRODUCTS)); do
|
||||
dir="$(pvar "$p" DIR)"
|
||||
user="$(pvar "$p" USER)"
|
||||
if [ ! -d "$dir/.git" ]; then
|
||||
info "$(printf '%-9s %s' "$p" "missing checkout: $dir")"
|
||||
pj+="${pj:+,}{\"product\":\"$p\",\"ref\":null,\"latest\":null,\"health\":null,\"problem\":\"missing checkout\"}"
|
||||
continue
|
||||
fi
|
||||
if [ "$fetch" = 1 ]; then
|
||||
@@ -56,6 +64,7 @@ status_church() {
|
||||
[ -n "$latest" ] && [ "$ref" != "$latest" ] && line="$line (update available)"
|
||||
info "$line"
|
||||
|
||||
hj=null
|
||||
if is_supported_product "$p"; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$CROSSCODE_HOME/products/$p.sh"
|
||||
@@ -66,12 +75,15 @@ status_church() {
|
||||
jobs="$(printf '%s' "$json" | json_get jobs)"
|
||||
backup="$(printf '%s' "$json" | json_get lastBackupAt)"
|
||||
info " health: version ${version:-?}, database ${db:-?}, jobs ${jobs:-?}, last backup ${backup:-never}"
|
||||
hj="$json"
|
||||
else
|
||||
warn " $p isn't answering on $url (pm2 status; pm2 logs)."
|
||||
fi
|
||||
fi
|
||||
pj+="${pj:+,}{\"product\":\"$p\",\"ref\":$(jstr "$ref"),\"latest\":$(jstr "$latest"),\"health\":$hj,\"ports\":$(jstr "$(pvar "$p" PORTS)"),\"domain\":$(jstr "$(pvar "$p" DOMAIN)")}"
|
||||
status_old_folder "$p"
|
||||
done
|
||||
STATUS_JSON+="${STATUS_JSON:+,}{\"church\":\"$church\",\"address\":$(jstr "$(cenv ADDRESS)"),\"products\":[$pj]}"
|
||||
}
|
||||
|
||||
# After `adopt`, the old folder is kept for 14 days so `adopt --undo` can go back to it.
|
||||
|
||||
Reference in New Issue
Block a user