dyn-dns: fix to only react when the IP actually changes
This commit is contained in:
@@ -45,8 +45,14 @@ in
|
|||||||
restartTriggers = [(builtins.toJSON cfg)];
|
restartTriggers = [(builtins.toJSON cfg)];
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
script = ''
|
script = ''
|
||||||
mkdir -p $(dirname "${cfg.ipPath}")
|
mkdir -p $(dirname '${cfg.ipPath}')
|
||||||
${cfg.ipCmd} > "${cfg.ipPath}"
|
newIp=$(${cfg.ipCmd})
|
||||||
|
# systemd path units are triggered on any file write action,
|
||||||
|
# regardless of content change. so only update the file if our IP *actually* changed
|
||||||
|
if [ "$newIp" != "$(cat '${cfg.ipPath}')" ]
|
||||||
|
then
|
||||||
|
echo "$newIp" > '${cfg.ipPath}'
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user