fix timezone refresh
This commit is contained in:
parent
20128c80ef
commit
de0a6add72
1 changed files with 41 additions and 0 deletions
|
|
@ -20,4 +20,45 @@
|
||||||
after = [ "dbus.socket" ];
|
after = [ "dbus.socket" ];
|
||||||
wants = [ "dbus.socket" ];
|
wants = [ "dbus.socket" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.fix-localtime-symlink = {
|
||||||
|
description = "Fix /etc/localtime symlink to be absolute";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "automatic-timezoned.service" ];
|
||||||
|
wants = [ "automatic-timezoned.service" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
ExecStart = pkgs.writeShellScript "fix-localtime-symlink" ''
|
||||||
|
target=$(${pkgs.coreutils}/bin/readlink /etc/localtime 2>/dev/null || true)
|
||||||
|
if [ -z "$target" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$target" == /* ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
abs_target="/etc/$target"
|
||||||
|
if [ -e "$abs_target" ]; then
|
||||||
|
${pkgs.coreutils}/bin/ln -sf "$abs_target" /etc/localtime
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
unitConfig = {
|
||||||
|
ConditionPathIsSymbolicLink = "/etc/localtime";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.paths.fix-localtime-symlink = {
|
||||||
|
description = "Watch /etc/localtime for changes";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
pathConfig = {
|
||||||
|
PathChanged = "/etc/localtime";
|
||||||
|
Unit = "fix-localtime-symlink.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue