mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-11 05:03:34 +01:00
9230bc7c65
We've accumulated a lot of cruft in this directory over the years: so much, that it passed the point of being so disorganized that we no longer browsed through it to see how bad it had gotten. This patch (based on changes by rl1987) tries to remove the most useless items, and split the others into reasonable directories. It creates a new scripts/ directory for maint and test scripts. This patch was generated with the script below. No other changes are made in this patch. ############# # new directories mkdir -p contrib/test-tools mkdir -p contrib/or-tools mkdir -p contrib/dirauth-tools mkdir -p contrib/operator-tools mkdir -p contrib/client-tools mkdir -p contrib/test-tools mkdir -p contrib/dist mkdir -p contrib/dist/suse mkdir -p contrib/win32build mkdir -p scripts/maint mkdir -p scripts/test ############ # Deleted -- nobody who wants this is going to be looking for it here any # longer. Also, nobody wants it. git rm contrib/auto-naming/README # Deleted: We no longer do polipo. git rm contrib/polipo/Makefile.mingw git rm contrib/polipo/README git rm contrib/polipo/polipo-mingw.nsi # We haven't even tried to run this for ages. It is a relic of a bygone era git rm contrib/mdd.py # contrib/dir-tools/directory-archive/ # Tools for running a directory archive. No longer used - deleting them. git rm contrib/directory-archive/crontab.sample git rm contrib/directory-archive/fetch-all git rm contrib/directory-archive/fetch-all-v3 git rm contrib/directory-archive/tar-them-up git rm contrib/directory-archive/fetch-all-functions git rm contrib/directory-archive/sort-into-month-folder # This appears to be related to very old windows packaging stuff. git rm contrib/bundle.nsi git rm contrib/package_nsis-weasel.sh git rm contrib/package_nsis.sh git rm contrib/netinst.nsi git rm contrib/torinst32.ico git rm contrib/xenobite.ico # This should not be needed for cross-compilation any more, should it? git rm contrib/cross.sh # I don't think anyone ever used this. git rm contrib/make-signature.sh # These are attempts to send tor controller commands from the command-line. # They don't support modern authentication. git rm contrib/tor-ctrl.sh # this is for fetching about a tor server from a dirauth. But it # doesn't authenticate the dirauth: yuck. git rm contrib/sd # wow, such unused, very perl4. git rm contrib/tor-stress ####### contrib/dirauth-tools/ # Tools for running a directory authority git mv contrib/add-tor contrib/dirauth-tools/ git mv contrib/nagios-check-tor-authority-cert contrib/dirauth-tools/ ####### # contrib/or-tools/ # Tools for examining relays git mv contrib/check-tor contrib/or-tools/check-tor git mv contrib/checksocks.pl contrib/or-tools/checksocks.pl git mv contrib/exitlist contrib/or-tools/exitlist ####### # contrib/operator-tools # Tools for running a relay. git mv contrib/linux-tor-prio.sh contrib/operator-tools/linux-tor-prio.sh git mv contrib/tor-exit-notice.html contrib/operator-tools/tor-exit-notice.html git mv contrib/tor.logrotate.in contrib/operator-tools/ ###### # contrib/dist git mv contrib/rc.subr contrib/dist/ git mv contrib/tor.sh.in contrib/dist/ git mv contrib/torctl.in contrib/dist/ git mv contrib/suse/* contrib/dist/suse/ ###### # client-tools git mv contrib/torify contrib/client-tools/torify git mv contrib/tor-resolve.py contrib/client-tools/ ###### # win32build git mv contrib/package_nsis-mingw.sh contrib/win32build/ git mv contrib/tor.nsi.in contrib/win32build/ # Erinn didn't ask for this... git mv contrib/tor-mingw.nsi.in contrib/win32build/ git mv contrib/tor.ico contrib/win32build/ ###### # scripts/test git mv contrib/cov-blame scripts/test/cov-blame git mv contrib/cov-diff scripts/test/cov-diff git mv contrib/coverage scripts/test/coverage git mv contrib/scan-build.sh scripts/test/ ######## scripts/maint # Maintainance scripts # # These are scripts for developers to use when hacking on Tor. They mostly # look at the Tor source in one way or another. git mv contrib/findMergedChanges.pl scripts/maint/findMergedChanges.pl git mv contrib/checkOptionDocs.pl scripts/maint/checkOptionDocs.pl git mv contrib/checkSpace.pl scripts/maint/checkSpace.pl git mv contrib/redox.py scripts/maint/redox.py git mv contrib/updateVersions.pl scripts/maint/updateVersions.pl git mv contrib/checkLogs.pl scripts/maint/checkLogs.pl git mv contrib/format_changelog.py scripts/maint/
196 lines
4.9 KiB
Bash
196 lines
4.9 KiB
Bash
#!/bin/sh
|
|
#
|
|
# TOR control script designed to allow an easy command line interface
|
|
# to controlling The Onion Router
|
|
#
|
|
# The exit codes returned are:
|
|
# 0 - operation completed successfully. For "status", tor running.
|
|
# 1 - For "status", tor not running.
|
|
# 2 - Command not supported
|
|
# 3 - Could not be started or reloaded
|
|
# 4 - Could not be stopped
|
|
# 5 -
|
|
# 6 -
|
|
# 7 -
|
|
# 8 -
|
|
#
|
|
# When multiple arguments are given, only the error from the _last_
|
|
# one is reported.
|
|
#
|
|
#
|
|
# |||||||||||||||||||| START CONFIGURATION SECTION ||||||||||||||||||||
|
|
# -------------------- --------------------
|
|
# Name of the executable
|
|
EXEC=tor
|
|
#
|
|
# the path to your binary, including options if necessary
|
|
TORBIN="@BINDIR@/$EXEC"
|
|
#
|
|
# the path to the configuration file
|
|
TORCONF="@CONFDIR@/torrc"
|
|
#
|
|
# the path to your PID file
|
|
PIDFILE="@LOCALSTATEDIR@/run/tor/tor.pid"
|
|
#
|
|
# The path to the log file
|
|
LOGFILE="@LOCALSTATEDIR@/log/tor/tor.log"
|
|
#
|
|
# The path to the datadirectory
|
|
TORDATA="@LOCALSTATEDIR@/lib/tor"
|
|
#
|
|
TORARGS="--pidfile $PIDFILE --log \"notice file $LOGFILE\" --runasdaemon 1"
|
|
TORARGS="$TORARGS --datadirectory $TORDATA"
|
|
|
|
# If user name is set in the environment, then use it;
|
|
# otherwise run as the invoking user (or whatever user the config
|
|
# file says)... unless the invoking user is root. The idea here is to
|
|
# let an unprivileged user run tor for her own use using this script,
|
|
# while still providing for it to be used as a system daemon.
|
|
if [ "x`id -u`" = "x0" ]; then
|
|
TORUSER=@TORUSER@
|
|
fi
|
|
|
|
if [ "x$TORUSER" != "x" ]; then
|
|
TORARGS="$TORARGS --user $TORUSER"
|
|
fi
|
|
|
|
# We no longer wrap the Tor daemon startup in an su when running as
|
|
# root, because it's too painful to make the use of su portable.
|
|
# Just let the daemon set the UID and GID.
|
|
START="$TORBIN -f $TORCONF $TORARGS"
|
|
|
|
#
|
|
# -------------------- --------------------
|
|
# |||||||||||||||||||| END CONFIGURATION SECTION ||||||||||||||||||||
|
|
|
|
ERROR=0
|
|
ARGV="$@"
|
|
if [ "x$ARGV" = "x" ] ; then
|
|
ARGS="help"
|
|
fi
|
|
|
|
checkIfRunning ( ) {
|
|
# check for pidfile
|
|
PID=unknown
|
|
if [ -f $PIDFILE ] ; then
|
|
PID=`/bin/cat $PIDFILE`
|
|
if [ "x$PID" != "x" ] ; then
|
|
if kill -0 $PID 2>/dev/null ; then
|
|
STATUS="$EXEC (pid $PID) running"
|
|
RUNNING=1
|
|
else
|
|
STATUS="PID file ($PIDFILE) present, but $EXEC ($PID) not running"
|
|
RUNNING=0
|
|
fi
|
|
else
|
|
STATUS="$EXEC (pid $PID?) not running"
|
|
RUNNING=0
|
|
fi
|
|
else
|
|
STATUS="$EXEC apparently not running (no pid file)"
|
|
RUNNING=0
|
|
fi
|
|
return
|
|
}
|
|
|
|
for ARG in $@ $ARGS
|
|
do
|
|
checkIfRunning
|
|
|
|
case $ARG in
|
|
start)
|
|
if [ $RUNNING -eq 1 ]; then
|
|
echo "$0 $ARG: $EXEC (pid $PID) already running"
|
|
continue
|
|
fi
|
|
if eval "$START" ; then
|
|
echo "$0 $ARG: $EXEC started"
|
|
# Make sure it stayed up!
|
|
/bin/sleep 1
|
|
checkIfRunning
|
|
if [ $RUNNING -eq 0 ]; then
|
|
echo "$0 $ARG: $EXEC (pid $PID) quit unexpectedly"
|
|
fi
|
|
else
|
|
echo "$0 $ARG: $EXEC could not be started"
|
|
ERROR=3
|
|
fi
|
|
;;
|
|
stop)
|
|
if [ $RUNNING -eq 0 ]; then
|
|
echo "$0 $ARG: $STATUS"
|
|
continue
|
|
fi
|
|
if kill -15 $PID ; then
|
|
echo "$0 $ARG: $EXEC stopped"
|
|
else
|
|
/bin/sleep 1
|
|
if kill -9 $PID ; then
|
|
echo "$0 $ARG: $EXEC stopped"
|
|
else
|
|
echo "$0 $ARG: $EXEC could not be stopped"
|
|
ERROR=4
|
|
fi
|
|
fi
|
|
# Make sure it really died!
|
|
/bin/sleep 1
|
|
checkIfRunning
|
|
if [ $RUNNING -eq 1 ]; then
|
|
echo "$0 $ARG: $EXEC (pid $PID) unexpectedly still running"
|
|
ERROR=4
|
|
fi
|
|
;;
|
|
restart)
|
|
$0 stop start
|
|
;;
|
|
reload)
|
|
if [ $RUNNING -eq 0 ]; then
|
|
echo "$0 $ARG: $STATUS"
|
|
continue
|
|
fi
|
|
if kill -1 $PID; then
|
|
/bin/sleep 1
|
|
echo "$EXEC (PID $PID) reloaded"
|
|
else
|
|
echo "Can't reload $EXEC"
|
|
ERROR=3
|
|
fi
|
|
;;
|
|
status)
|
|
echo $STATUS
|
|
if [ $RUNNING -eq 1 ]; then
|
|
ERROR=0
|
|
else
|
|
ERROR=1
|
|
fi
|
|
;;
|
|
log)
|
|
cat $LOGFILE
|
|
;;
|
|
help)
|
|
echo "usage: $0 (start|stop|restart|status|help)"
|
|
/bin/cat <<EOF
|
|
|
|
start - start $EXEC
|
|
stop - stop $EXEC
|
|
restart - stop and restart $EXEC if running or start if not running
|
|
reload - cause the running process to reinitialize itself
|
|
status - tell whether $EXEC is running or not
|
|
log - display the contents of the log file
|
|
help - this text
|
|
|
|
EOF
|
|
ERROR=0
|
|
;;
|
|
*)
|
|
$0 help
|
|
ERROR=2
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
exit $ERROR
|
|
|