[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Problem with init script.. :-[



Hi all,

Since I'm not that great in bash, I would like to ask for some help.
I wrote a script that will kill all instances of yiff-server (new one,
not yet in unstable as I have this problem).

Each yiff instance makes a pid file as follows:

/var/run/yiff-<port number>.pid

with PID in the file.

Here's my stop) part of yiff-server:

NAME=yiff
<snip>
  stop)
        echo -n "Stopping $DESC":
        k=`ls /var/run/$NAME*.pid 2>/dev/null`
        for i in non $k; do
                if [ "$i" != non ]; then
                        kill `cat $i` 2> /dev/null;
                        rm -f $i;
                fi;
        done;
        echo "$NAME."
        ;;


It works, _BUT_ if no server is running, it bails out on me
so people can't upgrade if they have yiff-server installed
but not running.

If I try to check if pid file exists in first place by,

if [ -e /var/run/$NAME*.pid ]; then blah blah

I get error if more than one pid file is there.


How can I detect if the file(s) exist without causing
the init script to bail out??


Thanks in advance,
Adam



Reply to: