Need help with custom init script

Posted by churnd on Server Fault See other posts from Server Fault or by churnd
Published on 2010-04-07T11:35:01Z Indexed on 2010/04/07 11:43 UTC
Read the original article Hit count: 355

Filed under:
|

I'm trying to set up an init script for a process on redhat linux:

#!/bin/sh
#
# Startup script for Conquest
#
# chkconfig: 345 85 15     - start or stop process definition within the boot process
# description: Conquest DICOM Server
# processname: conquest
# pidfile: /var/run/conquest.pid

# Source function library.      This creates the operating environment for the process to be started
. /etc/rc.d/init.d/functions

CONQ_DIR=/usr/local/conquest

case "$1" in
  start)
        echo -n "Starting Conquest DICOM server: "
        cd $CONQ_DIR && daemon --user mruser ./dgate -v                 - Starts only one process of a given name.
        echo
        touch /var/lock/subsys/conquest
        ;;
  stop)
        echo -n "Shutting down Conquest DICOM server: "
        killproc conquest
        echo
        rm -f /var/lock/subsys/conquest
        rm -f /var/run/conquest.pid      - Only if process generates this file
        ;;
  status)
        status conquest
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  reload)
        echo -n "Reloading process-name: "
        killproc conquest -HUP
        echo
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac

exit 0

However, the cd $CONQ_DIR is getting ignored, because the script errors out:

# ./conquest start
Starting Conquest DICOM server: -bash: ./dgate: No such file or directory
                                                           [FAILED]

For some reason, I have to run dgate as ./dgate. I cannot specify the full path /usr/local/conquest/dgate

The software came with an init script for a Debian system, so the script uses start-stop-daemon, with the option --chdir to where dgate is, but I haven't found a way to do this with the Redhat daemon function.

© Server Fault or respective owner

Related posts about init

Related posts about redhat