Report comment

“I have just tried the following:
-I deleted my network from wpa_supplicant.conf
-reboot -> starts in hotspot mode
-I use my webinterface to add the network to wpa_supplicant.conf again
-the website automatically runs /usr/bin/autohotspot (so I do not reboot)
-shuts down the hotspot and turns on the wifi
-Pi has internet access, everything works normally

I think, in that case the lines I commented out do not matter because that branch of the if statement is not executed. It's weird - but it works.”