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