Excute commands after resuming from hibernation in Ubuntu
At home I use a USB wireless adapter to broadcast wifi for my mobile phone. The setup for this was not very complex (for those who’re interested, this link can be useful: http://www.webupd8.org/2013/06/how-to-set-up-wireless-hotspot-access.html). The problem is that every time the system recovers from hibernation (and suspend), the hotspot daemon doesn’t work properly. So here’s my solution:
# cd /etc/pm/sleep.d/
# touch wifi_broadcast.sh
# chmod +x wifi_broadcast.sh
# vim wifi_broadcast.sh
Then add the following lines:
#!/bin/bash
case "$1" in
hibernate|suspend)
ap-hotspot stop
;;
thaw|resume)
ap-hotspot start
;;
*)
;;
esac
exit $?
This will create a script named wifi_broadcast.sh in /etc/pm/sleep.d/ directory. The script will make sure before the system goes to hibernation or suspend, the ap-hotspot deamon is stopped and is started again when the system resumes.