summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-06-06 10:04:47 +0000
committerPeter Palfrader <peter@palfrader.org>2003-06-06 10:04:47 +0000
commitee38573c402333971e7cf873b2fbcd1865206505 (patch)
treebed93e7ffc4bf2108ced79ccfda0267c65296546
parent62c859444ceb4401f6e73c48f4d6035f26646830 (diff)
Remove random command invocation via pingctr/init script. People should just call pingd directly
-rwxr-xr-xdebian/echolot.init24
-rwxr-xr-xtools/pingctl59
2 files changed, 48 insertions, 35 deletions
diff --git a/debian/echolot.init b/debian/echolot.init
index 3916ddc..616aa2b 100755
--- a/debian/echolot.init
+++ b/debian/echolot.init
@@ -44,9 +44,9 @@ wait_for_deaddaemon () {
sleep 2
echo -n "."
done
- rm -f /var/run/echolot/pingd.pid
+ rm -f $PIDFILE
else
- rm -f /var/run/echolot/pingd.pid
+ rm -f $PIDFILE
fi
fi
}
@@ -134,26 +134,6 @@ reload|force-reload|restart)
wait_for_deaddaemon $PID
$0 start
;;
-process|add|delete|set|setremailercaps|deleteremailercaps|getkeyconf|sendpings|sendchainpings|buildstats|buildkeys|buildthesaurus|buildfromlines|dumpconf|summary)
- # Check for right User
- SU=""
- if [ "$CHECKUID" -gt "0" ]; then
- CUID=`id -u`
- CUIDNAME=`id -nu`
- if [ "$CUIDNAME" = "$USER" ]; then
- SU=""
- elif [ "$CUID" = "0" ]; then
- SU="su $USER -c"
- else
- echo "You are neither $USER nor root. Aborting." >&2
- exit 1;
- fi
- fi
-
- echo "Running $DESC: $NAME $1..."
- $SU $DAEMON "$@"
- echo "done."
- ;;
*)
echo "Usage: $0 (start|stop|reload|force-reload|restart)" >&2
echo " $0 <COMMAND> [parameters]" >&2
diff --git a/tools/pingctl b/tools/pingctl
index 9304734..ba99c19 100755
--- a/tools/pingctl
+++ b/tools/pingctl
@@ -10,7 +10,9 @@ set -e
USER=pinger
VERBOSE=0
-PINGD="/home/pinger/echolot/pingd"
+BASEDIR="/home/pinger/echolot"
+PINGD="$BASEDIR/pingd"
+PIDFILE="$BASEDIR/pingd.pid"
# You probably don't want to mess with stuff below this line
################################################################
@@ -18,6 +20,35 @@ PINGD="/home/pinger/echolot/pingd"
CHECKULIMIT=1
CHECKUID=1
+
+wait_for_deaddaemon () {
+ PID=$1
+ sleep 3
+ if test -n "$PID"
+ then
+ if kill -0 $PID 2>/dev/null
+ then
+ echo -n "Waiting for pid $PID ."
+ cnt=0
+ while kill -0 $PID 2>/dev/null
+ do
+ cnt=`expr $cnt + 1`
+ if [ $cnt -gt 30 ]
+ then
+ echo -n " Failed.. "
+ break
+ fi
+ sleep 2
+ echo -n "."
+ done
+ rm -f $PIDFILE
+ else
+ rm -f $PIDFILE
+ fi
+ fi
+}
+
+
# Check for evil ulimits
if [ "$CHECKULIMIT" -gt "0" ]; then
FDs=`ulimit -n`
@@ -70,6 +101,18 @@ fi
case $1 in
start)
+ if [ -f $PIDFILE ] ; then
+ PID=`cat $PIDFILE 2>/dev/null` || true
+ if kill -0 $PID 2>/dev/null
+ then
+ echo "pingd already running."
+ exit 0
+ else
+ echo -n "Removing stale pid file: "
+ rm -f $PIDFILE
+ echo "$PIDFILE."
+ fi
+ fi
echo -n "Starting Echolot: pingd"
if [ ! -z "$SU" ]; then
$SU "$PINGD --detach $VERBOSE start"
@@ -90,23 +133,13 @@ stop)
;;
reload|force-reload|restart)
+ PID=`cat $PIDFILE 2>/dev/null` || true
$0 stop
- sleep 10
+ wait_for_deaddaemon $PID
$0 start
;;
-process|add|delete|set|setremailercaps|deleteremailercaps|getkeyconf|sendpings|sendchainpings|buildstats|buildkeys|buildthesaurus|buildfromlines|dumpconf|summary)
- echo "Running pingd $1..."
- if [ ! -z "$SU" ]; then
- $SU "$PINGD \"$@\""
- else
- $PINGD "$@"
- fi
- echo "done."
- ;;
*)
echo "Usage: $0 (start|stop|reload|force-reload|restart)" >&2
- echo " $0 <COMMAND> [parameters]" >&2
- echo "See the pingd(1) manual page for valid commands" >&2
exit 1
;;
esac