2
0

03_network-switchX-migration 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2013 OpenWrt.org
  4. #
  5. SWITCH_NAME_CHANGED=
  6. do_change_switch_name() {
  7. local config="$1"
  8. local option=$2
  9. local oldname=$3
  10. local newname=$4
  11. local val
  12. config_get val "$config" $option
  13. [ "$val" != "$oldname" ] && return 0
  14. uci_set network "$config" $option $newname
  15. SWITCH_NAME_CHANGED=1
  16. return 0
  17. }
  18. migrate_switch_name() {
  19. local oldname=$1
  20. local newname=$2
  21. . /lib/functions.sh
  22. config_load network
  23. logger -t migrate-switchX "Updating switch names in network configuration"
  24. config_foreach do_change_switch_name switch name $oldname $newname
  25. config_foreach do_change_switch_name switch_vlan device $oldname $newname
  26. [ "$SWITCH_NAME_CHANGED" = "1" ] && {
  27. logger -t migrate-switchX "Switch names updated, saving network configuration"
  28. uci commit network
  29. }
  30. }
  31. . /lib/ar71xx.sh
  32. board=$(ar71xx_board_name)
  33. case "$board" in
  34. dir-825-c1|\
  35. wzr-hp-g300nh2|\
  36. tl-wdr4300|\
  37. tl-wr1041n-v2|\
  38. wrt160nl|\
  39. ap121|\
  40. ap121-mini|\
  41. ap96|\
  42. airrouter|\
  43. dir-600-a1|\
  44. dir-615-c1|\
  45. dir-615-e1|\
  46. dir-615-e4|\
  47. ja76pf|\
  48. rb-750|\
  49. rb-751|\
  50. tew-632brp|\
  51. tew-712br|\
  52. tl-mr3220|\
  53. tl-mr3220-v2 |\
  54. tl-mr3420|\
  55. tl-wr741nd|\
  56. tl-wr741nd-v4|\
  57. tl-wr841n-v7|\
  58. whr-g301n|\
  59. whr-hp-g300n|\
  60. whr-hp-gn|\
  61. wzr-hp-ag300h|\
  62. wzr-hp-g450h|\
  63. z1|\
  64. ew-dorin|\
  65. ew-dorin-router)
  66. migrate_switch_name "eth0" "switch0"
  67. ;;
  68. el-m150|\
  69. rb-450)
  70. migrate_switch_name "eth1" "switch0"
  71. ;;
  72. db120 |\
  73. rb-2011l | \
  74. rb-2011uas-2hnd)
  75. migrate_switch_name "eth0" "switch0"
  76. migrate_switch_name "eth1" "switch1"
  77. ;;
  78. dir-825-b1|\
  79. tew-673gru|\
  80. nbg460n_550n_550nh)
  81. migrate_switch_name "rtl8366s" "switch0"
  82. ;;
  83. tl-wr1043nd)
  84. migrate_switch_name "rtl8366rb" "switch0"
  85. ;;
  86. esac
  87. exit 0