]> git.proxmox.com Git - ovs.git/blob - debian/openvswitch-vtep.init
[ Felix Moessbauer ]
[ovs.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 . /lib/lsb/init-functions
14
15 # Include defaults if available
16 default=/etc/default/openvswitch-vtep
17 if [ -f $default ] ; then
18 . $default
19 fi
20
21 start () {
22 if [ "$ENABLE_OVS_VTEP" = "false" ]; then
23 exit 0
24 fi
25
26 update-rc.d -f openvswitch-switch remove >/dev/null 2>&1
27 /etc/init.d/openvswitch-switch stop
28
29 mkdir -p "/var/run/openvswitch"
30
31 if [ ! -e "/etc/openvswitch/conf.db" ]; then
32 ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
33 fi
34
35 if [ ! -e "/etc/openvswitch/vtep.db" ]; then
36 ovsdb-tool create /etc/openvswitch/vtep.db /usr/share/openvswitch/vtep.ovsschema
37 fi
38
39 if [ ! -e "/etc/openvswitch/ovsclient-cert.pem" ]; then
40 export RANDFILE="/root/.rnd"
41 cd /etc/openvswitch && ovs-pki req ovsclient && ovs-pki self-sign ovsclient
42 fi
43
44 ovsdb-server --pidfile --detach --log-file --remote \
45 punix:/var/run/openvswitch/db.sock \
46 --remote=db:hardware_vtep,Global,managers \
47 --private-key=/etc/openvswitch/ovsclient-privkey.pem \
48 --certificate=/etc/openvswitch/ovsclient-cert.pem \
49 --bootstrap-ca-cert=/etc/openvswitch/vswitchd.cacert \
50 /etc/openvswitch/conf.db /etc/openvswitch/vtep.db
51
52 modprobe openvswitch
53
54 ovs-vswitchd --pidfile --detach --log-file \
55 unix:/var/run/openvswitch/db.sock
56 }
57
58 stop () {
59 /etc/init.d/openvswitch-switch stop
60 }
61
62 case $1 in
63 start)
64 start
65 ;;
66 stop)
67 stop
68 ;;
69 restart|force-reload)
70 stop
71 start
72 ;;
73 *)
74 echo "Usage: $0 {start|stop|restart|force-reload}" >&2
75 exit 1
76 ;;
77 esac
78
79 exit 0