From eefd613e6681f3879b26d12e7bf5e71c881803e2 Mon Sep 17 00:00:00 2001 From: Changbin Liu Date: Wed, 5 Jun 2013 17:26:34 -0400 Subject: [PATCH] Add pre-install scripts These scripts transform vanilla Ubuntu 12.04 to deploy-ready snapshot Change-Id: I8deb909682ced7505687313b7665467d1c8f7c51 --- bin/pre_install_ovs.sh | 77 +++++++++++++++++++++++++++++++++++ bin/pre_virtual_to_generic.sh | 19 +++++++++ 2 files changed, 96 insertions(+) create mode 100644 bin/pre_install_ovs.sh create mode 100755 bin/pre_virtual_to_generic.sh diff --git a/bin/pre_install_ovs.sh b/bin/pre_install_ovs.sh new file mode 100644 index 0000000..c9ffb5e --- /dev/null +++ b/bin/pre_install_ovs.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +## Install Open vSwitch. This file is translated from +## cookbook/openvswitch/recipes/default. + +# dependencies +sudo apt-get -y install build-essential \ + git \ + autoconf \ + python-simplejson \ + python-qt4 \ + python-twisted-conch \ + uml-utilities \ + libtool \ + pkg-config + +sudo mkdir -p /opt/openvswitch +sudo chmod 00755 /opt/openvswitch +sudo chown root:root /opt/openvswitch + +sudo mkdir -p /etc/openvswitch +sudo chmod 00755 /etc/openvswitch +sudo chown root:root /opt/openvswitch + +sudo chmod a+w /opt/openvswitch +cd /opt/openvswitch +git clone git://openvswitch.org/openvswitch +cd openvswitch +git checkout 3b6f2889400fd340b851c2d36356457559ae6e81 +./boot.sh +./configure --with-linux=/lib/modules/`uname -r`/build \ + --prefix=/usr --localstatedir=/var # default to these libraries +make -j +sudo make install +sudo ovsdb-tool create /etc/openvswitch/conf.db \ + vswitchd/vswitch.ovsschema + +echo "start on (filesystem and net-device-up) +stop on runlevel [016] + +# Automatically restart process if crashed +respawn + +# Essentially lets upstart know the process will detach itself to the background +expect fork + +pre-start script + /sbin/insmod /opt/openvswitch/openvswitch/datapath/linux/openvswitch.ko + mkdir -p /var/run/openvswitch/ +end script + +script + exec /usr/sbin/ovsdb-server /etc/openvswitch/conf.db \\ + --remote=punix:/var/run/openvswitch/db.sock \\ + --remote=db:Open_vSwitch,manager_options \\ + --private-key=db:SSL,private_key \\ + --certificate=db:SSL,certificate \\ + --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach --log-file +end script + +# seems main script only allows one daemon, so we move another +# daemon(s) to post-start and pre-stop +post-start script + exec /usr/sbin/ovs-vswitchd --pidfile --detach +end script + +pre-stop script + exec killall -9 ovs-vswitchd +end script + +post-stop script + /sbin/rmmod openvswitch +end script +" | sudo tee /etc/init/openvswitch.conf +sudo chmod 00755 /etc/init/openvswitch.conf +sudo chown root:root /opt/openvswitch +sudo service openvswitch start diff --git a/bin/pre_virtual_to_generic.sh b/bin/pre_virtual_to_generic.sh new file mode 100755 index 0000000..e701e43 --- /dev/null +++ b/bin/pre_virtual_to_generic.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +## Switch kernel from virtual to generic, for vanilla Ubuntu 12.04 +## image launched instance. + +# routine +sudo apt-get -y update +sudo apt-get -y upgrade + +# install generic and reomve virtual kernel +sudo apt-get -y install linux-generic +sudo apt-get -y purge linux-virtual + +# cleanup +sudo apt-get -y autoremove +sudo apt-get -y autoclean + +# reboot +sudo reboot