dns / dns (push) Successful in 11s
The stack's settings are repo variables, its secrets repo secrets, and NATS_PASSWORD an org secret the content repo can share. The deploy workflow checks they are all set, writes .env, portal.env, nats.env and chat.env into the runner's own directory, and the root script (now in the repo as deploy-tomtervel) pulls main, puts them in place as root's and brings the stack up. So nothing is edited on the host or committed: a host name or a version is a variable changed and a Run workflow. nats.conf reads NATS_PASSWORD from its environment, so it is committed rather than rendered. bootstrap.sh only makes Kanidm's config and certificate and recovers its admins; kanidm-setup.sh reads portal.env, and leaves the two secrets it makes in kanidm-setup.secrets for gt. The DNS workflow uses actions/checkout and actions/cache (the runner's cache server) for dnscontrol, at the DNSCONTROL_VERSION variable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
52 lines
2.1 KiB
Bash
Executable File
52 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# What a fresh host needs before the first deploy, and what only exists
|
|
# after it. Everything the stack runs with is an Actions variable or
|
|
# secret (README.md), written onto the host by the deploy workflow; this
|
|
# makes the two things that are not values: Kanidm's config and its
|
|
# internal certificate. Idempotent: rerunning skips what exists.
|
|
#
|
|
# sudo ID_HOST=id.tomtervel.no sh bootstrap.sh # before the first deploy
|
|
# (Actions -> deploy -> Run workflow)
|
|
# sudo sh bootstrap.sh # after: Kanidm admin recovery
|
|
#
|
|
# Run rootful (as root) so Kanidm sees a stable source IP.
|
|
set -eu
|
|
cd "$(dirname "$0")"
|
|
[ -f .env ] && . ./.env
|
|
: "${ID_HOST:?ID_HOST=id.<the vel's domain> sh bootstrap.sh, or run the deploy workflow first}"
|
|
|
|
# Kanidm's domain is fixed here, once: renaming it later is Kanidm's own
|
|
# `domain rename`, not a variable changed.
|
|
[ -f kanidm/server.toml ] || {
|
|
sed "s|\${ID_HOST}|$ID_HOST|g" kanidm/server.toml.tpl > kanidm/server.toml
|
|
echo "kanidm/server.toml made for $ID_HOST"
|
|
}
|
|
|
|
# Kanidm's internal certificate: Caddy holds the public one.
|
|
mkdir -p certs
|
|
if [ ! -f certs/kanidm-key.pem ]; then
|
|
openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \
|
|
-subj "/CN=kanidm" -addext "subjectAltName=DNS:kanidm,DNS:$ID_HOST" \
|
|
-keyout certs/kanidm-key.pem -out certs/kanidm-chain.pem >/dev/null 2>&1
|
|
chmod 600 certs/kanidm-key.pem
|
|
echo "internal Kanidm certificate made"
|
|
fi
|
|
|
|
# The Kanidm admin accounts exist only after the first start; their
|
|
# passwords are set by recovery. Once; the output is the password, shown
|
|
# once.
|
|
if ! podman compose ps --format '{{.Names}}' 2>/dev/null | grep -q kanidm; then
|
|
echo "Kanidm is not running yet: run the deploy workflow, then this again."
|
|
exit 0
|
|
fi
|
|
if [ ! -f .kanidm-recovered ]; then
|
|
echo
|
|
echo "=== Kanidm admin recovery (write these passwords down) ==="
|
|
podman compose exec kanidm kanidmd recover-account admin
|
|
podman compose exec kanidm kanidmd recover-account idm_admin
|
|
touch .kanidm-recovered
|
|
fi
|
|
|
|
echo
|
|
echo "Next: sh kanidm-setup.sh (log in as idm_admin, create the portal client and desk groups)"
|