iac/modules/castopod/files/generate_secrets.sh.tftpl
Florian Maury 1b9eeb1288 blip
2025-01-10 16:10:39 +01:00

22 lines
1.3 KiB
Text

#!/bin/bash
set -o errexit -o nounset -o pipefail
umask 7177
openssl rand -hex 16 | tr -d '\n' > "${secrets_path}/mariadb-root-password.secret"
(echo -n 'MARIADB_ROOT_PASSWORD=' ; cat ${secrets_path}/mariadb-root-password.secret) > "${secrets_path}/mariadb-root-password.env"
openssl rand -hex 16 | tr -d '\n' > "${secrets_path}/castopod-mariadb.secret"
(echo -n 'MARIADB_PASSWORD=' ; cat "${secrets_path}/castopod-mariadb.secret") > "${secrets_path}/mariadb-password.env"
(echo -n 'CP_DATABASE_PASSWORD=' ; cat "${secrets_path}/castopod-mariadb.secret") > "${secrets_path}/castopod-mariadb-password.env"
(echo -n 'CP_ANALYTICS_SALT=' ; openssl rand -base64 16) > "${secrets_path}/castopod-analytics.env"
openssl rand -hex 16 | tr -d '\n' > "${secrets_path}/castopod-valkey.secret"
(echo -n 'CP_REDIS_PASSWORD=' ; cat "${secrets_path}/castopod-valkey.secret") > "${secrets_path}/castopod-valkey.env"
echo "#!/bin/sh" > '${secrets_path}/valkey-entrypoint.sh'
(echo '/usr/local/bin/docker-entrypoint.sh valkey-server --requirepass "' ; cat "${secrets_path}/castopod-valkey.secret" ; echo '"') >> '${secrets_path}/valkey-entrypoint.sh'
chown 999 '${secrets_path}/valkey-entrypoint.sh'
chmod 700 '${secrets_path}/valkey-entrypoint.sh'
chcon -t container_file_t '${secrets_path}/valkey-entrypoint.sh'