S07bonding 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. source /opt/wz_mini/etc/rc.common
  3. source /opt/wz_mini/wz_mini.conf
  4. bonding_setup() {
  5. #we need to wait until wlan0 is up with the modified HWaddr
  6. wait_for_wlan_wpa
  7. ##Fool iCamera by renaming the hardline interface to wlan0
  8. ## $1 Bonding Interface, $2 Primary Interface, $3 Secondary Interface
  9. echo "renaming interfaces"
  10. #Prevent iCamera from cycling the wlan0 interface
  11. mount --bind /opt/wz_mini/usr/bin/restart_wlan0.sh /system/bin/restart_wlan0.sh
  12. # Bring all interfaces down
  13. ifconfig bond0 down
  14. ifconfig $BONDING_PRIMARY_INTERFACE down
  15. ifconfig $BONDING_SECONDARY_INTERFACE down
  16. # Have to bring bonding interface up to be able to bond our slaves.
  17. /opt/wz_mini/bin/busybox ip link set bond0 up
  18. # Rename the real wlan0 interface if needed/used
  19. if [[ "$BONDING_PRIMARY_INTERFACE" == "wlan0" ]]; then
  20. /opt/wz_mini/bin/busybox ip link set $BONDING_PRIMARY_INTERFACE name wlanold
  21. /opt/wz_mini/bin/busybox ip addr flush dev wlanold
  22. BONDING_PRIMARY_INTERFACE="wlanold"
  23. # Because we just changed the name of the primary interface, we need to
  24. # tell the bonding driver about the name change as well.
  25. echo "$BONDING_PRIMARY_INTERFACE" > /sys/devices/virtual/net/bond0/bonding/primary
  26. fi
  27. if [[ "$BONDING_SECONDARY_INTERFACE" == "wlan0" ]]; then
  28. /opt/wz_mini/bin/busybox ip link set $BONDING_SECONDARY_INTERFACE name wlanold
  29. /opt/wz_mini/bin/busybox ip addr flush dev wlanold
  30. BONDING_SECONDARY_INTERFACE="wlanold"
  31. fi
  32. # Enslave the Ethernet and Original Wifi interfaces
  33. # under the bonding interface.
  34. /opt/wz_mini/tmp/.bin/ifenslave bond0 $BONDING_PRIMARY_INTERFACE $BONDING_SECONDARY_INTERFACE
  35. # Have to bring bonding interface down to be rename the interface
  36. /opt/wz_mini/bin/busybox ip link set bond0 down
  37. # Name the bonding interface to be the "new" wlan0 interface
  38. /opt/wz_mini/bin/busybox ip link set bond0 name wlan0
  39. # Bring the newly renamed wlan0 (actually the bond interface) back up in the next step
  40. #Run the DHCP client, and bind mount our fake wpa_cli.sh to fool iCamera
  41. ifconfig wlan0 up
  42. pkill udhcpc
  43. udhcpc -i wlan0 -x hostname:$CUSTOM_HOSTNAME -p /var/run/udhcpc.pid -b
  44. # If running with Interface Bonding enabled, kill any existing
  45. # wpa_supplicant that might be running and spawn our own instead
  46. if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
  47. /opt/wz_mini/bin/busybox killall wpa_supplicant
  48. wpa_supplicant -D nl80211 -i wlanold -c /tmp/wpa_supplicant.conf -B -s
  49. fi
  50. if [ -f /opt/wz_mini/tmp/.T20 ]; then
  51. mount -o bind /opt/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli
  52. else
  53. mount -o bind /opt/wz_mini/bin/wpa_cli.sh /bin/wpa_cli
  54. fi
  55. }
  56. if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
  57. bonding_setup &
  58. fi