2017-03-01 02:28:16 +01:00
|
|
|
#!/bin/sh
|
2017-03-01 01:21:07 +01:00
|
|
|
|
2017-03-01 03:28:30 +01:00
|
|
|
# This script calls the equivalent script in chutney/tools
|
|
|
|
|
|
|
|
# If we already know CHUTNEY_PATH, don't bother with argument parsing
|
|
|
|
TEST_NETWORK="$CHUTNEY_PATH/tools/test-network.sh"
|
|
|
|
# Call the chutney version of this script, if it exists, and we can find it
|
|
|
|
if [ -d "$CHUTNEY_PATH" -a -x "$TEST_NETWORK" ]; then
|
|
|
|
# we can't produce any output, because we might be --quiet
|
|
|
|
# this preserves arguments with spaces correctly
|
|
|
|
exec "$TEST_NETWORK" "$@"
|
2017-03-01 01:21:07 +01:00
|
|
|
fi
|
2013-06-05 15:48:57 +02:00
|
|
|
|
2017-03-01 03:28:30 +01:00
|
|
|
# We need to go looking for CHUTNEY_PATH
|
2016-07-17 14:04:37 +02:00
|
|
|
|
2017-03-01 03:28:30 +01:00
|
|
|
# Do we output anything at all?
|
|
|
|
ECHO="${ECHO:-echo}"
|
2016-07-17 14:04:37 +02:00
|
|
|
# Output is prefixed with the name of the script
|
|
|
|
myname=$(basename $0)
|
2014-10-01 09:56:53 +02:00
|
|
|
|
2017-03-01 03:28:30 +01:00
|
|
|
# Save the arguments before we destroy them
|
|
|
|
# This might not preserve arguments with spaces in them
|
|
|
|
ORIGINAL_ARGS="$@"
|
2016-07-17 14:15:48 +02:00
|
|
|
|
2017-03-01 03:28:30 +01:00
|
|
|
# We need to find CHUTNEY_PATH, so that we can call the version of this script
|
|
|
|
# in chutney/tools with the same arguments. We also need to respect --quiet.
|
2015-09-08 14:27:12 +02:00
|
|
|
until [ -z "$1" ]
|
2013-09-29 07:24:14 +02:00
|
|
|
do
|
2015-09-08 14:27:12 +02:00
|
|
|
case "$1" in
|
2013-09-29 07:24:14 +02:00
|
|
|
--chutney-path)
|
2017-03-01 03:28:30 +01:00
|
|
|
CHUTNEY_PATH="$2"
|
2013-09-29 07:24:14 +02:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--tor-path)
|
2017-03-01 03:28:30 +01:00
|
|
|
TOR_DIR="$2"
|
2013-09-29 07:24:14 +02:00
|
|
|
shift
|
|
|
|
;;
|
2017-02-27 15:45:30 +01:00
|
|
|
--quiet)
|
2017-03-01 03:28:30 +01:00
|
|
|
ECHO=true
|
|
|
|
;;
|
2013-09-29 07:24:14 +02:00
|
|
|
*)
|
2017-03-01 03:28:30 +01:00
|
|
|
# maybe chutney's test-network.sh can handle it
|
2013-09-29 07:24:14 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2013-06-05 15:48:57 +02:00
|
|
|
|
2016-07-17 14:04:37 +02:00
|
|
|
# optional: $TOR_DIR is the tor build directory
|
|
|
|
# it's used to find the location of tor binaries
|
|
|
|
# if it's not set:
|
2017-03-01 03:28:30 +01:00
|
|
|
# - set it to $BUILDDIR, or
|
2016-07-17 14:04:37 +02:00
|
|
|
# - if $PWD looks like a tor build directory, set it to $PWD, or
|
|
|
|
# - unset $TOR_DIR, and let chutney fall back to finding tor binaries in $PATH
|
|
|
|
if [ ! -d "$TOR_DIR" ]; then
|
2018-07-05 23:05:54 +02:00
|
|
|
if [ -d "$BUILDDIR/src/core/or" -a -d "$BUILDDIR/src/tools" ]; then
|
2016-07-17 14:04:37 +02:00
|
|
|
# Choose the build directory
|
|
|
|
# But only if it looks like one
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$TOR_DIR not set, trying \$BUILDDIR"
|
2017-03-01 03:28:30 +01:00
|
|
|
TOR_DIR="$BUILDDIR"
|
2018-07-05 23:05:54 +02:00
|
|
|
elif [ -d "$PWD/src/core/or" -a -d "$PWD/src/tools" ]; then
|
2016-07-17 14:04:37 +02:00
|
|
|
# Guess the tor directory is the current directory
|
|
|
|
# But only if it looks like one
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$TOR_DIR not set, trying \$PWD"
|
2017-03-01 03:28:30 +01:00
|
|
|
TOR_DIR="$PWD"
|
2016-07-17 14:04:37 +02:00
|
|
|
else
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: no \$TOR_DIR, chutney will use \$PATH for tor binaries"
|
2016-07-17 14:04:37 +02:00
|
|
|
unset TOR_DIR
|
|
|
|
fi
|
|
|
|
fi
|
2015-09-01 16:52:30 +02:00
|
|
|
|
2016-07-17 14:04:37 +02:00
|
|
|
# mandatory: $CHUTNEY_PATH is the path to the chutney launch script
|
|
|
|
# if it's not set:
|
|
|
|
# - if $PWD looks like a chutney directory, set it to $PWD, or
|
|
|
|
# - set it based on $TOR_DIR, expecting chutney to be next to tor, or
|
|
|
|
# - fail and tell the user how to clone the chutney repository
|
|
|
|
if [ ! -d "$CHUTNEY_PATH" -o ! -x "$CHUTNEY_PATH/chutney" ]; then
|
|
|
|
if [ -x "$PWD/chutney" ]; then
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$PWD"
|
2017-03-01 03:28:30 +01:00
|
|
|
CHUTNEY_PATH="$PWD"
|
2016-07-17 14:04:37 +02:00
|
|
|
elif [ -d "$TOR_DIR" -a -d "$TOR_DIR/../chutney" -a \
|
|
|
|
-x "$TOR_DIR/../chutney/chutney" ]; then
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$TOR_DIR/../chutney"
|
2017-03-01 03:28:30 +01:00
|
|
|
CHUTNEY_PATH="$TOR_DIR/../chutney"
|
2016-07-17 14:04:37 +02:00
|
|
|
else
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: missing 'chutney' in \$CHUTNEY_PATH ($CHUTNEY_PATH)"
|
|
|
|
$ECHO "$myname: Get chutney: git clone https://git.torproject.org/\
|
2015-09-01 16:52:30 +02:00
|
|
|
chutney.git"
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: Set \$CHUTNEY_PATH to a non-standard location: export \
|
2016-07-17 14:04:37 +02:00
|
|
|
CHUTNEY_PATH=\`pwd\`/chutney"
|
|
|
|
unset CHUTNEY_PATH
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-08-03 19:23:58 +02:00
|
|
|
|
2017-03-01 03:28:30 +01:00
|
|
|
TEST_NETWORK="$CHUTNEY_PATH/tools/test-network.sh"
|
|
|
|
# Call the chutney version of this script, if it exists, and we can find it
|
|
|
|
if [ -d "$CHUTNEY_PATH" -a -x "$TEST_NETWORK" ]; then
|
|
|
|
$ECHO "$myname: Calling newer chutney script $TEST_NETWORK"
|
|
|
|
# this may fail if some arguments have spaces in them
|
|
|
|
# if so, set CHUTNEY_PATH before calling test-network.sh, and spaces
|
|
|
|
# will be handled correctly
|
|
|
|
exec "$TEST_NETWORK" $ORIGINAL_ARGS
|
|
|
|
else
|
|
|
|
$ECHO "$myname: Could not find tools/test-network.sh in CHUTNEY_PATH."
|
|
|
|
$ECHO "$myname: Please update your chutney using 'git pull'."
|
|
|
|
# We have failed to do what the user asked
|
|
|
|
exit 1
|
2016-07-17 14:08:31 +02:00
|
|
|
fi
|