]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Support head and tail files for resolv.conf
authorRoy Marples <roy@marples.name>
Wed, 13 Aug 2008 15:39:34 +0000 (15:39 +0000)
committerRoy Marples <roy@marples.name>
Wed, 13 Aug 2008 15:39:34 +0000 (15:39 +0000)
dhcpcd-hooks/20-resolv.conf

index 437c116778c4f2a861e2b6a3a7f7d08306758cc3..b86d5837a31cff2c67ce90d1871007f6d647acd8 100644 (file)
@@ -8,7 +8,7 @@ make_resolv_conf()
                -z "${new_domain_search}" ]; then
                return 0
        fi
-       local x= conf="${signature}\n"
+       local x= conf="${signature}\n" cf="/etc/resolv.conf.${interface}"
        if [ -n "${new_domain_search}" ]; then
                conf="${conf}search ${new_domain_search}\n"
        elif [ -n "${new_domain_name}" ]; then
@@ -20,8 +20,16 @@ make_resolv_conf()
        if type resolvconf >/dev/null 2>&1; then
                printf "${conf}" | resolvconf -a "${interface}"
        else
+               rm -f "${cf}"
+               if [ -f /etc/resolv.conf.head ]; then
+                       cat /etc/resolv.conf.head > "${cf}"
+               fi
+               printf "${conf}" >> "${cf}"
+               if [ -f /etc/resolv.conf.tail ]; then
+                       cat /etc/resolv.conf.tail >> "${cf}"
+               fi
                save_conf /etc/resolv.conf
-               printf "${conf}" > /etc/resolv.conf
+               mv -f "${cf}" /etc/resolv.conf
        fi
 }