Blame SOURCES/56dhclient

fad460
#!/bin/sh
fad460
# If we are running dhclient, shutdown running instances cleanly and
fad460
# bring them back up on resume.
fad460
fad460
. "${PM_FUNCTIONS}"
fad460
fad460
PM_DHCLIENT_RUNDIR="${PM_UTILS_RUNDIR}/network"
fad460
PM_DHCLIENT_SUSPEND="${PM_DHCLIENT_RUNDIR}/dhclient.suspend"
fad460
fad460
suspend_dhclient() {
fad460
    [ ! -d /etc/sysconfig/network-scripts ] && return
fad460
    [ ! -x /sbin/ifdown ] && return
fad460
fad460
    [ ! -d ${PM_DHCLIENT_RUNDIR} ] && /bin/mkdir -p ${PM_DHCLIENT_RUNDIR}
fad460
    [ -f ${PM_DHCLIENT_SUSPEND} ] && /bin/rm -f ${PM_DHCLIENT_SUSPEND}
fad460
fad460
    cd /etc/sysconfig/network-scripts
fad460
    for ifcfg in ifcfg-* ; do
fad460
        # Clear relevant parameters set by previous interface
fad460
        # (lo doesn't set them)
fad460
        NM_CONTROLLED=
fad460
        BOOTPROTO=
fad460
fad460
        . ./"${ifcfg}"
fad460
fad460
        if [ "${NM_CONTROLLED}" = "no" ] || [ "${NM_CONTROLLED}" = "n" ] || [ "${NM_CONTROLLED}" = "false" ]; then
fad460
            if [ "${BOOTPROTO}" = "bootp" ] || [ "${BOOTPROTO}" = "dhcp" ] || [ -z "${BOOTPROTO}" ]; then
fad460
                # device is not NetworkManager controlled and uses dhcp,
fad460
                # now see if it's actually up at the moment
fad460
                /sbin/ip link show ${DEVICE} | /bin/grep -qE "state (UP|UNKNOWN)" >/dev/null 2>&1
fad460
                if [ $? -eq 0 ]; then
fad460
                    echo "${DEVICE}" >> ${PM_DHCLIENT_SUSPEND}
fad460
                    /sbin/ifdown ${DEVICE}
fad460
                fi
fad460
            fi
fad460
        fi
fad460
    done
fad460
}
fad460
fad460
resume_dhclient() {
fad460
    [ ! -f ${PM_DHCLIENT_SUSPEND} ] && return
fad460
    [ ! -x /sbin/ifup ] && return
fad460
fad460
    cd /etc/sysconfig/network-scripts
fad460
    while read device ; do
fad460
        /sbin/ifup ${device}
fad460
    done < ${PM_DHCLIENT_SUSPEND}
fad460
fad460
    /bin/rm -f ${PM_DHCLIENT_SUSPEND}
fad460
}
fad460
fad460
case "$1" in
fad460
    hibernate|suspend)
fad460
        suspend_dhclient
fad460
        ;;
fad460
    thaw|resume)
fad460
        resume_dhclient
fad460
        ;;
fad460
    *) exit $NA
fad460
        ;;
fad460
esac