Files

41 lines
1.4 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Make throwaway secrets for a CI or local end-to-end run of compose.ci.yaml.
# Every value is random and new on each run. Nothing here is ever committed:
# deploy/ci/ci-secrets/ and deploy/ci/ci-backups/ are gitignored and dockerignored.
# Also makes an empty CA bundle placeholder for the base stack's /etc/ssl/pesco mount
# (LDAP in CI uses the Samba DC's own CA from the ci-dc-export volume instead)
# and an empty backup folder for the worker's read-only mount.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
out="$here/ci-secrets"
backups="$here/ci-backups"
umask 077
mkdir -p "$out" "$backups"
rand() {
# 32 random bytes as hex. No newline, so the file holds exactly the value.
od -An -N32 -tx1 /dev/urandom | tr -d ' \n'
}
for name in \
postgres_superuser_password postgres_migrate_password postgres_app_password \
visualkit_password mfileskit_password ldap_bind_password \
session_key seal_key
do
rand > "$out/$name"
done
# Samba DC Administrator. Samba wants upper, lower, digits and a symbol.
printf 'Ci-%s-Adm!' "$(rand)" > "$out/samba_admin_password"
: > "$out/ca.pem"
# CI only: the containers run as uid 10001 and uid 999 (postgres), not as the runner's
# user, so the throwaway files are world-readable. Production files are root:10001 0440.
chmod 0755 "$out" "$backups"
chmod 0444 "$out"/*
echo "make-secrets: wrote $(ls "$out" | wc -l) files to $out"