railiance-cluster/bin/railiance

128 lines
4.5 KiB
Text
Raw Normal View History

#!/usr/bin/env bash
2025-09-13 02:39:47 +02:00
# bin/railiance — thin dispatcher; subcommands live in tools/cmd/*
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
2025-09-13 02:39:47 +02:00
PATH="${ROOT}/tools/cmd:${PATH}"
2026-07-26 02:21:19 +02:00
resolve_rail_kubernetes_bin() {
if [[ -n "${RAILIANCE_RAIL_KUBERNETES_BIN:-}" ]]; then
if [[ -x "${RAILIANCE_RAIL_KUBERNETES_BIN}" ]]; then
printf '%s\n' "${RAILIANCE_RAIL_KUBERNETES_BIN}"
return 0
fi
echo "ERROR: RAILIANCE_RAIL_KUBERNETES_BIN is not executable: ${RAILIANCE_RAIL_KUBERNETES_BIN}" >&2
return 2
fi
local sibling="${ROOT}/../rail-kubernetes/bin/railiance"
if [[ -x "${sibling}" ]]; then
printf '%s\n' "${sibling}"
return 0
fi
return 1
}
run_compat_command() {
local cmd="$1"
shift || true
local delegate_bin=""
local resolve_status=0
if delegate_bin="$(resolve_rail_kubernetes_bin)"; then
exec "${delegate_bin}" "${cmd}" "$@"
else
resolve_status=$?
fi
if [[ "${resolve_status}" -eq 2 ]]; then
exit 1
fi
echo "WARN: rail-kubernetes delegate not found; using compatibility implementation from railiance-cluster" >&2
case "${cmd}" in
create-overlay) bash "$ROOT/tools/create_railiance_overlay_repo.sh" "$@" ;;
run) exec railiance-run "$@" ;;
deploy) exec railiance-stage2 deploy "$@" ;;
observe) exec railiance-stage2 observe "$@" ;;
promote) exec railiance-stage3 promote "$@" ;;
rollback) exec railiance-stage3 rollback "$@" ;;
*) echo "Unknown compatibility command: ${cmd}" >&2; exit 2 ;;
esac
}
usage() {
cat <<'EOF'
2025-09-13 02:39:47 +02:00
Usage: bin/railiance <command> [args]
Commands:
2025-09-13 02:39:47 +02:00
doctor Check workstation & provisioning toolchains
next Show canonical first-time sequence
2025-09-13 02:39:47 +02:00
plan-host Provider-neutral host specs & checklist
gen-ssh-key Generate SSH key and show public part
cloudinit Emit minimal cloud-init user-data
init-repo Idempotently furnish repo housekeeping
2026-07-26 02:21:19 +02:00
create-overlay Delegate to rail-kubernetes or use local compatibility scaffold
run Delegate to rail-kubernetes or run local Stage 1 compatibility path
deploy Delegate to rail-kubernetes or run local Stage 2 compatibility path
observe Delegate to rail-kubernetes or run local Stage 2 compatibility path
promote Delegate to rail-kubernetes or run local Stage 3 compatibility path
rollback Delegate to rail-kubernetes or run local Stage 3 compatibility path
deploy-triage-robustness
Deploy ACTIVITY-WP-0016 and prove daily-triage validation
admin-sync-smoke
Run activity-core no-restart POST /admin/sync smoke
build-spore Build a distributable "Spore" bundle
seed-local Run the seed script on this machine
2025-09-13 02:39:47 +02:00
checklist Pre-VM checklist
backup Backup postgres + config to Nextcloud (age-encrypted)
preflight Pre-migration safety gate (must pass before cluster work)
help Show this help
EOF
}
2025-09-13 02:39:47 +02:00
cmd="${1:-help}"; shift || true
case "$cmd" in
help) usage ;;
2025-09-13 02:39:47 +02:00
doctor) exec railiance-doctor "$@" ;;
2025-09-13 02:46:48 +02:00
plan-host) exec railiance-plan-host "$@" ;;
gen-ssh-key)
2025-09-13 02:39:47 +02:00
if ! command -v ssh-keygen >/dev/null 2>&1; then echo "Missing: ssh-keygen" >&2; exit 1; fi
key="${HOME}/.ssh/id_ed25519"
[[ -f "$key" ]] || ssh-keygen -t ed25519 -N "" -f "$key"
2025-09-13 02:39:47 +02:00
echo "Public key:"; cat "${key}.pub"
;;
cloudinit) cat "$ROOT/cloudinit/user-data.yaml" ;;
init-repo) bash "$ROOT/tools/furnish_railiance_repo.sh" ;;
2026-07-26 02:21:19 +02:00
create-overlay) run_compat_command create-overlay "$@" ;;
run) run_compat_command run "$@" ;;
deploy) run_compat_command deploy "$@" ;;
observe) run_compat_command observe "$@" ;;
promote) run_compat_command promote "$@" ;;
rollback) run_compat_command rollback "$@" ;;
deploy-triage-robustness) exec railiance-deploy-activity-core-triage-robustness "$@" ;;
admin-sync-smoke) exec railiance-admin-sync-smoke "$@" ;;
build-spore) bash "$ROOT/tools/build_spore.sh" ;;
seed-local) bash "$ROOT/tools/seed_node.sh" ;;
checklist)
cat <<'CK'
Rent-a-VM Checklist
-------------------
[ ] Provider account ready (billing set)
[ ] Region chosen (low latency to you/users)
[ ] Image: Ubuntu 24.04 LTS
[ ] Size: 2 vCPU / 48 GB RAM / 60+ GB SSD
[ ] SSH key uploaded (see gen-ssh-key)
[ ] Cloud-init pasted (see: bin/railiance cloudinit)
[ ] Hostname set (e.g., railiance-seed-1)
[ ] Record public IP / DNS
CK
;;
2025-09-13 02:39:47 +02:00
next) cat "$ROOT/QUICKSTART.md" ;;
backup) exec railiance-backup "$@" ;;
preflight) exec railiance-preflight "$@" ;;
2025-09-13 02:39:47 +02:00
*) echo "Unknown command: $cmd" >&2; usage; exit 2 ;;
esac