prepare-suspend 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. action=$1
  3. [ -z "$action" ] && action=suspend
  4. MODULES_BLACKLIST=""
  5. if [ -r /etc/qubes-suspend-module-blacklist ]; then
  6. MODULES_BLACKLIST="$MODULES_BLACKLIST `cat /etc/qubes-suspend-module-blacklist`"
  7. fi
  8. if [ -r /rw/config/suspend-module-blacklist ]; then
  9. MODULES_BLACKLIST="$MODULES_BLACKLIST `cat /rw/config/suspend-module-blacklist`"
  10. fi
  11. if [ x"$action" == x"suspend" ]; then
  12. nmcli nm sleep true || service NetworkManager stop
  13. # Force interfaces down, just in case when NM didn't done it
  14. for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
  15. ip l s $if down
  16. done
  17. LOADED_MODULES=""
  18. for mod in $MODULES_BLACKLIST; do
  19. if lsmod |grep -q $mod; then
  20. LOADED_MODULES="$LOADED_MODULES $mod"
  21. modprobe -r $mod
  22. fi
  23. done
  24. echo $LOADED_MODULES > /var/run/qubes/suspend-modules-loaded
  25. else
  26. for mod in `cat /var/run/qubes/suspend-modules-loaded`; do
  27. modprobe $mod
  28. done
  29. nmcli nm sleep false || { [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start
  30. fi