fix: fix _agenix_generation being empty if readlink fails

This commit is contained in:
tea 2024-09-10 23:56:24 +02:00
parent f6291c5935
commit 2e80d9ddd1
2 changed files with 4 additions and 4 deletions

View file

@ -11,7 +11,7 @@ with lib; let
ageBin = lib.getExe config.age.package;
newGeneration = ''
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}")" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] creating new generation in ${cfg.secretsMountPoint}/$_agenix_generation"
mkdir -p "${cfg.secretsMountPoint}"
@ -73,7 +73,7 @@ with lib; let
cfg.identityPaths;
cleanupAndLink = ''
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}")" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] symlinking new secrets to ${cfg.secretsDir} (generation $_agenix_generation)..."
ln -sfT "${cfg.secretsMountPoint}/$_agenix_generation" "${cfg.secretsDir}"

View file

@ -29,7 +29,7 @@ with lib; let
mount -t ramfs none "${cfg.secretsMountPoint}" -o nodev,nosuid,mode=0751
'';
newGeneration = ''
_agenix_generation="$(basename "$(readlink ${cfg.secretsDir})" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] creating new generation in ${cfg.secretsMountPoint}/$_agenix_generation"
mkdir -p "${cfg.secretsMountPoint}"
@ -100,7 +100,7 @@ with lib; let
cfg.identityPaths;
cleanupAndLink = ''
_agenix_generation="$(basename "$(readlink ${cfg.secretsDir})" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] symlinking new secrets to ${cfg.secretsDir} (generation $_agenix_generation)..."
ln -sfT "${cfg.secretsMountPoint}/$_agenix_generation" ${cfg.secretsDir}