fix: allow server configs to writeable by service user

This allows secrets to be correctly written to the files
This commit is contained in:
Price Hiller 2023-12-19 02:31:41 -06:00
parent 53c6e91089
commit 4334ac281a
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -983,16 +983,16 @@ in
cp -f "${path}" ./"${name}.cfg"
'') "" cfgs}
# Correct the permissions for the Squad Server cfgs. When the Squad Server is first
# installed it will include the configs by default with an overly open CHMOD.
chmod 0600 *.cfg
${lib.optionalString (cfg.config.server.passwordFile != null) ''
## Handle secrets for the `Server.cfg` file ##
# Safely load the server password outside of the nix store
sed -i -e 's/^ServerPassword=.*$/ServerPassword='"$(${pkgs.systemd}/bin/systemd-creds cat SQUAD_SERVER_PASSWORD_FILE)"'/g' ./Server.cfg
''}
# Correct the permissions for the Squad Server cfgs. When the Squad Server is first
# installed it will include the configs by default with an overly open CHMOD.
chmod 0400 *.cfg
${lib.optionalString (cfg.config.rcon.passwordFile != null) ''
## Handle secrets for the `Rcon.cfg` file ##
# Safely load the rcon password outside of the nix store
@ -1005,6 +1005,10 @@ in
printf "%s" "$(${pkgs.systemd}/bin/systemd-creds cat SQUAD_LICENSE_FILE)" > ./License.cfg
''}
# Correct the permissions for the Squad Server cfgs. When the Squad Server is first
# installed it will include the configs by default with an overly open CHMOD.
chmod 0600 *.cfg
popd >/dev/null 2>&1
cat <<-__EOS__