fa84285
#!/bin/sh
fa84285
# dhcp6c-script for Debian/Ubuntu. Jérémie Corbier, April, 2006.
fa84285
# resolvconf support by Mattias Guns, May 2006.
fa84285
fa84285
RESOLVCONF="/sbin/resolvconf"
fa84285
fa84285
[ -f /etc/default/wide-dhcpv6-client ] && . /etc/default/wide-dhcpv6-client
fa84285
fa84285
if [ -n "$new_domain_name" -o -n "$new_domain_name_servers" ]; then
fa84285
    old_resolv_conf=/etc/resolv.conf
fa84285
    new_resolv_conf=/etc/resolv.conf.dhcp6c-new
fa84285
    rm -f $new_resolv_conf
fa84285
    if [ -n "$new_domain_name" ]; then
fa84285
        echo search $new_domain_name >> $new_resolv_conf
fa84285
    fi
fa84285
    if [ -n "$new_domain_name_servers" ]; then
fa84285
        for nameserver in $new_domain_name_servers; do
fa84285
            # No need to add an already existing nameserver
fa84285
            res=$(grep "nameserver $nameserver" $old_resolv_conf)
fa84285
            if [ -z "$res" ]; then
fa84285
                echo nameserver $nameserver >> $new_resolv_conf
fa84285
            fi
fa84285
        done
fa84285
    fi
fa84285
fa84285
    # Use resolvconf if available
fa84285
    if [ -h "$old_resolv_conf" -a -x "$RESOLVCONF" ]; then
fa84285
        for IFACE in $INTERFACES; do
fa84285
            cat $new_resolv_conf | $RESOLVCONF -a $IFACE
fa84285
        done
fa84285
    else
fa84285
        # To preserve IPv4 informations...
fa84285
        cat $old_resolv_conf >> $new_resolv_conf
fa84285
        chown --reference=$old_resolv_conf $new_resolv_conf
fa84285
        chmod --reference=$old_resolv_conf $new_resolv_conf
fa84285
        mv -f $new_resolv_conf $old_resolv_conf
fa84285
    fi
fa84285
fi
fa84285
fa84285
exit 0