installer: support legacy source tree while enforcing ananke outputs
This commit is contained in:
parent
f76cb5cdeb
commit
dcc07fb18d
@ -617,6 +617,113 @@ retire_legacy_hecate_install() {
|
||||
rm -rf /var/lib/hecate
|
||||
}
|
||||
|
||||
resolve_build_target() {
|
||||
if [[ -d "${REPO_DIR}/cmd/ananke" ]]; then
|
||||
echo "./cmd/ananke"
|
||||
return 0
|
||||
fi
|
||||
if [[ -d "${REPO_DIR}/cmd/hecate" ]]; then
|
||||
echo "./cmd/hecate"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
install_config_template() {
|
||||
local template="$1"
|
||||
local dest="$2"
|
||||
local src modern legacy
|
||||
|
||||
modern="configs/ananke.${template}.yaml"
|
||||
case "${template}" in
|
||||
coordinator)
|
||||
legacy="configs/hecate.titan-db.yaml"
|
||||
;;
|
||||
peer)
|
||||
legacy="configs/hecate.tethys.yaml"
|
||||
;;
|
||||
example)
|
||||
legacy="configs/hecate.example.yaml"
|
||||
;;
|
||||
*)
|
||||
echo "[install] unknown config template key: ${template}" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -f "${modern}" ]]; then
|
||||
src="${modern}"
|
||||
install -m 0640 "${src}" "${dest}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${legacy}" ]]; then
|
||||
src="$(mktemp)"
|
||||
legacy_path_rewrite "${legacy}" "${src}"
|
||||
install -m 0640 "${src}" "${dest}"
|
||||
rm -f "${src}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "[install] missing both modern and legacy config templates for '${template}'." >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
install_systemd_units() {
|
||||
local unit
|
||||
local tmp
|
||||
|
||||
for unit in service bootstrap.service update.service update.timer; do
|
||||
local modern_src="deploy/systemd/ananke.${unit}"
|
||||
local legacy_src="deploy/systemd/hecate.${unit}"
|
||||
local target="${SYSTEMD_DIR}/ananke.${unit}"
|
||||
|
||||
if [[ -f "${modern_src}" ]]; then
|
||||
install -m 0644 "${modern_src}" "${target}"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -f "${legacy_src}" ]]; then
|
||||
tmp="$(mktemp)"
|
||||
legacy_path_rewrite "${legacy_src}" "${tmp}"
|
||||
install -m 0644 "${tmp}" "${target}"
|
||||
rm -f "${tmp}"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "[install] missing both modern and legacy systemd unit sources for ananke.${unit}" >&2
|
||||
return 1
|
||||
done
|
||||
}
|
||||
|
||||
install_self_update_script() {
|
||||
local modern_src="scripts/ananke-self-update.sh"
|
||||
local legacy_src="scripts/hecate-self-update.sh"
|
||||
local target="${LIB_DIR}/ananke-self-update.sh"
|
||||
local tmp
|
||||
|
||||
if [[ -f "${modern_src}" ]]; then
|
||||
install -m 0755 "${modern_src}" "${target}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${legacy_src}" ]]; then
|
||||
tmp="$(mktemp)"
|
||||
legacy_path_rewrite "${legacy_src}" "${tmp}"
|
||||
sed -Ei \
|
||||
-e 's/HECATE_/ANANKE_/g' \
|
||||
-e 's/hecate-self-update/ananke-self-update/g' \
|
||||
-e 's#bstein/hecate\.git#bstein/ananke.git#g' \
|
||||
"${tmp}"
|
||||
install -m 0755 "${tmp}" "${target}"
|
||||
rm -f "${tmp}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "[install] missing both modern and legacy self-update scripts." >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
configure_nut() {
|
||||
if [[ "${MANAGE_NUT}" != "1" ]]; then
|
||||
echo "[install] skipping NUT configuration (ANANKE_MANAGE_NUT=${MANAGE_NUT})"
|
||||
@ -683,7 +790,15 @@ migrate_legacy_hecate_install
|
||||
echo "[install] building ananke"
|
||||
cd "${REPO_DIR}"
|
||||
mkdir -p dist
|
||||
go build -o dist/ananke ./cmd/ananke
|
||||
BUILD_TARGET="$(resolve_build_target || true)"
|
||||
if [[ -z "${BUILD_TARGET}" ]]; then
|
||||
echo "[install] unable to find build target (expected cmd/ananke or cmd/hecate)." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${BUILD_TARGET}" != "./cmd/ananke" ]]; then
|
||||
echo "[install] build target fallback: ${BUILD_TARGET}"
|
||||
fi
|
||||
go build -o dist/ananke "${BUILD_TARGET}"
|
||||
|
||||
echo "[install] installing binary"
|
||||
install -d -m 0755 "${BIN_DIR}"
|
||||
@ -697,15 +812,15 @@ install -d -m 0755 "${LIB_DIR}"
|
||||
if [[ -n "${FORCE_CONFIG_TEMPLATE}" ]]; then
|
||||
case "${FORCE_CONFIG_TEMPLATE}" in
|
||||
coordinator)
|
||||
install -m 0640 configs/ananke.titan-db.yaml "${CONF_DIR}/ananke.yaml"
|
||||
install_config_template coordinator "${CONF_DIR}/ananke.yaml"
|
||||
echo "[install] forced config template: coordinator"
|
||||
;;
|
||||
peer)
|
||||
install -m 0640 configs/ananke.tethys.yaml "${CONF_DIR}/ananke.yaml"
|
||||
install_config_template peer "${CONF_DIR}/ananke.yaml"
|
||||
echo "[install] forced config template: peer"
|
||||
;;
|
||||
example)
|
||||
install -m 0640 configs/ananke.example.yaml "${CONF_DIR}/ananke.yaml"
|
||||
install_config_template example "${CONF_DIR}/ananke.yaml"
|
||||
echo "[install] forced config template: example"
|
||||
;;
|
||||
*)
|
||||
@ -714,7 +829,7 @@ if [[ -n "${FORCE_CONFIG_TEMPLATE}" ]]; then
|
||||
;;
|
||||
esac
|
||||
elif [[ ! -f "${CONF_DIR}/ananke.yaml" ]]; then
|
||||
install -m 0640 configs/ananke.example.yaml "${CONF_DIR}/ananke.yaml"
|
||||
install_config_template example "${CONF_DIR}/ananke.yaml"
|
||||
echo "[install] wrote default config to ${CONF_DIR}/ananke.yaml"
|
||||
else
|
||||
echo "[install] keeping existing config at ${CONF_DIR}/ananke.yaml"
|
||||
@ -724,11 +839,8 @@ ensure_ananke_ssh_identity
|
||||
ensure_ananke_kubeconfig
|
||||
|
||||
echo "[install] installing systemd units"
|
||||
install -m 0644 deploy/systemd/ananke.service "${SYSTEMD_DIR}/ananke.service"
|
||||
install -m 0644 deploy/systemd/ananke-bootstrap.service "${SYSTEMD_DIR}/ananke-bootstrap.service"
|
||||
install -m 0644 deploy/systemd/ananke-update.service "${SYSTEMD_DIR}/ananke-update.service"
|
||||
install -m 0644 deploy/systemd/ananke-update.timer "${SYSTEMD_DIR}/ananke-update.timer"
|
||||
install -m 0755 scripts/ananke-self-update.sh "${LIB_DIR}/ananke-self-update.sh"
|
||||
install_systemd_units
|
||||
install_self_update_script
|
||||
|
||||
resolve_nut_ups_name
|
||||
configure_nut
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user