2012-07-13 14:40:52 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
action=$1
|
|
|
|
[ -z "$action" ] && action=suspend
|
|
|
|
|
2013-10-24 04:13:27 +02:00
|
|
|
MODULES_BLACKLIST=""
|
2013-10-23 04:34:47 +02:00
|
|
|
if [ -r /etc/qubes-suspend-module-blacklist ]; then
|
|
|
|
MODULES_BLACKLIST="$MODULES_BLACKLIST `cat /etc/qubes-suspend-module-blacklist`"
|
|
|
|
fi
|
|
|
|
if [ -r /rw/config/suspend-module-blacklist ]; then
|
|
|
|
MODULES_BLACKLIST="$MODULES_BLACKLIST `cat /rw/config/suspend-module-blacklist`"
|
|
|
|
fi
|
|
|
|
|
2015-02-05 03:14:41 +01:00
|
|
|
if [ x"$action" = x"suspend" ]; then
|
2014-05-01 01:10:57 +02:00
|
|
|
dbus-send --system --print-reply \
|
2014-02-21 18:42:12 +01:00
|
|
|
--dest=org.freedesktop.NetworkManager \
|
|
|
|
/org/freedesktop/NetworkManager \
|
|
|
|
org.freedesktop.NetworkManager.Sleep boolean:true || \
|
|
|
|
service NetworkManager stop
|
2012-07-13 14:40:52 +02:00
|
|
|
# Force interfaces down, just in case when NM didn't done it
|
|
|
|
for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
|
2015-02-05 03:14:41 +01:00
|
|
|
if [ "`cat /sys/class/net/$if/device/devtype 2>/dev/null`" = "vif" ]; then
|
2014-10-27 15:07:06 +01:00
|
|
|
continue
|
|
|
|
fi
|
2012-07-13 14:40:52 +02:00
|
|
|
ip l s $if down
|
|
|
|
done
|
2013-10-23 04:34:47 +02:00
|
|
|
LOADED_MODULES=""
|
|
|
|
for mod in $MODULES_BLACKLIST; do
|
|
|
|
if lsmod |grep -q $mod; then
|
|
|
|
LOADED_MODULES="$LOADED_MODULES $mod"
|
|
|
|
modprobe -r $mod
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo $LOADED_MODULES > /var/run/qubes/suspend-modules-loaded
|
2012-07-13 14:40:52 +02:00
|
|
|
else
|
2013-10-23 04:34:47 +02:00
|
|
|
for mod in `cat /var/run/qubes/suspend-modules-loaded`; do
|
|
|
|
modprobe $mod
|
|
|
|
done
|
2014-05-01 01:10:57 +02:00
|
|
|
dbus-send --system --print-reply \
|
|
|
|
--dest=org.freedesktop.NetworkManager \
|
2014-02-21 18:42:12 +01:00
|
|
|
/org/freedesktop/NetworkManager \
|
|
|
|
org.freedesktop.NetworkManager.Sleep boolean:false || \
|
|
|
|
{ [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start
|
2012-07-13 14:40:52 +02:00
|
|
|
fi
|