Blame SOURCES/11-dhclient

f9ed25
#!/bin/bash
f9ed25
# run dhclient.d scripts in an emulated environment
f9ed25
f9ed25
PATH=/bin:/usr/bin:/sbin
f9ed25
ETCDIR=/etc/dhcp
f9ed25
SAVEDIR=/var/lib/dhclient
f9ed25
interface=$1
f9ed25
f9ed25
for optname in "${!DHCP4_@}"; do
f9ed25
    newoptname=${optname,,};
f9ed25
    newoptname=new_${newoptname#dhcp4_};
f9ed25
    export "${newoptname}"="${!optname}";
f9ed25
done
f9ed25
f9ed25
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
f9ed25
f9ed25
[ -f /etc/sysconfig/network-scripts/ifcfg-"${interface}" ] && \
f9ed25
    . /etc/sysconfig/network-scripts/ifcfg-"${interface}"
f9ed25
f9ed25
if [ -d $ETCDIR/dhclient.d ]; then
f9ed25
    for f in $ETCDIR/dhclient.d/*.sh; do
f9ed25
        if [ -x "${f}" ]; then
f9ed25
            subsystem="${f%.sh}"
f9ed25
            subsystem="${subsystem##*/}"
f9ed25
            . "${f}"
f9ed25
            if [ "$2" = "up" ]; then
f9ed25
                "${subsystem}_config"
f9ed25
            elif [ "$2" = "dhcp4-change" ]; then
f9ed25
                if [ "$subsystem" = "chrony" -o "$subsystem" = "ntp" ]; then
f9ed25
                    "${subsystem}_config"
f9ed25
                fi
f9ed25
            elif [ "$2" = "down" ]; then
f9ed25
                "${subsystem}_restore"
f9ed25
            fi
f9ed25
        fi
f9ed25
    done
f9ed25
fi