2016-10-22 17:43:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Source Qubes library.
|
|
|
|
. /usr/lib/qubes/init/functions
|
2012-07-13 14:40:52 +02:00
|
|
|
|
|
|
|
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
|
2015-03-18 00:30:57 +01:00
|
|
|
MODULES_BLACKLIST="$MODULES_BLACKLIST `grep -v '^#' /etc/qubes-suspend-module-blacklist`"
|
2013-10-23 04:34:47 +02:00
|
|
|
fi
|
|
|
|
if [ -r /rw/config/suspend-module-blacklist ]; then
|
2015-03-18 00:30:57 +01:00
|
|
|
MODULES_BLACKLIST="$MODULES_BLACKLIST `grep -v '^#' /rw/config/suspend-module-blacklist`"
|
2013-10-23 04:34:47 +02:00
|
|
|
fi
|
|
|
|
|
2015-02-05 03:14:41 +01:00
|
|
|
if [ x"$action" = x"suspend" ]; then
|
2016-10-22 17:43:16 +02:00
|
|
|
if qsvc network-manager ; then
|
2016-01-11 19:40:32 +01:00
|
|
|
dbus-send --system --print-reply \
|
|
|
|
--dest=org.freedesktop.NetworkManager \
|
|
|
|
/org/freedesktop/NetworkManager \
|
|
|
|
org.freedesktop.NetworkManager.Sleep boolean:true || \
|
|
|
|
service NetworkManager stop
|
|
|
|
fi
|
2012-07-13 14:40:52 +02:00
|
|
|
# Force interfaces down, just in case when NM didn't done it
|
2015-10-15 04:34:55 +02:00
|
|
|
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
|
2016-10-22 17:43:16 +02:00
|
|
|
if qsvc network-manager ; then
|
2016-01-11 19:40:32 +01:00
|
|
|
dbus-send --system --print-reply \
|
|
|
|
--dest=org.freedesktop.NetworkManager \
|
|
|
|
/org/freedesktop/NetworkManager \
|
|
|
|
org.freedesktop.NetworkManager.Sleep boolean:false || \
|
2016-10-22 17:43:16 +02:00
|
|
|
{ under_systemd && systemctl start NetworkManager.service; } || service qubes-core-netvm start
|
2016-01-11 19:40:32 +01:00
|
|
|
fi
|
2012-07-13 14:40:52 +02:00
|
|
|
fi
|