1

I'm somewhat new to Linux and OpenXCAP and I'm trying to make an init.d script for OpenXCAP on CentOS 6.

My script can start and stop OpenXCAP service, but it returns this error for the status command (service openxcap status): openxcap dead but subsys locked

Maybe somebody can tell me if problem is in the init.d script or the openxcap service itself? Is openxcap missing some 'give-status' feature?

#!/bin/bash
#
# Startup script for OpenXCAP
#
# processname: openxcap
# pidfile: /var/run/openxcap/openxcap.pid
# chkconfig: - 85 15
# description: start, stop, restart OpenXCAP server
#
### BEGIN INIT INFO
# Provides: openxcap
# Required-Start: $local_fs $network
# Should-Start: mysqld
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

APP_NAME=openxcap
APP_HOME=/usr/local/src/openxcap-2.0.1
PID_PATH=/var/run/openxcap/openxcap.pid
RETVAL=0

[ -f /etc/sysconfig/$APP_NAME ] && . /etc/sysconfig/$APP_NAME

start()
{
        echo -n $"Starting $APP_NAME: "
        daemon $APP_HOME/$APP_NAME $OPTIONS 2>/dev/null | tail -1
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/$APP_NAME
}

stop()
{
        echo -n $"Stopping $APP_NAME: "
        killproc -p $PID_PATH
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$APP_NAME $PID_PATH
}

# See how we were called.
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
                status $APP_NAME
                RETVAL=$?
                ;;
        restart|reload)
                stop
                start
                ;;
        *)
                echo $"Usage: $APP_NAME {start|stop|reload|restart|status|help}"
                exit 1
esac

exit $RETVAL
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
kalabic
  • 11
  • 1

1 Answers1

0

You are (hopefully) writing out a PID file as /var/run/openxcap/openxcap.pid.

I suspect that your program is writing out one PID, but then starting another process. The first process dies, so sysvinit doesn't know to look for a different one.

However, the lock file indicating that your process was started is still present.

You may not be able to directly use the daemon function for starting this program; you might need to create a customized version that is “smart enough” to identify the correct PID.

BRPocock
  • 13,638
  • 3
  • 31
  • 50
  • Hi @BRPocock, first sorry for late reply. Now regarding the issue itself, this OpenXCAP service is a python application and maybe there is solution for this problem for python apps in general. I just haven't found it yet. And not to mention that this OpenXCAP project didn't see any updates for a while and I am considering dropping it from my project. – kalabic Jun 18 '12 at 13:53