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:
@@ -77,3 +77,40 @@ events_reload() {
|
||||
events_ensure_pm2_config "$1" "$2"
|
||||
run_as "$2" "$(events_app "$1")" pm2 reload ecosystem.config.js --update-env
|
||||
}
|
||||
|
||||
# The church's data as crosscode.church-export/1 into <out dir> (owned by the app user). Releases
|
||||
# from before the export (events@2.2.0) don't have the script.
|
||||
events_export() {
|
||||
local dir="$1" user="$2" out="$3" app
|
||||
app="$(events_app "$dir")"
|
||||
[ -f "$app/backend/scripts/export-church.ts" ] ||
|
||||
die "This release of Events ($(checkout_ref "$dir" events)) has no export yet. Update it first."
|
||||
run_as "$user" "$app/backend" npx tsx scripts/export-church.ts --out-dir "$out"
|
||||
}
|
||||
|
||||
# Uploaded files into <dest> (WhatsApp ticket PDFs waiting to be sent are left out).
|
||||
events_copy_uploads() {
|
||||
local src
|
||||
src="$(events_app "$1")/backend/public/uploads"
|
||||
mkdir -p "$2"
|
||||
[ -d "$src" ] || return 0
|
||||
rsync -a --exclude tickets-temp/ "$src/" "$2/"
|
||||
}
|
||||
|
||||
# What uninstall keeps for 30 days in <dest>: the backups (the last is the final one), the
|
||||
# uploads, and the .env files (the backup's stored secrets are encrypted with its JWT_SECRET).
|
||||
events_keep() {
|
||||
local app dest="$2"
|
||||
app="$(events_app "$1")"
|
||||
mkdir -p "$dest"
|
||||
[ ! -d "$app/backend/backups" ] || rsync -a "$app/backend/backups/" "$dest/backups/"
|
||||
[ ! -d "$app/backend/public/uploads" ] || tar -czf "$dest/uploads.tar.gz" -C "$app/backend/public" uploads
|
||||
cp -p "$app/backend/.env" "$dest/backend.env" 2>/dev/null || true
|
||||
cp -p "$app/frontend/.env.production" "$dest/frontend.env.production" 2>/dev/null || true
|
||||
chmod -R go-rwx "$dest"
|
||||
}
|
||||
|
||||
# --var arguments for the env template (envtpl.js), from church.env.
|
||||
events_env_vars() {
|
||||
printf '%s\n' --var "domain=$(pvar events DOMAIN)" --var "apiPort=$(events_api_port)" --var "webPort=$(events_web_port)" --var "church=$(cenv CHURCH)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user