mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-28 10:02:43 +01:00
939ae1a9e6
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
58 lines
1.4 KiB
Bash
58 lines
1.4 KiB
Bash
#!/bin/sh
|
|
# Start/stop/restart openvswitch.
|
|
|
|
# To start Open vSwitch automatically at boot, be sure this script is
|
|
# executable:
|
|
#
|
|
# % chmod 755 /etc/rc.d/rc.openvswitch
|
|
|
|
DBCONF=/var/lib/openvswitch/ovs-vswitchd.conf.db
|
|
SOCKET=/var/run/openvswitch/db.sock
|
|
VSPID=/var/run/openvswitch/ovs-vswitchd.pid
|
|
DBPID=/var/run/openvswitch/ovsdb-server.pid
|
|
|
|
# Insert kernel driver for Open vSwitch:
|
|
/sbin/modprobe openvswitch
|
|
|
|
# Insert kernel driver for VLANs:
|
|
/sbin/modprobe 8021q
|
|
|
|
# Start openvswitch:
|
|
openvswitch_start() {
|
|
echo "Starting openvswitch: /etc/rc.d/rc.openvswitch"
|
|
if [ ! -f $DBCONF ]; then
|
|
ovsdb-tool create $DBCONF @DOCDIR@/schema/vswitch.ovsschema
|
|
fi
|
|
/usr/sbin/ovsdb-server $DBCONF --remote=punix:$SOCKET --detach --pidfile=$DBPID --verbose=ANY:ANY:err
|
|
/usr/bin/ovs-vsctl --no-wait --verbose=ANY:ANY:err init
|
|
/usr/sbin/ovs-vswitchd unix:$SOCKET --detach --pidfile=$VSPID --verbose=ANY:ANY:err
|
|
}
|
|
|
|
# Stop openvswitch:
|
|
openvswitch_stop() {
|
|
echo "Stopping openvswitch: /etc/rc.d/rc.openvswitch"
|
|
if [ -e $VSPID ]; then
|
|
pid=$(cat $VSPID)
|
|
/usr/bin/ovs-appctl -t /var/run/openvswitch/ovs-vswitchd.$pid.ctl exit
|
|
fi
|
|
if [ -e $DBPID ]; then
|
|
pid=$(cat $DBPID)
|
|
/usr/bin/ovs-appctl -t /var/run/openvswitch/ovsdb-server.$pid.ctl exit
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
'start')
|
|
openvswitch_start
|
|
;;
|
|
'stop')
|
|
openvswitch_stop
|
|
;;
|
|
'restart')
|
|
openvswitch_stop
|
|
sleep 1
|
|
openvswitch_start
|
|
;;
|
|
*)
|
|
echo "usage $0 start|stop|restart"
|
|
esac
|