File: openvswitch-vtep.sh

package info (click to toggle)
openvswitch 3.6.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 99,632 kB
  • sloc: sh: 1,683,183; ansic: 313,349; python: 28,192; xml: 21,442; makefile: 548; javascript: 191
file content (80 lines) | stat: -rwxr-xr-x 1,969 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh

# Short-Description: Open vSwitch VTEP emulator
# Description:       Initializes the Open vSwitch VTEP emulator

export OVS_LOGDIR=/var/log/openvswitch-vtep
export OVS_RUNDIR=/run/openvswitch-vtep
export OVS_PKGDATADIR=/usr/share/openvswitch
export OVS_DBDIR=/etc/openvswitch-vtep
etcdir=/etc/openvswitch-vtep

. /usr/share/openvswitch/scripts/ovs-lib

start () {
    ovs-dpctl dump-dps 2>&1 | grep ovs-system > /dev/null
    rc=$?
    if [ $rc -eq 0 ]; then
        cat << EOF >&2
An already running copy of ovs-vswitchd detected in current namespace.

Running multiple instances of ovs-vswitchd in the same namespace is not
supported.
EOF
        exit 1
    fi

    if [ ! -e "$etcdir/conf.db" ]; then
        ovsdb-tool create $etcdir/conf.db $OVS_PKGDATADIR/vswitch.ovsschema
    fi

    if [ ! -e "$etcdir/vtep.db" ]; then
        ovsdb-tool create $etcdir/vtep.db $OVS_PKGDATADIR/vtep.ovsschema
    fi

    if [ ! -e "$etcdir/ovsclient-cert.pem" ]; then
        export RANDFILE="/root/.rnd"
        cd $etcdir && ovs-pki req ovsclient && ovs-pki self-sign ovsclient
    fi

    if [ ! -d $OVS_RUNDIR ]; then
        install -d -m 755 -o root -g root $OVS_RUNDIR
    fi

    ovsdb-server --pidfile --detach --log-file --remote \
        punix:$OVS_RUNDIR/db.sock \
        --remote=db:hardware_vtep,Global,managers \
        --private-key=$etcdir/ovsclient-privkey.pem \
        --certificate=$etcdir/ovsclient-cert.pem \
        --bootstrap-ca-cert=$etcdir/vswitchd.cacert \
        $etcdir/conf.db $etcdir/vtep.db

    modprobe openvswitch

    ovs-vswitchd --pidfile --detach --log-file \
        unix:$OVS_RUNDIR/db.sock
}

stop () {
    stop_daemon ovs-vswitchd
    stop_daemon ovsdb-server
}

case $1 in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart|force-reload)
        stop
        start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0