Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / debian / openvswitch-vtep.init
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides:          openvswitch-vtep
5 # Required-Start:    $network $named $remote_fs $syslog
6 # Required-Stop:     $remote_fs
7 # Default-Start:     2 3 4 5
8 # Default-Stop:      0 1 6
9 # Short-Description: Open vSwitch VTEP emulator
10 # Description:       Initializes the Open vSwitch VTEP emulator
11 ### END INIT INFO
12
13
14 # Include defaults if available
15 default=/etc/default/openvswitch-vtep
16 if [ -f $default ] ; then
17     . $default
18 fi
19
20 start () {
21     if [ "$ENABLE_OVS_VTEP" = "false" ]; then
22         exit 0
23     fi
24
25     update-rc.d -f openvswitch-switch remove >/dev/null 2>&1
26     /etc/init.d/openvswitch-switch stop
27
28     mkdir -p "/var/run/openvswitch"
29
30     if [ ! -e "/etc/openvswitch/conf.db" ]; then
31         ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
32     fi
33
34     if [ ! -e "/etc/openvswitch/vtep.db" ]; then
35         ovsdb-tool create /etc/openvswitch/vtep.db /usr/share/openvswitch/vtep.ovsschema
36     fi
37
38     if [ ! -e "/etc/openvswitch/ovsclient-cert.pem" ]; then
39         export RANDFILE="/root/.rnd"
40         cd /etc/openvswitch && ovs-pki req ovsclient && ovs-pki self-sign ovsclient
41     fi
42
43     ovsdb-server --pidfile --detach --log-file --remote \
44         punix:/var/run/openvswitch/db.sock \
45         --remote=db:hardware_vtep,Global,managers \
46         --private-key=/etc/openvswitch/ovsclient-privkey.pem \
47         --certificate=/etc/openvswitch/ovsclient-cert.pem \
48         --bootstrap-ca-cert=/etc/openvswitch/vswitchd.cacert \
49         /etc/openvswitch/conf.db /etc/openvswitch/vtep.db
50
51     modprobe openvswitch
52
53     ovs-vswitchd --pidfile --detach --log-file \
54         unix:/var/run/openvswitch/db.sock
55 }
56
57 stop () {
58     /etc/init.d/openvswitch-switch stop
59 }
60
61 case $1 in
62     start)
63         start
64         ;;
65     stop)
66         stop
67         ;;
68     restart|force-reload)
69         stop
70         start
71         ;;
72     *)
73         echo "Usage: $0 {start|stop|restart|force-reload}" >&2
74         exit 1
75         ;;
76 esac
77
78 exit 0