3 # Copyright (c) 2013, 2015 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.
20 (cd "$sandbox" && "$@") ||
exit 1
26 run xterm
-T "$title" -e "$@" &
32 # Remove the --detach and to put the process under gdb control.
33 # Also remove --vconsole:off to allow error message to show up
35 # Use "DISPLAY" variable to determine out if X is supported
36 if $under_gdb && [ "$DISPLAY" ]; then
37 args
=`echo $@ |sed s/--detach//g | sed s/--vconsole:off//g`
39 run_xterm
$xterm_title gdb
-ex run
--args $args
54 # This option-parsing mechanism borrowed from a Autoconf-generated
55 # configure script under the following license:
57 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
58 # 2002, 2003, 2004, 2005, 2006, 2009, 2013 Free Software Foundation, Inc.
59 # This configure script is free software; the Free Software Foundation
60 # gives unlimited permission to copy, distribute and modify it.
62 # If the previous option needs an argument, assign it.
63 if test -n "$prev"; then
69 *=*) optarg
=`expr "X$option" : '[^=]*=\(.*\)'` ;;
73 case $dashdash$option in
78 ovs-sandbox, for starting a sandboxed dummy Open vSwitch environment
81 If you run ovs-sandbox from an OVS build directory, it uses the OVS that
82 you built. Otherwise, if you have an installed Open vSwitch, it uses
83 the installed version.
85 These options force ovs-sandbox to use a particular OVS build:
86 -b, --builddir=DIR specify Open vSwitch build directory
87 -s, --srcdir=DIR specify Open vSwitch source directory
88 These options force ovs-sandbox to use an installed Open vSwitch:
89 -i, --installed use installed Open vSwitch
90 -g, --gdb-vswitchd run ovs-vswitchd under gdb
91 -d, --gdb-ovsdb run ovsdb-server under gdb
92 -S, --schema=FILE use FILE as vswitch.ovsschema
95 -h, --help Print this usage message.
134 echo "unrecognized option $option (use --help for help)" >&2
138 echo "$option: non-option arguments not supported (use --help for help)" >&2
145 if $installed && $built; then
146 echo "sorry, conflicting options (use --help for help)" >&2
148 elif $installed ||
$built; then
150 elif test -e vswitchd
/ovs-vswitchd
; then
153 elif (ovs-vswitchd
--version) >/dev
/null
2>&1; then
156 echo "can't find an OVS build or install (use --help for help)" >&2
161 if test ! -e "$builddir"/vswitchd
/ovs-vswitchd
; then
162 echo "$builddir does not appear to be an OVS build directory" >&2
165 builddir
=`cd $builddir && pwd`
171 if test ! -e "$srcdir"/WHY-OVS.md
; then
172 srcdir
=`cd $builddir/.. && pwd`
176 *) srcdir
=`pwd`/$srcdir ;;
178 schema
=$srcdir/vswitchd
/vswitch.ovsschema
179 if test ! -e "$schema"; then
180 echo >&2 'source directory not found, please use --srcdir'
184 # Put built tools early in $PATH.
185 if test ! -e $builddir/vswitchd
/ovs-vswitchd
; then
186 echo >&2 'build not found, please change set $builddir or change directory'
189 PATH
=$builddir/ovsdb
:$builddir/vswitchd
:$builddir/utilities
:$PATH
195 /usr
/local
/share
/openvswitch
/vswitch.ovsschema \
196 /usr
/share
/openvswitch
/vswitch.ovsschema \
198 if test -r $schema; then
204 *) schema
=`pwd`/$schema ;;
206 if test ! -r "$schema"; then
207 echo "can't find vswitch.ovsschema, please specify --schema" >&2
215 sandbox
=`cd sandbox && pwd`
217 # Set up environment for OVS programs to sandbox themselves.
218 OVS_RUNDIR
=$sandbox; export OVS_RUNDIR
219 OVS_LOGDIR
=$sandbox; export OVS_LOGDIR
220 OVS_DBDIR
=$sandbox; export OVS_DBDIR
221 OVS_SYSCONFDIR
=$sandbox; export OVS_SYSCONFDIR
224 # Easy access to OVS manpages.
225 (cd "$builddir" && ${MAKE} install-man mandir
="$sandbox"/man
)
226 MANPATH
=$sandbox/man
:; export MANPATH
230 trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15
232 # Create database and start ovsdb-server.
233 touch "$sandbox"/.conf.db.~lock~
234 run ovsdb-tool create conf.db
"$schema"
235 rungdb
$gdb_ovsdb ovsdb-server
--detach --no-chdir --pidfile -vconsole:off
--log-file \
236 --remote=punix
:"$sandbox"/db.sock
238 #Add a small delay to allow ovsdb-server to launch.
241 #Wait for ovsdb-server to finish launching.
242 if test ! -e "$sandbox"/db.sock
; then
243 echo -n "Waiting for ovsdb-server to start..."
244 while test ! -e "$sandbox"/db.sock
; do
250 # Initialize database.
251 run ovs-vsctl
--no-wait -- init
253 # Start ovs-vswitchd.
254 rungdb
$gdb_vswitchd ovs-vswitchd
--detach --no-chdir --pidfile -vconsole:off
--log-file \
255 --enable-dummy=override
-vvconn -vnetdev_dummy
261 ----------------------------------------------------------------------
262 You are running in a dummy Open vSwitch environment. You can use
263 ovs-vsctl, ovs-ofctl, ovs-appctl, and other tools to work with the
266 Log files, pidfiles, and the configuration database are in the
267 "sandbox" subdirectory.
269 Exit the shell to kill the running daemons.
272 status
=0; $SHELL || status
=$?
275 ----------------------------------------------------------------------