Add a script for stalwart to wait pocketid to start so OIDC doesnt fail
This commit is contained in:
1 parent
c92b90e406
commit
32c756fde5
1 file changed
+16
@@ -8,6 +8,18 @@ let
|
||||
planPath = config.sops.templates."stalwart-oidc-plan.json".path;
|
||||
cliEnvPath = config.sops.templates."stalwart-cli.env".path;
|
||||
hostDataPath = "${common.dataDir}/stalwart";
|
||||
pocketIdReady = pkgs.writeShellScript "stalwart-wait-pocket-id" ''
|
||||
set -euo pipefail
|
||||
url="${"http://127.0.0.1:${toString rootCfg.pocket-id.server.hostHttpPort}/.well-known/openid-configuration"}"
|
||||
for i in $(seq 1 90); do
|
||||
if ${lib.getExe pkgs.curl} -fsS -o /dev/null --max-time 2 "$url"; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "Pocket ID did not serve $url" >&2
|
||||
exit 1
|
||||
'';
|
||||
in
|
||||
{
|
||||
imports = [ ./config.nix ];
|
||||
@@ -77,6 +89,8 @@ in
|
||||
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
preStart = ''
|
||||
${pocketIdReady}
|
||||
|
||||
mkdir -p ${hostDataPath}/{config,data}
|
||||
chown -R 2000:2000 ${hostDataPath} 2>/dev/null || chmod 775 ${hostDataPath}
|
||||
chmod 775 ${hostDataPath}/{config,data}
|
||||
@@ -139,6 +153,8 @@ in
|
||||
"$cli_image" \
|
||||
apply --stdin
|
||||
|
||||
${pocketIdReady}
|
||||
|
||||
${common.backend} restart ${cfg.name}
|
||||
|
||||
ok=0
|
||||
|
||||
Reference in new issue
Block a user