Update of /cvsroot/devil-linux/build/config/etc/init.d
In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv23928/config/etc/init.d
Modified Files:
functions
Log Message:
- added siproxd 0.5.14 (Heiko / Roland Pabel)
- added support for pidfiles in /etc/init.d/functions for reloadproc,
killproc
and statusproc (Heiko / Roland Pabel)
- introduced a build configuration option to enable magic sysrq in the
kernel (Heiko / Roland Pabel)
Index: functions
===================================================================
RCS file: /cvsroot/devil-linux/build/config/etc/init.d/functions,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- functions 23 Dec 2003 16:05:33 -0000 1.11
+++ functions 18 Aug 2006 15:38:14 -0000 1.12
@@ -133,11 +133,16 @@
pidlist=$(pidof -o $$ -o $PPID -x $base)
}
+getpidfromfile()
+{
+ test -r $1 && pidlist=`cat $1`
+}
+
loadproc()
{
if [ $# = 0 ]
then
- echo "Usage: loadproc {program}"
+ echo "Usage: loadproc [-q] {program}"
exit 1
fi
@@ -163,16 +168,29 @@
{
if [ $# = 0 ]
then
- echo "Usage: killproc {program} [signal]"
+ echo "Usage: killproc [-q] [-p pidfile] {program} [signal]"
exit 1
fi
QUIET=""
- if [ "$1" = "-q" ]; then
- shift
- QUIET="yes"
- fi
-
+ PIDFILE=""
+ until [ -z "$1" ]
+ do
+ case "$1" in
+ "-q")
+ QUIET="yes"
+ shift
+ ;;
+ "-p")
+ PIDFILE=$2
+ shift 2
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
if [ -z "$2" ]; then
signal=TERM
fallback=KILL
@@ -182,7 +200,11 @@
fallback=""
fi
- getpids $1
+ if [ -n "$PIDFILE" ]; then
+ getpidfromfile $PIDFILE
+ else
+ getpids $1
+ fi
if [ -n "$pidlist" ]; then
failure=0
@@ -204,7 +226,13 @@
done
base=${1##*/}
- if [ $failure = 0 ]; then rm -f /var/run/$base.pid; fi
+ if [ $failure = 0 ]; then
+ if [ -n $PIDFILE ]; then
+ rm -f $PIDFILE
+ else
+ rm -f /var/run/$base.pid;
+ fi
+ fi
(exit $failure)
test -z "$QUIET" && evaluate_retval
@@ -218,9 +246,15 @@
{
if [ $# = 0 ]
then
- echo "Usage: reloadproc {program} [signal]"
+ echo "Usage: reloadproc [-p pidfile] {program} [signal]"
exit 1
fi
+
+ PIDFILE=""
+ if [ "$1" = "-p" ]; then
+ PIDFILE=$2
+ shift 2
+ fi
if [ -z "$2" ]; then
signal=HUP
@@ -230,7 +264,11 @@
fi
- getpids $1
+ if [ -n "$PIDFILE" ]; then
+ getpidfromfile $PIDFILE
+ else
+ getpids $1
+ fi
if [ -n "$pidlist" ]
then
@@ -253,20 +291,49 @@
{
if [ $# = 0 ]
then
- echo "Usage: statusproc {program}"
+ echo "Usage: statusproc [-p pidfile] {program}"
exit 1
fi
base=${1##*/}
- getpids $base
+
+ PIDFILE="/var/run/$base.pid"
+ if [ "$1" = "-p" ]; then
+ PIDFILE=$2
+ shift 2
+ fi
+
+ # check if pid file exists
+ PIDFILEEXISTS=0
+ if [ -s $PIDFILE ]; then
+ PIDFILEEXISTS=1
+ getpidfromfile $PIDFILE
+ PIDFILEPID=$pidlist
+ fi
+
+ # get pids of running processes
+ getpids $1
+
+ # compare pidfile to running processes
+ if [ $PIDFILEEXISTS = 1 ]; then
+ mypidlist=$pidlist
+ pidlist=;
+ for i in $mypidlist; do
+ if [ "$i" = "$PIDFILEPID" ]
+ then
+ pidlist=$PIDFILEPID
+ break
+ fi
+ done
+ fi
if [ -n "$pidlist" ]
then
echo "$base is running with Process ID(s) $pidlist"
else
- if [ -s /var/run/$base.pid ]
+ if [ -n $PIDFILEEXISTS ]
then
- echo "$1 is not running but /var/run/$base.pid exists"
+ echo "$1 is not running but $PIDFILE exists"
return 1
else
echo "$1 is not running"
|