packages/net/openvswitch/files/openvswitch.init
Yousong Zhou c2f788f054 openvswitch: rework packaging
New scheme mainly provides three packages: openvswitch,
openvswitch-ovn-north, openvswitch-ovn-controller.  These should fit
most usage scenarios.  Other subpackages like openvswitch-libXXX
etc.  are there for dependency management and are hidden from the
menu.

Many python and shell scripts are removed in this revision.  Most of
them cannot run out of box at all for lack of dependencies.  Others
being legacy ones are not that useful now.  Add them back at later time
when real need appears

Below are a simple listing of additions

 - initscript now incorporate also ovn north and controller support
 - ovn-ctl and ovs-ctl can be invoked directly from within $PATH

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2018-06-04 11:27:54 +08:00

68 lines
1.2 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
# Copyright (C) 2013 Julius Schulz-Zander <julius@net.t-labs.tu-berlin.de>
# Copyright (C) 2014-2017 OpenWrt.org
# Copyright (C) 2018 Yousong Zhou <yszhou4tech@gmail.com>
START=15
ovs_script_dir=/usr/share/openvswitch/scripts
ovs_ctl="$ovs_script_dir/ovs-ctl"
ovn_ctl="$ovs_script_dir/ovn-ctl"
EXTRA_COMMANDS=status
start() {
ovs_action start "$@"
}
stop() {
ovs_action stop "$@"
}
restart() {
ovs_action restart "$@"
}
status() {
ovs_action status "$@"
}
ovs_action_cfgs=
ovs_action() {
local action="$1"; shift
local cfgtype
ovs_action_cfgs="$*"
config_load openvswitch
for cfgtype in ovs ovn_northd ovn_controller; do
config_foreach "ovs_xx" "$cfgtype" "$action" "$cfgtype"
done
}
ovs_xx() {
local cfg="$1"
local action="$2"
local cfgtype="$3"
local disabled
if [ -n "$ovs_action_cfgs" ] && ! list_contains "ovs_action_cfgs" "$cfg"; then
return
fi
case "$action" in
status|stop) ;;
*)
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -le 0 ] || return
;;
esac
case "$cfgtype" in
ovs)
"$ovs_ctl" "$action" \
--system-id=random
;;
ovn_*)
"$ovn_ctl" "${action}_${cfgtype#ovn_}"
;;
esac
}