powered by Jive Software

Wrong status in init script

A fragment from the rpm init script:

status() {

pid=cat $OPENFIRE_PIDFILE 2>&1

if [ “$?” = “1” ]; then

echo “openfire is not running”

RETVAL=0

else

ps -p $pid > /dev/null 2>&1

if [ “$?” = “0” ]; then

echo “openfire is running”

RETVAL=0

else

echo “openfire is not running”

RETVAL=0

fi

fi

}

I believe that’s wrong, only the second RETVAL should be 0.

I must admit that I’ve not looked into the init scripts myself. Is there any kind of specification that describes what the exit status for init scripts should be in each condition? One could argue that the script itself ran just fine, which could explain the exit 0.

According to http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/in iscrptact.html , this code should be:

status() {

pid=cat $OPENFIRE_PIDFILE 2>&1

if [ “$?” = “1” ]; then

echo “openfire is not running”

RETVAL=3

else

ps -p $pid > /dev/null 2>&1

if [ “$?” = “0” ]; then

echo “openfire is running”

RETVAL=0

else

echo “openfire is not running”

RETVAL=1

fi

fi

}

Coinsidently, someone else also checked in LSB-related changes. I piggybacked on the same issue: OF-433. The changes that you propose have been applied. Note that this does not make the script fully LSB compliant - other functionality is still missing.