03_network-switchX-migration 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. pb92|\
  37. ap113|\
  38. tl-wdr4300|\
  39. tl-wr1041n-v2|\
  40. wrt160nl|\
  41. ap121|\
  42. ap121-mini|\
  43. ap96|\
  44. airrouter|\
  45. dir-600-a1|\
  46. dir-615-c1|\
  47. dir-615-e1|\
  48. dir-615-e4|\
  49. ja76pf|\
  50. mr-12|\
  51. mr-16|\
  52. rb-750|\
  53. rb-751|\
  54. tew-632brp|\
  55. tew-712br|\
  56. tl-mr3220|\
  57. tl-mr3220-v2 |\
  58. tl-mr3420|\
  59. tl-wr741nd|\
  60. tl-wr741nd-v4|\
  61. tl-wr841n-v7|\
  62. whr-g301n|\
  63. whr-hp-g300n|\
  64. whr-hp-gn|\
  65. wzr-hp-ag300h|\
  66. wzr-hp-g450h|\
  67. ew-dorin|\
  68. ew-dorin-router)
  69. migrate_switch_name "eth0" "switch0"
  70. ;;
  71. el-m150|\
  72. rb-450)
  73. migrate_switch_name "eth1" "switch0"
  74. ;;
  75. db120 |\
  76. rb-2011l | \
  77. rb-2011uas-2hnd)
  78. migrate_switch_name "eth0" "switch0"
  79. migrate_switch_name "eth1" "switch1"
  80. ;;
  81. dir-825-b1|\
  82. tew-673gru|\
  83. nbg460n_550n_550nh)
  84. migrate_switch_name "rtl8366s" "switch0"
  85. ;;
  86. tl-wr1043nd)
  87. migrate_switch_name "rtl8366rb" "switch0"
  88. ;;
  89. esac
  90. exit 0