Replace getdate by ntpd
[hvlinux.git] / stage3 / pkg / ntp
diff --git a/stage3/pkg/ntp b/stage3/pkg/ntp
new file mode 100644 (file)
index 0000000..f7b9384
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+hvconfig_pre()
+{
+    groupadd --system -f ntp
+    hv_useradd --system -c Network_Time_Protocol -g ntp -s /bin/false \
+               -d /var/lib/ntp ntp
+
+    CONFIGURE_OPTS+=" \
+        --bindir=/usr/sbin \
+        --enable-linuxcaps \
+        --with-lineeditlibs=readline"
+}
+
+hvbuild_post()
+{
+    install -v -o ntp -g ntp -d /var/lib/ntp
+
+cat > /etc/ntp.conf << "EOF"
+# Local router
+server 192.168.1.1
+
+# North America
+#server 0.north-america.pool.ntp.org
+
+driftfile /var/lib/ntp/ntp.drift
+pidfile   /var/run/ntpd.pid
+
+leapfile  /etc/ntp.leapseconds
+
+# Security session
+restrict    default nomodify notrap nopeer noquery
+restrict -6 default nomodify notrap nopeer noquery
+
+restrict 127.0.0.1
+restrict ::1
+
+# Denying access to NTP's monlist functionality, used for querying traffic
+# stats but also exploited in a denial-of-service attack.
+disable monitor
+
+EOF
+
+    # Adding fcrontab entries to run ntpd and leap seconds update script
+    # periodically:
+    install -v -m644 ${SCRDIR}/misc/ntpd* /etc/fcron/fcron.d
+}