3
# Copyright (c) 2013 Nicira, Inc.
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at:
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
21
(cd "$sandbox" && "$@") || exit 1
30
# This option-parsing mechanism borrowed from a Autoconf-generated
31
# configure script under the following license:
33
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
34
# 2002, 2003, 2004, 2005, 2006, 2009, 2013 Free Software Foundation, Inc.
35
# This configure script is free software; the Free Software Foundation
36
# gives unlimited permission to copy, distribute and modify it.
38
# If the previous option needs an argument, assign it.
39
if test -n "$prev"; then
45
*=*) optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;;
49
case $dashdash$option in
54
ovs-sandbox, for starting a sandboxed dummy Open vSwitch environment
57
If you run ovs-sandbox from an OVS build directory, it uses the OVS that
58
you built. Otherwise, if you have an installed Open vSwitch, it uses
59
the installed version.
61
These options force ovs-sandbox to use a particular OVS build:
62
-b, --builddir=DIR specify Open vSwitch build directory
63
-s, --srcdir=DIR specify Open vSwitch source directory
64
These options force ovs-sandbox to use an installed Open vSwitch:
65
-i, --installed use installed Open vSwitch
66
-S, --schema=FILE use FILE as vswitch.ovsschema
69
-h, --help Print this usage message.
102
echo "unrecognized option $option (use --help for help)" >&2
106
echo "$option: non-option arguments not supported (use --help for help)" >&2
113
if $installed && $built; then
114
echo "sorry, conflicting options (use --help for help)" >&2
116
elif $installed || $built; then
118
elif test -e vswitchd/ovs-vswitchd; then
121
elif (ovs-vswitchd --version) >/dev/null 2>&1; then
124
echo "can't find an OVS build or install (use --help for help)" >&2
129
if test ! -e "$builddir"/vswitchd/ovs-vswitchd; then
130
echo "$builddir does not appear to be an OVS build directory" >&2
133
builddir=`cd $builddir && pwd`
139
if test ! -e "$srcdir"/WHY-OVS; then
140
srcdir=`cd $builddir/.. && pwd`
144
*) srcdir=`pwd`/$srcdir ;;
146
schema=$srcdir/vswitchd/vswitch.ovsschema
147
if test ! -e "$schema"; then
148
echo >&2 'source directory not found, please use --srcdir'
152
# Put built tools early in $PATH.
153
if test ! -e $builddir/vswitchd/ovs-vswitchd; then
154
echo >&2 'build not found, please change set $builddir or change directory'
157
PATH=$builddir/ovsdb:$builddir/vswitchd:$builddir/utilities:$PATH
163
/usr/local/share/openvswitch/vswitch.ovsschema \
164
/usr/share/openvswitch/vswitch.ovsschema \
166
if test -r $schema; then
172
*) schema=`pwd`/$schema ;;
174
if test ! -r "$schema"; then
175
echo "can't find vswitch.ovsschema, please specify --schema" >&2
183
sandbox=`cd sandbox && pwd`
185
# Set up environment for OVS programs to sandbox themselves.
186
OVS_RUNDIR=$sandbox; export OVS_RUNDIR
187
OVS_LOGDIR=$sandbox; export OVS_LOGDIR
188
OVS_DBDIR=$sandbox; export OVS_DBDIR
189
OVS_SYSCONFDIR=$sandbox; export OVS_SYSCONFDIR
192
# Easy access to OVS manpages.
193
(cd "$builddir" && make install-man mandir="$sandbox"/man)
194
MANPATH=$sandbox/man:; export MANPATH
198
trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15
200
# Create database and start ovsdb-server.
201
touch "$sandbox"/.conf.db.~lock~
202
run ovsdb-tool create conf.db "$schema"
203
run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
204
--remote=punix:"$sandbox"/db.sock
206
# Start ovs-vswitchd.
207
run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
208
--enable-dummy=override -vvconn -vnetdev_dummy
214
----------------------------------------------------------------------
215
You are running in a dummy Open vSwitch environment. You can use
216
ovs-vsctl, ovs-ofctl, ovs-appctl, and other tools to work with the
219
Log files, pidfiles, and the configuration database are in the
220
"sandbox" subdirectory.
222
Exit the shell to kill the running daemons.
225
status=0; $SHELL || status=$?
228
----------------------------------------------------------------------