mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-23 14:40:51 +01:00
Wait for tor to die in init stop. Let the user know if it doesn't
svn:r1223
This commit is contained in:
parent
ee3ed492ee
commit
3e452fed54
2 changed files with 61 additions and 11 deletions
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -5,8 +5,9 @@ tor (0.0.1+0.0.2pre24-1) unstable; urgency=low
|
||||||
* Add "# ulimit -c unlimited" to tor.default
|
* Add "# ulimit -c unlimited" to tor.default
|
||||||
* Always enable DataDirectory.
|
* Always enable DataDirectory.
|
||||||
* Actually use dpatch now (to modify upstream torrc.in)
|
* Actually use dpatch now (to modify upstream torrc.in)
|
||||||
|
* Wait for tor to die in init stop. Let the user know if it doesn't.
|
||||||
|
|
||||||
-- Peter Palfrader <weasel@debian.org> Wed, 3 Mar 2004 13:48:09 +0100
|
-- Peter Palfrader <weasel@debian.org> Wed, 3 Mar 2004 14:10:25 +0100
|
||||||
|
|
||||||
tor (0.0.1+0.0.2pre23-1) unstable; urgency=low
|
tor (0.0.1+0.0.2pre23-1) unstable; urgency=low
|
||||||
|
|
||||||
|
|
69
debian/tor.init
vendored
69
debian/tor.init
vendored
|
@ -1,26 +1,53 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
DAEMON=/usr/sbin/tor
|
DAEMON=/usr/sbin/tor
|
||||||
NAME=tor
|
NAME=tor
|
||||||
DESC="tor daemon"
|
DESC="tor daemon"
|
||||||
TORLOG=/var/log/tor/log
|
TORLOG=/var/log/tor/log
|
||||||
TORPID=/var/run/tor/tor.pid
|
TORPID=/var/run/tor/tor.pid
|
||||||
|
DEFAULTSFILE=/etc/default/$NAME
|
||||||
|
WAITFORDAEMON=10
|
||||||
ARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
|
ARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
|
||||||
|
|
||||||
test -x $DAEMON || exit 0
|
test -x $DAEMON || exit 0
|
||||||
|
|
||||||
# Include tor defaults if available
|
# Include tor defaults if available
|
||||||
if [ -f /etc/default/tor ] ; then
|
if [ -f $DEFAULTSFILE ] ; then
|
||||||
. /etc/default/tor
|
. $DEFAULTSFILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
wait_for_deaddaemon () {
|
||||||
|
pid=$1
|
||||||
|
sleep 1
|
||||||
|
if test -n "$pid"
|
||||||
|
then
|
||||||
|
if kill -0 $pid 2>/dev/null
|
||||||
|
then
|
||||||
|
echo -n "."
|
||||||
|
cnt=0
|
||||||
|
while kill -0 $pid 2>/dev/null
|
||||||
|
do
|
||||||
|
cnt=`expr $cnt + 1`
|
||||||
|
if [ $cnt -gt $WAITFORDAEMON ]
|
||||||
|
then
|
||||||
|
echo " FAILED."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
echo -n "."
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ "$RUN_DAEMON" != "yes" ]; then
|
if [ "$RUN_DAEMON" != "yes" ]; then
|
||||||
echo "Not starting $DESC (Disabled in /etc/default/tor)."
|
echo "Not starting $DESC (Disabled in $DEFAULTSFILE)."
|
||||||
else
|
else
|
||||||
echo -n "Starting $DESC: "
|
echo -n "Starting $DESC: "
|
||||||
start-stop-daemon --start --quiet --oknodo \
|
start-stop-daemon --start --quiet --oknodo \
|
||||||
|
@ -32,14 +59,36 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping $DESC: "
|
echo -n "Stopping $DESC: "
|
||||||
start-stop-daemon --stop --quiet --oknodo --pidfile $TORPID \
|
pid=`cat $TORPID 2>/dev/null` || true
|
||||||
--exec $DAEMON
|
if test ! -f $TORPID -o -z "$pid"
|
||||||
echo "$NAME."
|
then
|
||||||
|
echo "not running (there is no $TORPID)."
|
||||||
|
elif start-stop-daemon --stop --quiet --pidfile $TORPID --exec $DAEMON
|
||||||
|
then
|
||||||
|
wait_for_deaddaemon $pid
|
||||||
|
echo "$NAME."
|
||||||
|
elif kill -0 $pid 2>/dev/null
|
||||||
|
then
|
||||||
|
echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
|
||||||
|
else
|
||||||
|
echo "FAILED ($DAEMON died: process $pid not running)."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
reload|force-reload)
|
reload|force-reload)
|
||||||
echo "Reloading $DESC configuration."
|
echo -n "Reloading $DESC configuration: "
|
||||||
start-stop-daemon --stop --signal 1 --oknodo --quiet --pidfile $TORPID \
|
pid=`cat $TORPID 2>/dev/null` || true
|
||||||
--exec $DAEMON
|
if test ! -f $TORPID -o -z "$pid"
|
||||||
|
then
|
||||||
|
echo "not running (there is no $TORPID)."
|
||||||
|
elif start-stop-daemon --stop --signal 1 --quiet --pidfile $TORPID --exec $DAEMON
|
||||||
|
then
|
||||||
|
echo "$NAME."
|
||||||
|
elif kill -0 $pid 2>/dev/null
|
||||||
|
then
|
||||||
|
echo "FAILED (Is $pid not $NAME? Is $DAEMON a different binary now?)."
|
||||||
|
else
|
||||||
|
echo "FAILED ($DAEMON died: process $pid not running)."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
|
Loading…
Add table
Reference in a new issue