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