ifup 674 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. ifup_all=
  3. if_call() {
  4. local interface="$1"
  5. for mode in $modes; do
  6. ubus call network.interface $mode "{ \"interface\" : \"$interface\" }"
  7. done
  8. }
  9. case "$0" in
  10. *ifdown) modes=down;;
  11. *ifup)
  12. modes="down up"
  13. ;;
  14. *) echo "Invalid command: $0";;
  15. esac
  16. while :; do
  17. case "$1" in
  18. -a)
  19. ifup_all=1
  20. shift
  21. ;;
  22. *)
  23. break
  24. ;;
  25. esac
  26. done
  27. [ "$modes" = "down up" ] && ubus call network reload
  28. if [ -n "$ifup_all" ]; then
  29. for interface in $(ubus -S list 'network.interface.*'); do
  30. if_call "${interface##network.interface.}"
  31. done
  32. exit
  33. else
  34. ubus -S list "network.interface.$1" > /dev/null || {
  35. echo "Interface $1 not found"
  36. exit
  37. }
  38. if_call "$1"
  39. fi