From: Roy Marples Date: Thu, 14 Aug 2008 12:37:44 +0000 (+0000) Subject: Don't error if no interfaces or the state dir does not exist. X-Git-Tag: v4.0.2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=205be441f3dff70fa9098f84110b85a760b429fd;p=thirdparty%2Fdhcpcd.git Don't error if no interfaces or the state dir does not exist. --- diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf index b94f2f10..2c68f7f9 100644 --- a/dhcpcd-hooks/20-resolv.conf +++ b/dhcpcd-hooks/20-resolv.conf @@ -17,21 +17,26 @@ build_resolv_conf() # Build a list of interfaces for x in "${resolvconf_dir}"/*; do + [ -e "${x}" ] || continue [ -n "${interfaces}" ] && header="${header}, " header="${header}${x##*/}" interfaces="${interfaces}${interfaces:+ }${x##*/}" done - # Build a search list - search=$(cd "${resolvconf_dir}"; sed -n 's/^search //p' ${interfaces}) - [ -n "${search}" ] && search="search $(uniqify ${search})\n" + if [ -n "${interfaces}" ]; then + # Build a search list + search=$(cd "${resolvconf_dir}"; + sed -n 's/^search //p' ${interfaces}) + [ -n "${search}" ] && search="search $(uniqify ${search})\n" - # Build a nameserver list - srvs=$(cd "${resolvconf_dir}"; sed -n 's/^nameserver //p' ${interfaces}) - if [ -n "${srvs}" ]; then - for x in $(uniqify ${srvs}); do - servers="${servers}nameserver ${x}\n" - done + # Build a nameserver list + srvs=$(cd "${resolvconf_dir}"; + sed -n 's/^nameserver //p' ${interfaces}) + if [ -n "${srvs}" ]; then + for x in $(uniqify ${srvs}); do + servers="${servers}nameserver ${x}\n" + done + fi fi # Build our final resolv.conf