Merge pull request #304340 from Stunkymonkey/postsrsd-chmod-install

nixos/postsrsd: prefer 'install' over 'chmod/chown'
This commit is contained in:
h7x4 2024-06-18 10:32:49 +02:00 committed by GitHub
commit f5263306d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -120,14 +120,9 @@ in {
if [ ! -e "${cfg.secretsFile}" ]; then
echo "WARNING: secrets file not found, autogenerating!"
DIR="$(dirname "${cfg.secretsFile}")"
if [ ! -d "$DIR" ]; then
mkdir -p -m750 "$DIR"
chown "${cfg.user}:${cfg.group}" "$DIR"
fi
dd if=/dev/random bs=18 count=1 | base64 > "${cfg.secretsFile}"
chmod 600 "${cfg.secretsFile}"
install -m 750 -o ${cfg.user} -g ${cfg.group} -d "$DIR"
install -m 600 -o ${cfg.user} -g ${cfg.group} <(dd if=/dev/random bs=18 count=1 | base64) "${cfg.secretsFile}"
fi
chown "${cfg.user}:${cfg.group}" "${cfg.secretsFile}"
'';
};