raspiApWlanScripts
raspiApWlanScripts copied to clipboard
Does this work with Raspbian Buster Lite?
I tested and got an error. I would not recommend this script unless you know what you are doing.
I've tested these scripts on raspbian buster lite and they do work in switching between wifi and hotspot and back. I'm just stuck on the issue of having to access the pi via hostname.local while in hotspot mode and I want to access it via just the hostname. Apart from that I haven't encountered a problem.
Doesn't work.
To be more specific: Station mode does NOT work on RPI 3b+, Raspbian buster lite after initial setup and reboot. Unfortunately ETH0 is also not operable after that so you need to re-flash.
Can't currently say, what's going wrong. AP mode works.
One thing I noticed: This line causes an error on repeated runs of the setup script (most likely because the interface file cannot be found anymore after rename).
Here is the setup log. After that the device did neither enter the existing "accuware" network, nor did respond on eth0.
pi@raspberrypi:~/raspiApWlanScripts $ sudo ./setup_wlan_and_AP_modes.sh -s accuware -p 12345678 -a test -r 12345678
[I] setup_wlan_and_AP_modes.sh: /tmp/setup_wlan_and_AP_modes.0.raspberrypi.lock: Locking succeeded
[I] setup_wlan_and_AP_modes.sh: Start 20/03/30@13:58:03 with pid 3691 by root@raspberrypi:/home/pi/raspiApWlanScripts (NOLOG)
[I] -==#####################################==-
[I] -==# Masking existing network services #==-
[I] -==#####################################==-
[C] [03724] systemctl mask networking.service
[O] [03724] 1 [STDERR] Created symlink /etc/systemd/system/networking.service → /dev/null.
[I] [03724] Command succeeded [OK] (rc=0): systemctl mask networking.service
[C] [03724] systemctl mask dhcpcd.service
[O] [03724] 1 [STDERR] Created symlink /etc/systemd/system/dhcpcd.service → /dev/null.
[I] [03724] Command succeeded [OK] (rc=0): systemctl mask dhcpcd.service
[C] [03724] mv /etc/network/interfaces /etc/network/interfaces~
[I] [03724] Command succeeded [OK] (rc=0): mv /etc/network/interfaces /etc/network/interfaces~
[C] [03724] sed -i '1i resolvconf=NO' /etc/resolvconf.conf
[I] [03724] Command succeeded [OK] (rc=0): sed -i '1i resolvconf=NO' /etc/resolvconf.conf
[I] -==##################################################==-
[I] -==# Enabling systemd-networkd and systemd-resolved #==-
[I] -==##################################################==-
[C] [03724] systemctl enable systemd-networkd.service
[O] [03724] 1 [STDERR] Created symlink /etc/systemd/system/dbus-org.freedesktop.network1.service → /lib/systemd/system/systemd-networkd.service.
[O] [03724] 2 [STDERR] Created symlink /etc/systemd/system/multi-user.target.wants/systemd-networkd.service → /lib/systemd/system/systemd-networkd.service.
[O] [03724] 3 [STDERR] Created symlink /etc/systemd/system/sockets.target.wants/systemd-networkd.socket → /lib/systemd/system/systemd-networkd.socket.
[O] [03724] 4 [STDERR] Created symlink /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service → /lib/systemd/system/systemd-networkd-wait-online.service.
[I] [03724] Command succeeded [OK] (rc=0): systemctl enable systemd-networkd.service
[C] [03724] systemctl enable systemd-resolved.service
[O] [03724] 1 [STDERR] Created symlink /etc/systemd/system/dbus-org.freedesktop.resolve1.service → /lib/systemd/system/systemd-resolved.service.
[O] [03724] 2 [STDERR] Created symlink /etc/systemd/system/multi-user.target.wants/systemd-resolved.service → /lib/systemd/system/systemd-resolved.service.
[I] [03724] Command succeeded [OK] (rc=0): systemctl enable systemd-resolved.service
[C] [03724] ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
[I] [03724] Command succeeded [OK] (rc=0): ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
[I] -==######################################==-
[I] -==# Creating wlan0 wpa_supplicant file #==-
[I] -==######################################==-
[C] [03724] chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
[I] [03724] Command succeeded [OK] (rc=0): chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
[C] [03724] systemctl disable wpa_supplicant.service
[O] [03724] 1 [STDERR] Removed /etc/systemd/system/multi-user.target.wants/wpa_supplicant.service.
[O] [03724] 2 [STDERR] Removed /etc/systemd/system/dbus-fi.w1.wpa_supplicant1.service.
[I] [03724] Command succeeded [OK] (rc=0): systemctl disable wpa_supplicant.service
[C] [03724] systemctl enable [email protected]
[O] [03724] 1 [STDERR] Created symlink /etc/systemd/system/multi-user.target.wants/[email protected] → /lib/systemd/system/[email protected].
[I] [03724] Command succeeded [OK] (rc=0): systemctl enable [email protected]
[I] -==####################################==-
[I] -==# Creating ap0 wpa_supplicant file #==-
[I] -==####################################==-
[C] [03724] chmod 600 /etc/wpa_supplicant/wpa_supplicant-ap0.conf
[I] [03724] Command succeeded [OK] (rc=0): chmod 600 /etc/wpa_supplicant/wpa_supplicant-ap0.conf
[I] -==#####################################################==-
[I] -==# Creating both wlan0 and ap0 systemd network files #==-
[I] -==#####################################################==-
[I] -==############################################==-
[I] -==# Now for some slick systemd unit editing! #==-
[I] -==############################################==-
[C] [03724] systemctl disable [email protected]
[I] [03724] Command succeeded [OK] (rc=0): systemctl disable [email protected]
[C] [03724] cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]
[I] [03724] Command succeeded [OK] (rc=0): cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]
[C] [03724] sed -i 's/Requires=sys-subsystem-net-devices-0.device/Requires=sys-subsystem-net-devices-wlan0.device/' /etc/systemd/system/[email protected]
[I] [03724] Command succeeded [OK] (rc=0): sed -i 's/Requires=sys-subsystem-net-devices-0.device/Requires=sys-subsystem-net-devices-wlan0.device/' /etc/systemd/system/[email protected]
[C] [03724] sed -i 's/After=sys-subsystem-net-devices-0.device/After=sys-subsystem-net-devices-wlan0.device/' /etc/systemd/system/[email protected]
[I] [03724] Command succeeded [OK] (rc=0): sed -i 's/After=sys-subsystem-net-devices-0.device/After=sys-subsystem-net-devices-wlan0.device/' /etc/systemd/system/[email protected]
[C] [03724] sed -i '/After=sys-subsystem-net-devices-wlan0.device/a [email protected]' /etc/systemd/system/[email protected]
[I] [03724] Command succeeded [OK] (rc=0): sed -i '/After=sys-subsystem-net-devices-wlan0.device/a [email protected]' /etc/systemd/system/[email protected]
[C] [03724] sed -i '/Type=simple/a ExecStartPre=/sbin/iw dev wlan0 interface add ap0 type __ap' /etc/systemd/system/[email protected]
[I] [03724] Command succeeded [OK] (rc=0): sed -i '/Type=simple/a ExecStartPre=/sbin/iw dev wlan0 interface add ap0 type __ap' /etc/systemd/system/[email protected]
[C] [03724] sed -i '/ExecStart=/a ExecStopPost=/sbin/iw dev ap0 del' /etc/systemd/system/[email protected]
[I] [03724] Command succeeded [OK] (rc=0): sed -i '/ExecStart=/a ExecStopPost=/sbin/iw dev ap0 del' /etc/systemd/system/[email protected]
[C] [03724] systemctl daemon-reload
[I] [03724] Command succeeded [OK] (rc=0): systemctl daemon-reload
[I] -==##########################################==-
[I] -==# Finally, setup the default wifi option #==-
[I] -==##########################################==-
[C] [03724] systemctl enable [email protected]
[I] [03724] Command succeeded [OK] (rc=0): systemctl enable [email protected]
[C] [03724] systemctl disable [email protected]
[I] [03724] Command succeeded [OK] (rc=0): systemctl disable [email protected]
[I] -==#################################==-
[I] -==# YOU SHOULD NOW REBOOT YOUR PI #==-
[I] -==#################################==-
Run 'sudo reboot now'
[I] setup_wlan_and_AP_modes.sh: Finished at 13H58 (Time=8s, Error=0, Warning=0, RC=0).
pi@raspberrypi:~/raspiApWlanScripts $ sudo reboot
Connection to 192.168.188.89 closed by remote host.
Connection to 192.168.188.89 closed.
~ $