|
rdobuilder |
f9eca4 |
#!/bin/bash
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
# Copyright (c) 2011 Alexey I. Froloff.
|
|
rdobuilder |
f9eca4 |
#
|
|
rdobuilder |
f9eca4 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
rdobuilder |
f9eca4 |
# you may not use this file except in compliance with the License.
|
|
rdobuilder |
f9eca4 |
# You may obtain a copy of the License at:
|
|
rdobuilder |
f9eca4 |
#
|
|
rdobuilder |
f9eca4 |
# http://www.apache.org/licenses/LICENSE-2.0
|
|
rdobuilder |
f9eca4 |
#
|
|
rdobuilder |
f9eca4 |
# Unless required by applicable law or agreed to in writing, software
|
|
rdobuilder |
f9eca4 |
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
rdobuilder |
f9eca4 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
rdobuilder |
f9eca4 |
# See the License for the specific language governing permissions and
|
|
rdobuilder |
f9eca4 |
# limitations under the License.
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
. /etc/init.d/functions
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
cd /etc/sysconfig/network-scripts
|
|
rdobuilder |
f9eca4 |
. ./network-functions
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
[ -f ../network ] && . ../network
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
CONFIG=${1}
|
|
rdobuilder |
f9eca4 |
TIMEOUT=10
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
source_config
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
. /etc/sysconfig/network
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${REAL_DEVICETYPE}"
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
if [ ! -x ${OTHERSCRIPT} ]; then
|
|
rdobuilder |
f9eca4 |
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
|
|
rdobuilder |
f9eca4 |
fi
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
SERVICE_UNIT=/usr/lib/systemd/system/ovsdb-server.service
|
|
rdobuilder |
f9eca4 |
if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
|
|
rdobuilder |
f9eca4 |
if ! systemctl --quiet is-active ovsdb-server.service; then
|
|
rdobuilder |
f9eca4 |
systemctl start ovsdb-server.service
|
|
rdobuilder |
f9eca4 |
fi
|
|
rdobuilder |
f9eca4 |
else
|
|
rdobuilder |
f9eca4 |
if [ ! -f /var/lock/subsys/openvswitch ]; then
|
|
rdobuilder |
f9eca4 |
/sbin/service openvswitch start
|
|
rdobuilder |
f9eca4 |
fi
|
|
rdobuilder |
f9eca4 |
fi
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
case "$TYPE" in
|
|
rdobuilder |
f9eca4 |
OVSBridge|OVSUserBridge)
|
|
rdobuilder |
f9eca4 |
${OTHERSCRIPT} ${CONFIG} $2
|
|
rdobuilder |
f9eca4 |
retval=$?
|
|
rdobuilder |
f9eca4 |
ovs-vsctl -t ${TIMEOUT} -- --if-exists del-br "$DEVICE"
|
|
rdobuilder |
f9eca4 |
;;
|
|
rdobuilder |
f9eca4 |
OVSPort|OVSIntPort|OVSBond)
|
|
rdobuilder |
f9eca4 |
${OTHERSCRIPT} ${CONFIG} $2
|
|
rdobuilder |
f9eca4 |
retval=$?
|
|
rdobuilder |
f9eca4 |
ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
|
|
rdobuilder |
f9eca4 |
;;
|
|
rdobuilder |
f9eca4 |
OVSPatchPort|OVSTunnel)
|
|
rdobuilder |
f9eca4 |
ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
|
|
rdobuilder |
f9eca4 |
;;
|
|
rdobuilder |
f9eca4 |
OVSDPDKPort|OVSDPDKVhostUserPort|OVSDPDKBond)
|
|
rdobuilder |
f9eca4 |
ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
|
|
rdobuilder |
f9eca4 |
;;
|
|
rdobuilder |
f9eca4 |
*)
|
|
rdobuilder |
f9eca4 |
echo $"Invalid OVS interface type $TYPE"
|
|
rdobuilder |
f9eca4 |
exit 1
|
|
rdobuilder |
f9eca4 |
;;
|
|
rdobuilder |
f9eca4 |
esac
|
|
rdobuilder |
f9eca4 |
|
|
rdobuilder |
f9eca4 |
exit $retval
|