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