Blame SOURCES/56dhclient

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