* Job for ntpd. Doesn't seem to work quite right, but that might be a

VMware problem.

svn path=/nixos/trunk/; revision=7460
This commit is contained in:
Eelco Dolstra 2006-12-21 23:43:17 +00:00
parent 647db4dd2a
commit 617ebcbcce
3 changed files with 75 additions and 0 deletions

View File

@ -239,6 +239,29 @@
}
{
name = ["services" "ntp" "enable"];
default = true;
description = "
Whether to synchronise your machine's time using the NTP
protocol.
";
}
{
name = ["services" "ntp" "servers"];
default = [
"0.pool.ntp.org"
"1.pool.ntp.org"
"2.pool.ntp.org"
];
description = "
The set of NTP servers from which to synchronise.
";
}
{
name = ["services" "xserver" "enable"];
default = false;

View File

@ -81,6 +81,13 @@ import ../upstart-jobs/gather.nix {
inherit (pkgs) openssh glibc pwdutils;
})
# NTP daemon.
++ optional ["services" "ntp" "enable"]
(import ../upstart-jobs/ntpd.nix {
inherit (pkgs) ntp glibc pwdutils writeText;
servers = config.get ["services" "ntp" "servers"];
})
# X server.
++ optional ["services" "xserver" "enable"]
(import ../upstart-jobs/xserver.nix {

45
upstart-jobs/ntpd.nix Normal file
View File

@ -0,0 +1,45 @@
{ntp, glibc, pwdutils, writeText, servers}:
let
stateDir = "/var/lib/ntp";
ntpUser = "ntp";
config = writeText "ntp.conf" "
driftfile ${stateDir}/ntp.drift
${toString (map (server: "server " + server + "\n") servers)}
";
in
{
name = "ntpd";
job = "
description \"NTP daemon\"
start on network-interfaces/started
stop on network-interfaces/stop
start script
if ! ${glibc}/bin/getent passwd ${ntpUser} > /dev/null; then
${pwdutils}/sbin/useradd -g nogroup -d ${stateDir} -s /noshell \\
-c 'NTP daemon user' ${ntpUser}
fi
mkdir -m 0755 -p ${stateDir}
chown ${ntpUser} ${stateDir}
date
${ntp}/bin/ntpd -ddd -c ${config} -q -g
date
end script
respawn ${ntp}/bin/ntpd -ddd -n -c ${config}
";
}