3

I'm using a hotspot on Ubuntu 17.04 to share my Internet connection with other devices. But when I restart or suspend the computer, I need to activate the hotspot manually each time.

Is there some option, script, or command to launch the hotspot automatically after wakeup?

5
+50

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

1

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.

  • to get your wifi module up again after reboot, you could try to create a file here sudo gedit /etc/pm/config.d/config and paste SUSPEND_MODULES="your-wifi-driver" into it. Also you could create another script with sudo modprobe -r your-wifi-driver; sudo modprobe your-wifi-driver into it. You can find your driver with sudo lshw -C network. – starkus Jul 13 '17 at 10:18
  • Also it could be good to edit sudo -H gedit /etc/NetworkManager/NetworkManager.conf and add [device] <br> wifi.scan-rand-mac-address=0 at the end. – starkus Jul 13 '17 at 10:20
  • I'd also try this - askubuntu.com/a/761220/196781 – starkus Jul 13 '17 at 10:25
  • Sorry, the <br> above is a typo error. To connect automatically you will also need to turn of your login screen on resume. You can do so with gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true' or dconf-tools and editing sudo gedit /etc/default/acpi-support. You need to write a # in front of LOCK_SCREEN=true. Just like # LOCK_SCREEN=true. – starkus Jul 13 '17 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.