mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
nixos/adguardhome: fix shellcheck error in pre-start script
(cherry picked from commit d9d779c24d)
This commit is contained in:
parent
55dce2f15f
commit
5026b48150
1 changed files with 26 additions and 16 deletions
|
|
@ -176,22 +176,32 @@ in
|
|||
StartLimitBurst = 10;
|
||||
};
|
||||
|
||||
preStart = lib.optionalString (settings != null) ''
|
||||
if [ -e "$STATE_DIRECTORY/AdGuardHome.yaml" ] \
|
||||
&& [ "${toString cfg.mutableSettings}" = "1" ]; then
|
||||
# First run a schema_version update on the existing configuration
|
||||
# This ensures that both the new config and the existing one have the same schema_version
|
||||
# Note: --check-config has the side effect of modifying the file at rest!
|
||||
${lib.getExe cfg.package} -c "$STATE_DIRECTORY/AdGuardHome.yaml" --check-config
|
||||
preStart =
|
||||
let
|
||||
installFresh = ''
|
||||
cp --force "${configFile}" "$STATE_DIRECTORY/AdGuardHome.yaml"
|
||||
chmod 600 "$STATE_DIRECTORY/AdGuardHome.yaml"
|
||||
'';
|
||||
in
|
||||
lib.optionalString (settings != null) (
|
||||
if cfg.mutableSettings then
|
||||
''
|
||||
if [ -e "$STATE_DIRECTORY/AdGuardHome.yaml" ]; then
|
||||
# First run a schema_version update on the existing configuration
|
||||
# This ensures that both the new config and the existing one have the same schema_version
|
||||
# Note: --check-config has the side effect of modifying the file at rest!
|
||||
${lib.getExe cfg.package} -c "$STATE_DIRECTORY/AdGuardHome.yaml" --check-config
|
||||
|
||||
# Writing directly to AdGuardHome.yaml results in empty file
|
||||
${lib.getExe pkgs.yaml-merge} "$STATE_DIRECTORY/AdGuardHome.yaml" "${configFile}" > "$STATE_DIRECTORY/AdGuardHome.yaml.tmp"
|
||||
mv "$STATE_DIRECTORY/AdGuardHome.yaml.tmp" "$STATE_DIRECTORY/AdGuardHome.yaml"
|
||||
else
|
||||
cp --force "${configFile}" "$STATE_DIRECTORY/AdGuardHome.yaml"
|
||||
chmod 600 "$STATE_DIRECTORY/AdGuardHome.yaml"
|
||||
fi
|
||||
'';
|
||||
# Writing directly to AdGuardHome.yaml results in empty file
|
||||
${lib.getExe pkgs.yaml-merge} "$STATE_DIRECTORY/AdGuardHome.yaml" "${configFile}" > "$STATE_DIRECTORY/AdGuardHome.yaml.tmp"
|
||||
mv "$STATE_DIRECTORY/AdGuardHome.yaml.tmp" "$STATE_DIRECTORY/AdGuardHome.yaml"
|
||||
else
|
||||
${installFresh}
|
||||
fi
|
||||
''
|
||||
else
|
||||
installFresh
|
||||
);
|
||||
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue