suspend: customizable modules blacklist

This commit is contained in:
Marek Marczykowski-Górecki 2013-10-23 04:34:47 +02:00
parent 047a7a0b23
commit 8f2c8d5382

View File

@ -3,17 +3,31 @@
action=$1 action=$1
[ -z "$action" ] && action=suspend [ -z "$action" ] && action=suspend
MODULES_BLACKLIST="uhci_hcd ehci_pci ehci_hcd iwldvm"
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
if [ x"$action" == x"suspend" ]; then if [ x"$action" == x"suspend" ]; then
nmcli nm sleep true || service NetworkManager stop nmcli nm sleep true || service NetworkManager stop
# Force interfaces down, just in case when NM didn't done it # Force interfaces down, just in case when NM didn't done it
for if in `ls /sys/class/net|grep -v "lo\|vif"`; do for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
ip l s $if down ip l s $if down
done done
modprobe -r uhci_hcd ehci_pci ehci_hcd LOADED_MODULES=""
lsmod|grep -q iwldvm && touch /var/run/qubes/suspend-iwldvm-loaded for mod in $MODULES_BLACKLIST; do
modprobe -r iwldvm 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
else else
modprobe ehci_pci; modprobe uhci_hcd for mod in `cat /var/run/qubes/suspend-modules-loaded`; do
test -e /var/run/qubes/suspend-iwldvm-loaded && modprobe iwldvm modprobe $mod
done
nmcli nm sleep false || { [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start nmcli nm sleep false || { [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start
fi fi