 cb5c457fba
			
		
	
	
		cb5c457fba
		
			
		
	
	
	
	
		
			
			Sending dbus calls to a service which isn't running _and is blocked to not be started_ would result in timeout, which would delay the whole system suspend. Fixes QubesOS/qubes-issues#1419
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| action=$1
 | |
| [ -z "$action" ] && action=suspend
 | |
| 
 | |
| MODULES_BLACKLIST=""
 | |
| if [ -r /etc/qubes-suspend-module-blacklist ]; then
 | |
|     MODULES_BLACKLIST="$MODULES_BLACKLIST `grep -v '^#' /etc/qubes-suspend-module-blacklist`"
 | |
| fi
 | |
| if [ -r /rw/config/suspend-module-blacklist ]; then
 | |
|     MODULES_BLACKLIST="$MODULES_BLACKLIST `grep -v '^#' /rw/config/suspend-module-blacklist`"
 | |
| fi
 | |
| 
 | |
| if [ x"$action" = x"suspend" ]; then
 | |
|     if [ -f /var/run/qubes-service/network-manager ]; then
 | |
|         dbus-send --system --print-reply          \
 | |
|             --dest=org.freedesktop.NetworkManager \
 | |
|             /org/freedesktop/NetworkManager       \
 | |
|             org.freedesktop.NetworkManager.Sleep boolean:true ||  \
 | |
|             service NetworkManager stop
 | |
|     fi
 | |
|     # Force interfaces down, just in case when NM didn't done it
 | |
|     for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
 | |
|         if [ "`cat /sys/class/net/$if/device/devtype 2>/dev/null`" = "vif" ]; then
 | |
|             continue
 | |
|         fi
 | |
|         ip l s $if down
 | |
|     done
 | |
|     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
 | |
| else
 | |
|     for mod in `cat /var/run/qubes/suspend-modules-loaded`; do
 | |
|         modprobe $mod
 | |
|     done
 | |
|     if [ -f /var/run/qubes-service/network-manager ]; then
 | |
|         dbus-send --system --print-reply          \
 | |
|             --dest=org.freedesktop.NetworkManager \
 | |
|             /org/freedesktop/NetworkManager       \
 | |
|             org.freedesktop.NetworkManager.Sleep boolean:false ||  \
 | |
|             { [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start
 | |
|     fi
 | |
| fi
 |