From 9d78ea2ea60803f82e224caf8e4cb4a6a1ac0860 Mon Sep 17 00:00:00 2001 From: Scott Kilau Date: Tue, 14 Jun 2022 22:52:17 -0500 Subject: [PATCH] Add wpa_supplicant daemon that works properly for the wlanold interface. With this addition, the bonding now works correctly. Ethernet is used when available/connected, and will fallback to Wifi when not. As soon as Ethernet does become available again, the bonding will switch to it as priority. --- SD_ROOT/wz_mini/etc/init.d/wz_user.sh | 46 +++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/SD_ROOT/wz_mini/etc/init.d/wz_user.sh b/SD_ROOT/wz_mini/etc/init.d/wz_user.sh index f695b97..3d364bd 100755 --- a/SD_ROOT/wz_mini/etc/init.d/wz_user.sh +++ b/SD_ROOT/wz_mini/etc/init.d/wz_user.sh @@ -64,43 +64,49 @@ rename_interface() { ##Fool iCamera by renaming the hardline interface to wlan0 echo "renaming interfaces" - # Bring all interfaces down + # Bring all interfaces down ifconfig $1 down ifconfig wlan0 down - ifconfig bond0 down + ifconfig bond0 down - # Rename the real wlan0 interface - /opt/wz_mini/bin/busybox ip link set wlan0 name wlanold - /opt/wz_mini/bin/busybox ip addr flush dev wlanold + # Rename the real wlan0 interface + /opt/wz_mini/bin/busybox ip link set wlan0 name wlanold + /opt/wz_mini/bin/busybox ip addr flush dev wlanold - # Have to bring bond0 up to be able to bond our slaves. - /opt/wz_mini/bin/busybox ip link set bond0 up + # Have to bring bond0 up to be able to bond our slaves. + /opt/wz_mini/bin/busybox ip link set bond0 up - # Enslave the Ethernet and Original Wifi interfaces - # under the Bonding interface. - /opt/wz_mini/tmp/.bin/ifenslave bond0 eth0 wlanold + # Enslave the Ethernet and Original Wifi interfaces + # under the Bonding interface. + /opt/wz_mini/tmp/.bin/ifenslave bond0 eth0 wlanold - # Have to bring bond0 down to be rename the interface - /opt/wz_mini/bin/busybox ip link set bond0 down + # Have to bring bond0 down to be rename the interface + /opt/wz_mini/bin/busybox ip link set bond0 down - # Name the bond0 interface to be the "new" wlan0 interface - /opt/wz_mini/bin/busybox ip link set bond0 name wlan0 + # Name the bond0 interface to be the "new" wlan0 interface + /opt/wz_mini/bin/busybox ip link set bond0 name wlan0 - # Bring the newly renamed wlan0 back up + # Bring the newly renamed wlan0 back up eth_wlan_up } eth_wlan_up() { ##Run DHCP client, and bind mount our fake wpa_cli.sh to fool iCamera - ifconfig wlan0 up - + ifconfig wlan0 up pkill udhcpc - udhcpc -i wlan0 -x hostname:$HOSTNAME -p /var/run/udhcpc.pid -b + udhcpc -i wlan0 -x hostname:$HOSTNAME -p /var/run/udhcpc.pid -b + + # Kill any existing wpa_supplicant that might be running + # and spawn our own instead + /opt/wz_mini/bin/busybox killall wpa_supplicant + wpa_supplicant -D nl80211 -i wlanold -c /tmp/wpa_supplicant.conf -B -s + if [[ "$V2" == "true" ]]; then mount -o bind /opt/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli else mount -o bind /opt/wz_mini/bin/wpa_cli.sh /bin/wpa_cli fi + break } @@ -244,8 +250,8 @@ if [[ "$ENABLE_USB_ETH" == "true" ]]; then insmod $KMOD_PATH/kernel/drivers/net/usb/$i.ko done - # Insert the bonding driver when running Ethernet - insmod $KMOD_PATH/kernel/drivers/net/bonding.ko mode=active-backup miimon=100 downdelay=5000 updelay=5000 primary=eth0 + # Insert the bonding driver when running Ethernet + insmod $KMOD_PATH/kernel/drivers/net/bonding/bonding.ko mode=active-backup miimon=100 downdelay=5000 updelay=5000 primary=eth0 swap_enable