]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Improve config file handling some more on Debian systems.
authorRoy Marples <roy@marples.name>
Sat, 26 Jun 2010 09:09:59 +0000 (09:09 +0000)
committerRoy Marples <roy@marples.name>
Sat, 26 Jun 2010 09:09:59 +0000 (09:09 +0000)
dhcpcd-hooks/50-ntp.conf
dhcpcd-run-hooks.in

index 2ac713ef4bf8cdb72a17c0c0fd56693e5e727008..9ca262ef66fe171ec5bb2f9ed28d8c8fb23e8027 100644 (file)
@@ -18,6 +18,7 @@ elif type invoke-rc.d >/dev/null 2>&1; then
        fi
        # Debian as a seperate file for DHCP config to avoid stamping on
        # the master.
+       [ -e /var/lib/ntp ] || mkdir /var/lib/ntp
        : ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
 elif [ -x /etc/rc.d/ntpd ]; then
        ntpd_restart_cmd="/etc/rc.d/ntpd status >/dev/null 2>&1 && /etc/rc.d/ntpd restart"
@@ -68,6 +69,8 @@ build_ntp_conf()
                echo "$signature_base${header:+ $from }$header" >> "$cf"
                printf "$search$servers" >> "$cf"
                echo "$signature_base_end${header:+ $from }$header" >> "$cf"
+       else
+               [ -e "$ntp_conf" ] || return
        fi
 
        # If we changed anything, restart ntpd
index 5a50d0e8aa20df25b36dde790632a7f52a95d3da..fbda2f0ce362605383cdf7025294877f624af225 100644 (file)
@@ -91,17 +91,19 @@ remove_markers()
 # If different, replace first with second otherwise remove second
 change_file()
 {
-       if type cmp >/dev/null 2>&1; then
-               cmp -s "$1" "$2"
-       elif type diff >/dev/null 2>&1; then
-               diff -q "$1" "$2" >/dev/null
-       else
-               # Hopefully we're only working on small text files ...
-               [ "$(cat "$1")" = "$(cat "$2")" ]
-       fi
-       if [ $? -eq 0 ]; then
-               rm -f "$2"
-               return 1
+       if [ -e "$1" ]; then
+               if type cmp >/dev/null 2>&1; then
+                       cmp -s "$1" "$2"
+               elif type diff >/dev/null 2>&1; then
+                       diff -q "$1" "$2" >/dev/null
+               else
+                       # Hopefully we're only working on small text files ...
+                       [ "$(cat "$1")" = "$(cat "$2")" ]
+               fi
+               if [ $? -eq 0 ]; then
+                       rm -f "$2"
+                       return 1
+               fi
        fi
        cat "$2" > "$1"
        rm -f "$2"