S07bonding 2.9 KB

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