You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.2 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2013 Julius Schulz-Zander <julius@net.t-labs.tu-berlin.de>
  3. # Copyright (C) 2014-2017 OpenWrt.org
  4. # Copyright (C) 2018 Yousong Zhou <yszhou4tech@gmail.com>
  5. START=15
  6. ovs_ctl="/usr/share/openvswitch/scripts/ovs-ctl"; [ -x "$ovs_ctl" ] || ovs_ctl=:
  7. ovn_ctl="/usr/share/ovn/scripts/ovn-ctl"; [ -x "$ovn_ctl" ] || ovn_ctl=:
  8. EXTRA_COMMANDS=status
  9. start() {
  10. ovs_action start "$@"
  11. }
  12. stop() {
  13. ovs_action stop "$@"
  14. }
  15. restart() {
  16. ovs_action restart "$@"
  17. }
  18. status() {
  19. ovs_action status "$@"
  20. }
  21. ovs_action_cfgs=
  22. ovs_action() {
  23. local action="$1"; shift
  24. local cfgtype
  25. ovs_action_cfgs="$*"
  26. config_load openvswitch
  27. for cfgtype in ovs ovn_northd ovn_controller; do
  28. config_foreach "ovs_xx" "$cfgtype" "$action" "$cfgtype"
  29. done
  30. }
  31. ovs_xx() {
  32. local cfg="$1"
  33. local action="$2"
  34. local cfgtype="$3"
  35. local disabled
  36. if [ -n "$ovs_action_cfgs" ] && ! list_contains "ovs_action_cfgs" "$cfg"; then
  37. return
  38. fi
  39. case "$action" in
  40. status|stop) ;;
  41. *)
  42. config_get_bool disabled "$cfg" disabled 0
  43. [ "$disabled" -le 0 ] || return
  44. ;;
  45. esac
  46. case "$cfgtype" in
  47. ovs)
  48. "$ovs_ctl" "$action" \
  49. --system-id=random
  50. ;;
  51. ovn_*)
  52. "$ovn_ctl" "${action}_${cfgtype#ovn_}"
  53. ;;
  54. esac
  55. }