Blame SOURCES/11-dhclient

fad460
#!/bin/bash
fad460
# run dhclient.d scripts in an emulated environment
fad460
fad460
PATH=/bin:/usr/bin:/sbin
fad460
SAVEDIR=/var/lib/dhclient
fad460
ETCDIR=/etc/dhcp
fad460
interface=$1
fad460
fad460
eval "$(
fad460
declare | LC_ALL=C grep '^DHCP4_[A-Z_]*=' | while read -r opt; do
fad460
    optname=${opt%%=*}
fad460
    optname=${optname,,}
fad460
    optname=new_${optname#dhcp4_}
fad460
    optvalue=${opt#*=}
fad460
    echo "export $optname=$optvalue"
fad460
done
fad460
)"
fad460
fad460
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
fad460
fad460
[ -f /etc/sysconfig/network-scripts/ifcfg-$interface ] && \
fad460
    . /etc/sysconfig/network-scripts/ifcfg-$interface
fad460
fad460
if [ -d $ETCDIR/dhclient.d ]; then
fad460
    for f in $ETCDIR/dhclient.d/*.sh; do
fad460
        if [ -x $f ]; then
fad460
            subsystem="${f%.sh}"
fad460
            subsystem="${subsystem##*/}"
fad460
            . ${f}
fad460
            if [ "$2" = "up" ]; then
fad460
                "${subsystem}_config"
fad460
            elif [ "$2" = "dhcp4-change" ]; then
fad460
                if [ "$subsystem" = "chrony" -o "$subsystem" = "ntp" ]; then
fad460
                    "${subsystem}_config"
fad460
                fi
fad460
            elif [ "$2" = "down" ]; then
fad460
                "${subsystem}_restore"
fad460
            fi
fad460
        fi
fad460
    done
fad460
fi