Report comment

Thanks for helping along! We’re making great progress, though the problem is not resolved — we’re close, and at this point I’m pretty sure all we’re looking at is iw not executing properly from the script due to, maybe, a path issue. Root’s $PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. Other sudoer user’s $PATH is /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games.

1. Your script posted on your site at /images/autohotspot-switch.txt contains an error. Specifically, at the end of line 8 your portion of code containing sed ‘s/,$//’) contains apostrophes that, when copy/pasted, don’t translate properly into terminal. I recommend editing your script with plain-text apostrophes there. I have corrected that on my end in the Pi3.

2. The reason dnsmasq was failing to start, resulting in “junk found” is due to Debian big #860064 where, when dns-root-data is installed dnsmasq will fail to start. I recommend adding to your overall instructions (for Debian users) to execute apt-get purge dns-root-data following the apt-get update. I have purged dns-root-data on my end, and dnsmasq no longer fails to start. No errors result in status dnsmasq nor hostapd.

3. I altered my DHCP range stated in dnsmasq.conf to, per your recommendation so that the wlan0 ip stated in autohotspot is included in the DHCP range. No improvement in operation can be determined yet because the overall problem is not yet resolved.

4. Our temporary cron.log throws “/usr/bin/autohotspot: line 40: iw: command not found” in each scenario of (a) booting with home router available and (b) booting with no home router available. I attempted to overcome the problem by editing autohotspot for “/sbin/iw” but that did not solve the problem, so I reverted to your verbatim script. iw is installed and runs fine when commanded in terminal — just not via the script. No other errors are shown in cron.log. However, cron.log does indicate “Hotspot already active” regardless of whether the hotspot is actually active or not- I attribute this to the failure in executing iw to make the swap.

5. Because iw is not executing through the script, I had to uncomment wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf in network/interfaces in order to get the Pi3 to operate properly with the home router. I suspect that once we correct the iw execution via the autohotspot script I’ll be able to re-comment wpa-conf.

6. When cold-booting with home router available, the Pi3 connects to the home router, obtains an ip, and ssh is accessible. Same, fully working, in the opposite when cold-booting with no home router available, the Pi3 starts the hotspot, gives itself an ip within the range specified in dnsmasq.conf, and ssh is accessible.

8. While booted with active hotspot and the home router is restored the cron task successfully identifies the home router, connects to it, and shuts down the hotspot. ssh is accessible.

9. THE PROBLEM SUMMARY. When already booted with home router available (connected) and the home router is lost, the hotspot does not start regardless of length of time waited. At this time, cron.log only indicates “/usr/bin/autohotspot: line 40: iw: command not found” and “Hotspot already active” — nothing more. From this problem condition, when the home router is restored, the autohotspot script does indeed catch the home router and connect to it, restoring ssh access etc.