Skip to content

Instantly share code, notes, and snippets.

@leoh0
Created October 18, 2016 07:19
Show Gist options
  • Select an option

  • Save leoh0/389c6903470435591c03bd38ed39970e to your computer and use it in GitHub Desktop.

Select an option

Save leoh0/389c6903470435591c03bd38ed39970e to your computer and use it in GitHub Desktop.
ubuntu 에서 ovs 를 package 에서 source 버전으로 변경 script
# 다운로드 및 빌드
cd /tmp
wget http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz
tar zxvf openvswitch-2.3.1.tar.gz
mv openvswitch-2.3.1 /usr/src/
cd /usr/src/openvswitch-2.3.1
./boot.sh
./configure --with-linux=/lib/modules/`uname -r`/build --prefix=/usr --sysconfdir=/etc --localstatedir=/var
make -j
# db를 복사해 놓을 공간을 만들어 놓음 2.3~ 대부터는 /var/lib/openvswitch에 저장함
mkdir -p /var/lib/openvswitch/
cp /etc/openvswitch/conf.db /var/lib/openvswitch/conf.db
cp /etc/openvswitch/.conf.db.~lock~ /var/lib/openvswitch/.conf.db.~lock~
# purge package!! after 3 second traffic will be shutdown..
apt-get purge --auto-remove -y openvswitch-common openvswitch-datapath-dkms openvswitch-switch
# 인스톨에 빠진 데비안용 스크립트들 설치
mkdir -p /usr/share/openvswitch/scripts/
cp /usr/src/openvswitch-2.3.1/debian/ifupdown.sh /usr/share/openvswitch/scripts/ifupdown.sh
chmod +x /usr/share/openvswitch/scripts/ifupdown.sh
ln -s /usr/share/openvswitch/scripts/ifupdown.sh /etc/network/if-pre-up.d/openvswitch
ln -s /usr/share/openvswitch/scripts/ifupdown.sh /etc/network/if-post-down.d/openvswitch
cp /usr/src/openvswitch-2.3.1/debian/openvswitch-switch.init /etc/init.d/openvswitch-switch
chmod +x /etc/init.d/openvswitch-switch
cat << 'EOF' > /etc/init/openvswitch-force-reload-kmod.conf
# vim: set ft=upstart ts=2 et:
description "Open vSwitch - force reload of kernel module"
author "James Page <[email protected]"
task
script
stop openvswitch-switch || true
# Drop gre module as well - native kernel module in 3.11 uses
# this and it blocks GRE protocol registration in the DKMS
# module
modprobe -r openvswitch gre || true
start openvswitch-switch
end script
EOF
cat << 'EOF' > /etc/init/openvswitch-switch.conf
# vim: set ft=upstart ts=2 et:
description "Open vSwitch switch"
author "James Page <[email protected]"
start on (local-filesystems and net-device-up IFACE=lo)
stop on runlevel [!2345]
pre-start script
(test -x /usr/sbin/ovs-vswitchd && test -x /usr/sbin/ovsdb-server) || exit 0
. /usr/share/openvswitch/scripts/ovs-lib
test -e /etc/default/openvswitch-switch && . /etc/default/openvswitch-switch
if ovs_ctl load-kmod; then
:
else
echo "Module has probably not been built for this kernel."
if ! test -d /usr/share/doc/openvswitch-datapath-dkms; then
echo "Install the openvswitch-datapath-dkms package."
fi
if test X"$OVS_MISSING_KMOD_OK" = Xyes; then
# We're being invoked by the package postinst. Do not
# fail package installation just because the kernel module
# is not available.
exit 0
fi
fi
set ovs_ctl start --system-id=random
if test X"$FORCE_COREFILES" != X; then
set "$@" --force-corefiles="$FORCE_COREFILES"
fi
set "$@" $OVS_CTL_OPTS
"$@"
end script
post-stop script
. /usr/share/openvswitch/scripts/ovs-lib
test -e /etc/default/openvswitch-switch && . /etc/default/openvswitch-switch
ovs_ctl stop
end script
EOF
cp /usr/src/openvswitch-2.3.1/debian/openvswitch-switch.logrotate /etc/logrotate.d/openvswitch-switch
mkdir -p /usr/share/openvswitch/switch/
cp /usr/src/openvswitch-2.3.1/debian/openvswitch-switch.template /usr/share/openvswitch/switch/default.template
cp /usr/share/openvswitch/switch/default.template /etc/default/openvswitch-switch
rm /etc/openvswitch/conf.db
rm /etc/openvswitch/.conf.db.~lock~
mkdir -p /etc/openvswitch
ln -s /var/lib/openvswitch/conf.db /etc/openvswitch/conf.db
ln -s /var/lib/openvswitch/.conf.db.~lock~ /etc/openvswitch/.conf.db.~lock~
# 인스톨!
make install
make modules_install
# 모듈 내리고 서비스 올리면 모듈 알아서 올라옴
service openvswitch-force-reload-kmod restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment