From: Roy Marples Date: Sat, 26 Jun 2010 09:09:59 +0000 (+0000) Subject: Improve config file handling some more on Debian systems. X-Git-Tag: v5.2.6~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49f2854719ec6543cee7bf7584c3f08bd688251a;p=thirdparty%2Fdhcpcd.git Improve config file handling some more on Debian systems. --- diff --git a/dhcpcd-hooks/50-ntp.conf b/dhcpcd-hooks/50-ntp.conf index 2ac713ef..9ca262ef 100644 --- a/dhcpcd-hooks/50-ntp.conf +++ b/dhcpcd-hooks/50-ntp.conf @@ -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 diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index 5a50d0e8..fbda2f0c 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -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"