Report comment

Hi Simmo,

The setup for Jessie was fine, unfortunately you have to do things differently for Stretch.

The RTNETLINK answers: File exists in this situation usually refers to the file at /var/run/wpa_supplicant/wlan0

When wifi network starts through wpa_supplicant a file is created with the device name. When Wifi is ended through the GUI by the clock or termination via wpa_cli then the device file in /var/run/wpa_supplicant is cleared.
The script double checks that it has been removed by specifically deleting it just in case, before it goes to a hotspot.

If wpa_supplicant exits unexpectedly or the interface is deactivated by another process or a second instance of wpa_supplicant is running then the device file is not cleared. The hotspot cannot bring wlan0 back up with, ip link set dev wlan0 up, if the device file still exists.
So no device file should exist in /var/run/wpa_supplicant before the hotspot is activated.

As for the cause, though probably unlikely, while your wifi is running check you only have one instance active with the command: pgrep wpa_supplicant
if you see more than one number then you have multiple instance and that is the issue.
Check that there is no reference to wpa_supplicant in the /etc/network/interfaces file, usually empty on stretch.

If you have one instance then, check that the path in the top 3 lines of you /etc/wpa_supplicant/wpa_supplicant.conf file shows: ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
if it doesn't then the file is not created as expected.

In general if the file does exist, rebooting resets everything and it will work again. As I presume this is not happening for you there is some other setup issue somewhere.

I have not been able to reproduce your issue. I presume your sequence of events is edited as some feedback is missing, so if this doesn't help can you send me the output of the manual switches, and I try to find the issue.