From 7b1f69ab3c18344e1c25a218ef8cdf4a6924118e Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sat, 4 Apr 2026 18:48:51 -0300 Subject: [PATCH] hecate: allow forced host config templates during install --- README.md | 1 + scripts/install.sh | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16818a7..ddf222f 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Installer knobs (optional): - `HECATE_ENABLE_BOOTSTRAP=1` enables `hecate-bootstrap.service` on this host. - `HECATE_ENABLE_BOOTSTRAP=0` disables it; default `auto` enables bootstrap by default. - `HECATE_MANAGE_NUT=0` skips writing NUT/udev files. +- `HECATE_FORCE_CONFIG_TEMPLATE=coordinator|peer|example` overwrites `/etc/hecate/hecate.yaml` from a known template during install. - `HECATE_NUT_UPS_NAME` (default inferred from `/etc/hecate/hecate.yaml` target, fallback `pyrphoros`) - `HECATE_NUT_VENDOR_ID` / `HECATE_NUT_PRODUCT_ID` (defaults `0764` / `0601`) - `HECATE_NUT_MONITOR_USER` / `HECATE_NUT_MONITOR_PASSWORD` (defaults `monuser` / `hecateupsmon`) diff --git a/scripts/install.sh b/scripts/install.sh index 9c243a0..dfe8440 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -21,6 +21,7 @@ NUT_VENDOR_ID="${HECATE_NUT_VENDOR_ID:-0764}" NUT_PRODUCT_ID="${HECATE_NUT_PRODUCT_ID:-0601}" NUT_MONITOR_USER="${HECATE_NUT_MONITOR_USER:-monuser}" NUT_MONITOR_PASSWORD="${HECATE_NUT_MONITOR_PASSWORD:-hecateupsmon}" +FORCE_CONFIG_TEMPLATE="${HECATE_FORCE_CONFIG_TEMPLATE:-}" while [[ $# -gt 0 ]]; do case "$1" in @@ -325,7 +326,27 @@ echo "[install] installing config + state dirs" install -d -m 0750 "${CONF_DIR}" install -d -m 0750 "${STATE_DIR}" install -d -m 0755 "${LIB_DIR}" -if [[ ! -f "${CONF_DIR}/hecate.yaml" ]]; then + +if [[ -n "${FORCE_CONFIG_TEMPLATE}" ]]; then + case "${FORCE_CONFIG_TEMPLATE}" in + coordinator) + install -m 0640 configs/hecate.titan-db.yaml "${CONF_DIR}/hecate.yaml" + echo "[install] forced config template: coordinator" + ;; + peer) + install -m 0640 configs/hecate.tethys.yaml "${CONF_DIR}/hecate.yaml" + echo "[install] forced config template: peer" + ;; + example) + install -m 0640 configs/hecate.example.yaml "${CONF_DIR}/hecate.yaml" + echo "[install] forced config template: example" + ;; + *) + echo "[install] unknown HECATE_FORCE_CONFIG_TEMPLATE value: ${FORCE_CONFIG_TEMPLATE}" >&2 + exit 1 + ;; + esac +elif [[ ! -f "${CONF_DIR}/hecate.yaml" ]]; then install -m 0640 configs/hecate.example.yaml "${CONF_DIR}/hecate.yaml" echo "[install] wrote default config to ${CONF_DIR}/hecate.yaml" else