Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Last active December 10, 2016 00:39
Show Gist options
  • Save jpouellet/aaeecdf34b2d066371a5acfead978467 to your computer and use it in GitHub Desktop.
Save jpouellet/aaeecdf34b2d066371a5acfead978467 to your computer and use it in GitHub Desktop.
Restarts your sys-net without requiring shutting everything else down first. Useful if your wifi drivers hang regularly... :(
#!/bin/sh
# TODO: detect sys-net(s) by pci attachment & sys-firewall(s) by netvm == $sys-net(s)
if [ -z "$NET_RESTART_LOCK" ]; then
if env NET_RESTART_LOCK=ok flock -o -n /var/run/qubes/net-restart.lock "$0" "$@"; then
exit 0
else
echo "$0: Failed to aquire lock" >&2
exit 1
fi
fi
[ X"$1" = X-v ] && v=true || v=false
step() {
step="$1"
shift
if $v; then
echo "$step"
"$@" 2>&1 | sed 's/^/\t/'
else
echo -n "$step... "
"$@" >/dev/null 2>&1
echo done
fi
}
#step "Removing netvm from sys-firewall" qvm-prefs -s sys-firewall netvm none
#step "Shutting down sys-net" qvm-shutdown --wait sys-net
#step "Starting sys-net" qvm-start sys-net
#step "Restoring netvm to sys-firewall" qvm-prefs -s sys-firewall netvm sys-net
step "Reloading modules" qvm-run -p sys-net 'sudo sh -c "rmmod iwlmvm; rmmod iwlwifi; modprobe iwlwifi; modprobe iwlmvm;"'
@jpouellet
Copy link
Author

So actually, if you just add the relevant drivers to /rw/config/suspend-module-blacklist in your sys-net, Qubes will {un,re}load them for you on suspend/resume, which is a much better (faster, and no manual button pressing on fail) solution than this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment