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