]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow ntp.conf location to be tunable, #119
authorRoy Marples <roy@marples.name>
Mon, 27 Oct 2008 12:41:04 +0000 (12:41 +0000)
committerRoy Marples <roy@marples.name>
Mon, 27 Oct 2008 12:41:04 +0000 (12:41 +0000)
dhcpcd-hooks/50-ntp.conf

index 536f14e97890cc648b4b0dd28bd3c12b6763b104..d4062589d161985ae326875ea27bd6beb624f3d7 100644 (file)
@@ -2,6 +2,12 @@
 # Like our resolv.conf hook script, we store a database of ntp.conf files
 # and merge into /etc/ntp.conf
 
+# You can set the env var NTP_CONF to another file like this
+#   dhcpcd -e NTP_CONF=/usr/pkg/etc/ntpd.conf
+# or by adding this to /etc/dhcpcd.enter-hook
+#   NTP_CONF=/usr/pkg/etc/ntpd.conf
+# to use openntpd from pkgsrc instead of the system provided ntp.
+
 # Detect OpenRC or BSD rc
 # Distributions may want to just have their command here instead of this
 if type rc-service >/dev/null 2>&1 && rc-service --exists ntpd; then
@@ -13,10 +19,11 @@ elif [ -x /usr/local/etc/rc.d/ntpd ]; then
 fi
 
 ntp_conf_dir="${state_dir}/ntp.conf"
+ntp_conf=${NTP_CONF:-/etc/ntp.conf}
 
 build_ntp_conf()
 {
-       local cf="/etc/ntp.conf.${interface}"
+       local cf="${ntp_conf}.${interface}"
        local interfaces= header= srvs= servers= x=
 
        # Build a list of interfaces
@@ -49,7 +56,7 @@ build_ntp_conf()
        fi
 
        # If we changed anything, restart ntpd
-       if change_file /etc/ntp.conf "${cf}"; then
+       if change_file "${ntp_conf}" "${cf}"; then
                [ -n "${ntpd_restart_cmd}" ] && ${ntpd_restart_cmd}
        fi
 }