3 # This script calls the equivalent script in chutney/tools
5 # If we already know CHUTNEY_PATH, don't bother with argument parsing
6 TEST_NETWORK
="$CHUTNEY_PATH/tools/test-network.sh"
7 # Call the chutney version of this script, if it exists, and we can find it
8 if [ -d "$CHUTNEY_PATH" ] && [ -x "$TEST_NETWORK" ]; then
9 # we can't produce any output, because we might be --quiet
10 # this preserves arguments with spaces correctly
11 exec "$TEST_NETWORK" "$@"
14 # We need to go looking for CHUTNEY_PATH
16 # Do we output anything at all?
18 # Output is prefixed with the name of the script
19 myname
=$
(basename "$0")
21 # We need to find CHUTNEY_PATH, so that we can call the version of this script
22 # in chutney/tools with the same arguments. We also need to respect --quiet.
23 CHUTNEY_PATH
=$
(echo "$@" |
awk -F '--chutney-path ' '{sub(" .*","",$2); print $2}')
24 TOR_DIR
=$
(echo "$@" |
awk -F '--tor-dir ' '{sub(" .*","",$2); print $2}')
26 if echo "$@" |
grep -e "--quiet" > /dev
/null
; then
30 # optional: $TOR_DIR is the tor build directory
31 # it's used to find the location of tor binaries
33 # - set it to $BUILDDIR, or
34 # - if $PWD looks like a tor build directory, set it to $PWD, or
35 # - unset $TOR_DIR, and let chutney fall back to finding tor binaries in $PATH
36 if [ ! -d "$TOR_DIR" ]; then
37 if [ -d "$BUILDDIR/src/core/or" ] && [ -d "$BUILDDIR/src/tools" ]; then
38 # Choose the build directory
39 # But only if it looks like one
40 $ECHO "$myname: \$TOR_DIR not set, trying \$BUILDDIR"
42 elif [ -d "$PWD/src/core/or" ] && [ -d "$PWD/src/tools" ]; then
43 # Guess the tor directory is the current directory
44 # But only if it looks like one
45 $ECHO "$myname: \$TOR_DIR not set, trying \$PWD"
48 $ECHO "$myname: no \$TOR_DIR, chutney will use \$PATH for tor binaries"
53 # mandatory: $CHUTNEY_PATH is the path to the chutney launch script
55 # - if $PWD looks like a chutney directory, set it to $PWD, or
56 # - set it based on $TOR_DIR, expecting chutney to be next to tor, or
57 # - fail and tell the user how to clone the chutney repository
58 if [ ! -d "$CHUTNEY_PATH" ] ||
[ ! -x "$CHUTNEY_PATH/chutney" ]; then
59 if [ -x "$PWD/chutney" ]; then
60 $ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$PWD"
62 elif [ -d "$TOR_DIR" ] && [ -d "$TOR_DIR/../chutney" ] && \
63 [ -x "$TOR_DIR/../chutney/chutney" ]; then
64 $ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$TOR_DIR/../chutney"
65 CHUTNEY_PATH
="$TOR_DIR/../chutney"
67 $ECHO "$myname: missing 'chutney' in \$CHUTNEY_PATH ($CHUTNEY_PATH)"
68 $ECHO "$myname: Get chutney: git clone
69 https://gitlab.torproject.org/tpo/core\
71 $ECHO "$myname: Set \$CHUTNEY_PATH to a non-standard location: export \
72 CHUTNEY_PATH=\`pwd\`/chutney"
78 TEST_NETWORK
="$CHUTNEY_PATH/tools/test-network.sh"
79 # Call the chutney version of this script, if it exists, and we can find it
80 if [ -d "$CHUTNEY_PATH" ] && [ -x "$TEST_NETWORK" ]; then
81 $ECHO "$myname: Calling newer chutney script $TEST_NETWORK"
82 # this may fail if some arguments have spaces in them
83 # if so, set CHUTNEY_PATH before calling test-network.sh, and spaces
84 # will be handled correctly
85 exec "$TEST_NETWORK" "$@"
87 $ECHO "$myname: Could not find tools/test-network.sh in CHUTNEY_PATH."
88 $ECHO "$myname: Please update your chutney using 'git pull'."
89 # We have failed to do what the user asked