From 893b9070a8ea5be365e6cf3ba4af7b337af0027d Mon Sep 17 00:00:00 2001 From: Mario Preksavec Date: Mon, 16 Mar 2015 01:53:28 +0700 Subject: network/openvswitch-utils: Added (a multilayer software switch). Signed-off-by: Willy Sudiarto Raharjo --- network/openvswitch-utils/README | 20 ++++ network/openvswitch-utils/README.SLACKWARE | 27 +++++ network/openvswitch-utils/doinst.sh | 25 +++++ .../openvswitch-utils/openvswitch-utils.SlackBuild | 113 +++++++++++++++++++++ network/openvswitch-utils/openvswitch-utils.info | 10 ++ network/openvswitch-utils/rc.openvswitch | 87 ++++++++++++++++ network/openvswitch-utils/slack-desc | 18 ++++ 7 files changed, 300 insertions(+) create mode 100644 network/openvswitch-utils/README create mode 100644 network/openvswitch-utils/README.SLACKWARE create mode 100644 network/openvswitch-utils/doinst.sh create mode 100644 network/openvswitch-utils/openvswitch-utils.SlackBuild create mode 100644 network/openvswitch-utils/openvswitch-utils.info create mode 100644 network/openvswitch-utils/rc.openvswitch create mode 100644 network/openvswitch-utils/slack-desc diff --git a/network/openvswitch-utils/README b/network/openvswitch-utils/README new file mode 100644 index 0000000000..1efa3d3dcc --- /dev/null +++ b/network/openvswitch-utils/README @@ -0,0 +1,20 @@ +Open vSwitch is a multilayer software switch licensed under the open +source Apache 2 license. The goal is to implement a production quality +switch platform that supports standard management interfaces and opens the +forwarding functions to programmatic extension and control. + +Open vSwitch is well suited to function as a virtual switch in VM +environments. In addition to exposing standard control and visibility +interfaces to the virtual networking layer, it was designed to support +distribution across multiple physical servers. Open vSwitch supports +multiple Linux-based virtualization technologies including Xen/XenServer, +KVM, and VirtualBox. + +Note: This package builds only the Open vSwitch userspace utilities, and +it is incompatible with 'openvswitch' package found on SlackBuilds.org +website. The stock Slackware kernel has been shipping Open vSwitch support +for a while now, and these utilities take this advantage into account +while providing a different approach to Open vSwitch management. + +See README.SLACKWARE (which is also installed with the package docs) for +setup, configuration, and usage hints. diff --git a/network/openvswitch-utils/README.SLACKWARE b/network/openvswitch-utils/README.SLACKWARE new file mode 100644 index 0000000000..d8072e695c --- /dev/null +++ b/network/openvswitch-utils/README.SLACKWARE @@ -0,0 +1,27 @@ +You may wish to add these lines to /etc/rc.d/rc.local to start the service: + +if [ -x /etc/rc.d/rc.openvswitch ]; then + /etc/rc.d/rc.openvswitch start +fi + +Run Control script can also initialize the database: + + /etc/rc.d/rc.openvswitch clean-database + +One shot start with a clean initialized database can be performed with: + + /etc/rc.d/rc.openvswitch start-clean + +And if you want to stop, clean the database, and start again: + + /etc/rc.d/rc.openvswitch restart-clean + +You may also add these lines to /etc/rc.d/rc.local_shutdown: + +if [ -x /etc/rc.d/rc.openvswitch ]; then + /etc/rc.d/rc.openvswitch stop +fi + +Remember to give executable permission to /etc/rc.d/rc.local_shutdown: + + chmod 0755 /etc/rc.d/rc.local_shutdown diff --git a/network/openvswitch-utils/doinst.sh b/network/openvswitch-utils/doinst.sh new file mode 100644 index 0000000000..2057a9da19 --- /dev/null +++ b/network/openvswitch-utils/doinst.sh @@ -0,0 +1,25 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.openvswitch.new diff --git a/network/openvswitch-utils/openvswitch-utils.SlackBuild b/network/openvswitch-utils/openvswitch-utils.SlackBuild new file mode 100644 index 0000000000..bdf8e72dd7 --- /dev/null +++ b/network/openvswitch-utils/openvswitch-utils.SlackBuild @@ -0,0 +1,113 @@ +#!/bin/sh + +# Slackware build script for openvswitch-utils + +# Copyright 2010, 2011, 2013, 2014, 2015 Mario Preksavec, Zagreb, Croatia +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=openvswitch-utils +VERSION=${VERSION:-2.3.1} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +SRCNAM=openvswitch + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $SRCNAM-$VERSION +tar xvf $CWD/$SRCNAM-$VERSION.tar.gz +cd $SRCNAM-$VERSION +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --mandir=/usr/man \ + --docdir=/usr/doc/$PRGNAM-$VERSION \ + --enable-static=no \ + --enable-shared=yes \ + --build=$ARCH-slackware-linux + +make +make install DESTDIR=$PKG + +# Create the missing dirs +mkdir -p $PKG/{etc/$SRCNAM,var/run/$SRCNAM} + +# Install rc script +install -D -oroot -groot -m644 $CWD/rc.$SRCNAM $PKG/etc/rc.d/rc.$SRCNAM.new + +find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +find $PKG/usr/man -type f -exec gzip -9 {} \; +for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a AUTHORS CONTRIBUTING COPYING CodingStyle DESIGN FAQ INSTALL* IntegrationGuide NEWS \ + NOTICE OPENFLOW-1.1+ PORTING README* REPORTING-BUGS TODO WHY-OVS $CWD/README.SLACKWARE \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/network/openvswitch-utils/openvswitch-utils.info b/network/openvswitch-utils/openvswitch-utils.info new file mode 100644 index 0000000000..d4add08229 --- /dev/null +++ b/network/openvswitch-utils/openvswitch-utils.info @@ -0,0 +1,10 @@ +PRGNAM="openvswitch-utils" +VERSION="2.3.1" +HOMEPAGE="http://openvswitch.org/" +DOWNLOAD="http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz" +MD5SUM="c008c1de0a8b6363b37afa599105d6d6" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="Mario Preksavec" +EMAIL="mario at slackware dot hr" diff --git a/network/openvswitch-utils/rc.openvswitch b/network/openvswitch-utils/rc.openvswitch new file mode 100644 index 0000000000..8022ae3b74 --- /dev/null +++ b/network/openvswitch-utils/rc.openvswitch @@ -0,0 +1,87 @@ +#!/bin/sh +# Start/stop/restart openvswitch. + +# To start Open vSwitch automatically at boot, be sure this script is +# executable: +# +# % chmod 755 /etc/rc.d/rc.openvswitch + +# Before you can run Open vSwitch daemon, you must have a database. To +# install one, perform the following as root: +# +# % /etc/rc.d/rc.openvswitch clean-database +# + +DBCONF=/etc/openvswitch/ovs-vswitchd.conf.db +SOCKET=/var/run/openvswitch/db.sock +VSPID=/var/run/openvswitch/ovs-vswitchd.pid +DBPID=/var/run/openvswitch/ovsdb-server.pid + +# Insert kernel driver for Open vSwitch: +/sbin/modprobe openvswitch + +# Insert kernel driver for VLANs: +/sbin/modprobe 8021q + +# Start openvswitch: +openvswitch_start() { + echo "Starting openvswitch: /etc/rc.d/rc.openvswitch" + /usr/sbin/ovsdb-server /etc/openvswitch/ovs-vswitchd.conf.db --remote=punix:$SOCKET \ + --detach --pidfile=$DBPID --verbose=ANY:ANY:err + /usr/bin/ovs-vsctl --no-wait --verbose=ANY:ANY:err init + /usr/sbin/ovs-vswitchd unix:$SOCKET --detach --pidfile=$VSPID --verbose=ANY:ANY:err +} + +# Stop openvswitch: +openvswitch_stop() { + echo "Stopping openvswitch: /etc/rc.d/rc.openvswitch" + if [ -e $VSPID ]; then + pid=$(cat $VSPID) + /usr/bin/ovs-appctl -t /var/run/openvswitch/ovs-vswitchd.$pid.ctl exit + fi + if [ -e $DBPID ]; then + pid=$(cat $DBPID) + /usr/bin/ovs-appctl -t /var/run/openvswitch/ovsdb-server.$pid.ctl exit + fi +} + +# Clean openvswitch: +openvswitch_clean() { + if [ ! -e $DBPID ] && [ ! -e $VSPID ]; then + rm -f $DBCONF + /usr/bin/ovsdb-tool create $DBCONF /usr/share/openvswitch/vswitch.ovsschema + else + echo "Stop openvswitch first!" + fi +} + +case "$1" in + 'start') + openvswitch_start + ;; + 'stop') + openvswitch_stop + ;; + 'restart') + openvswitch_stop + sleep 1 + openvswitch_start + ;; + 'clean-database') + openvswitch_clean + ;; + 'start-clean') + openvswitch_clean + sleep 1 + openvswitch_start + ;; + 'restart-clean') + openvswitch_stop + sleep 1 + openvswitch_clean + sleep 1 + openvswitch_start + ;; + *) + echo "Usage $0 start|stop|restart|clean-database|start-clean|restart-clean" +esac diff --git a/network/openvswitch-utils/slack-desc b/network/openvswitch-utils/slack-desc new file mode 100644 index 0000000000..8e2519f3dd --- /dev/null +++ b/network/openvswitch-utils/slack-desc @@ -0,0 +1,18 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +openvswitch-utils: openvswitch-utils (a multilayer software switch) +openvswitch-utils: +openvswitch-utils: Open vSwitch is a multilayer software switch licensed under the open +openvswitch-utils: source Apache 2 license. The goal is to implement a production +openvswitch-utils: quality switch platform that supports standard management interfaces +openvswitch-utils: and opens the forwarding functions to programmatic extension and +openvswitch-utils: control. +openvswitch-utils: +openvswitch-utils: Homepage: http://openvswitch.org/ +openvswitch-utils: -- cgit v1.2.3