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:
2026-11-17 12:50:19 +02:00
co-authored by Claude Opus 5.5
parent 350ab9f4e8
commit e9e9b5a97f
17 changed files with 1308 additions and 88 deletions
+37 -2
View File
@@ -193,6 +193,26 @@ deploy_church() {
done
[ "$failed" = 0 ] || die "Requirements not met for $church. Nothing was changed."
# New settings in the target release's env template (AGENT-1.0-PLAN §5): a new required one
# with no value anywhere stops the deploy here, before anything is touched.
local tpl out
local -a vars
for p in "${products[@]}"; do
[ -n "${TVER[$p]}" ] || continue
tpl="$(mktemp)"
if git_in "${DIR[$p]}" show "${TARGET[$p]}:apps/$p/env.template.json" > "$tpl" 2>/dev/null; then
mapfile -t vars < <("${p}_env_vars")
if out="$(env_apply_template "$tpl" "$(pvar "$p" DIR)/apps/$p" "$p" "${TARGET[$p]}" --check "${vars[@]}" 2>&1)"; then
[ -z "$out" ] || printf '%s\n' "$out" | sed "s/^/ $p: /"
else
warn "$p ${TVER[$p]}: $out"
failed=1
fi
fi
rm -f "$tpl"
done
[ "$failed" = 0 ] || die "Settings missing for $church (set them in the Hub's server configuration or defaults). Nothing was changed."
for p in "${products[@]}"; do
if [ "${PREV[$p]}" = "${TARGET[$p]}" ]; then
info "$p: already on ${PREV[$p]}."
@@ -218,8 +238,17 @@ deploy_church() {
echo
step "Summary for $church"
for p in "${products[@]}"; do info "$(printf '%-9s %s' "$p" "${RESULT[$p]}")"; done
[ "$stopped" = 0 ] || return 1
local json="" rolled=0
for p in "${products[@]}"; do
info "$(printf '%-9s %s' "$p" "${RESULT[$p]}")"
json+="${json:+,}\"$p\":{\"from\":\"${PREV[$p]}\",\"to\":\"${TARGET[$p]}\",\"result\":\"${RESULT[$p]//\"/\'}\"}"
[[ "${RESULT[$p]}" != *"rolled back to"*"running again"* && "${RESULT[$p]}" != *"rolled back to"*"never stopped"* ]] || rolled=1
done
report_result_json products "{$json}"
if [ "$stopped" = 1 ]; then
[ "$rolled" = 0 ] || report_status rolled-back
return 1
fi
}
# deploy_product <product> <checkout> <user> <previous ref> <target ref>: sets DEPLOY_OK and
@@ -238,6 +267,12 @@ deploy_product() {
echo checkout > "$stage_file"
step "$p: checking out $target"
run_as "$user" "$dir" git checkout -q --detach "$target"
if [ -f "$dir/apps/$p/env.template.json" ]; then
step "$p: settings new in this release"
local -a vars
mapfile -t vars < <("${p}_env_vars")
env_apply "$dir/apps/$p" "$p" "$target" "${vars[@]}" | sed 's/^/ /'
fi
step "$p: installing"
"${p}_install_deps" "$dir" "$user"
step "$p: migrations"