Restart Wi-Fi Hotspot automatically on Ubuntu 17.04

Solution 1:

you can do it with Network Manager. Check the name of the connection which represents the hotspot that you want to start when its active or just guest

nmcli con show

then to make it start automatically

nmcli con mod <connection-name> connection.autoconnect yes

test it with reboot

Solution 2:

You could open a terminal and type

nmcli device wifi hotspot ssid YOURSSID

If it brings up your Hotspot you could create a file using

gnome-session-properties

to let your Hotspot start on system startup. But I am not sure if this will also do the trick if your machine comes up from suspend.

Maybe then you would need to create two files with

sudo touch /etc/pm/sleep.d/your-script 
sudo touch /lib/systemd/system-sleep/your-script

Edit them both with

sudo -H gedit /lib/systemd/system-sleep/your-script 
sudo -H gedit /etc/pm/sleep.d/your-script

and paste

#!/bin/sh
case "$1" in
  post|thaw)
    echo "waking up..."
    nmcli device wifi hotspot ssid YOURSSID 
 ;;
 esac

into them. Then you would need to make them both executable with

sudo chmod a+x /etc/pm/sleep.d/your-script
sudo chmod a+x /lib/systemd/system-sleep/your-script

and try your luck again...

The script works on my machine, but as I am connected only wireless and I am using the same name of the SSID for the test of the Hotspot and after a while, even after sleep, the adapter connects to the standard wifi operations and the Hotspot is getting disabled and wifi is getting enabled.