~changbl/inception/master

« back to all changes in this revision

Viewing changes to bin/install_openvswitch.sh

  • Committer: Changbin Liu
  • Date: 2014-07-25 14:23:06 UTC
  • Revision ID: git-v1:8233e63e95641ffb708053065fdde16416442d35
Add procedures/scripts as starting point of multi-DC deployment

Change-Id: If455358e9164aa51b99ed3a06dd49ab2cf03d69b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
## Install Open vSwitch (2.0.0). This file is translated from
 
4
## cookbook/openvswitch/recipes/default
 
5
 
 
6
# dependencies
 
7
sudo apt-get -y install build-essential \
 
8
    git \
 
9
    autoconf \
 
10
    python-dev \
 
11
    python-simplejson \
 
12
    python-qt4 \
 
13
    python-twisted-conch \
 
14
    uml-utilities \
 
15
    libtool \
 
16
    libssl-dev \
 
17
    pkg-config
 
18
 
 
19
sudo mkdir -p /opt/openvswitch
 
20
sudo chmod 00755 /opt/openvswitch
 
21
sudo chown root:root /opt/openvswitch
 
22
 
 
23
sudo mkdir -p /etc/openvswitch
 
24
sudo chmod 00755 /etc/openvswitch
 
25
sudo chown root:root /etc/openvswitch
 
26
 
 
27
sudo chmod a+w /opt/openvswitch
 
28
cd /opt/openvswitch
 
29
wget http://openvswitch.org/releases/openvswitch-2.0.0.tar.gz
 
30
tar xzvf openvswitch-2.0.0.tar.gz
 
31
mv openvswitch-2.0.0 openvswitch
 
32
cd openvswitch
 
33
./configure --with-linux=/lib/modules/`uname -r`/build \
 
34
    --prefix=/usr --localstatedir=/var # default to these libraries
 
35
make -j
 
36
sudo make install
 
37
sudo make modules_install
 
38
sudo ovsdb-tool create /etc/openvswitch/conf.db \
 
39
    vswitchd/vswitch.ovsschema
 
40
sudo /usr/bin/ovs-vsctl --no-wait init
 
41
 
 
42
echo "start on (filesystem and net-device-up)
 
43
stop on runlevel [016]
 
44
 
 
45
# Automatically restart process if crashed
 
46
respawn
 
47
 
 
48
# Essentially lets upstart know the process will detach itself to the background
 
49
expect fork
 
50
 
 
51
pre-start script
 
52
  /sbin/modprobe openvswitch
 
53
  /sbin/modprobe gre
 
54
  mkdir -p /var/run/openvswitch/
 
55
end script
 
56
 
 
57
script
 
58
  exec /usr/sbin/ovsdb-server /etc/openvswitch/conf.db \\
 
59
        --remote=punix:/var/run/openvswitch/db.sock \\
 
60
        --remote=db:Open_vSwitch,Open_vSwitch,manager_options \\
 
61
        --private-key=db:Open_vSwitch,SSL,private_key \\
 
62
        --certificate=db:Open_vSwitch,SSL,certificate \\
 
63
        --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \\
 
64
        --pidfile --detach
 
65
end script
 
66
 
 
67
# seems main script only allows one daemon, so we move another
 
68
# daemon(s) to post-start and pre-stop
 
69
post-start script
 
70
  exec /usr/sbin/ovs-vswitchd --pidfile --detach
 
71
end script
 
72
 
 
73
pre-stop script
 
74
  exec killall -9 ovs-vswitchd
 
75
end script
 
76
 
 
77
post-stop script
 
78
  /sbin/rmmod openvswitch
 
79
end script
 
80
" | sudo tee /etc/init/openvswitch.conf
 
81
sudo chmod 00755 /etc/init/openvswitch.conf
 
82
sudo chown root:root /etc/init/openvswitch.conf
 
83
 
 
84
sudo service openvswitch start