can i use this script without having daemon service

uknet80
uknet80 used Ask the Experts™
on
I have this script below, i don't have daemon service on my system and can't find any for it.
is it posible to run this script without having daemon command


#!/bin/bash
USER=koha
GROUP=koha
DBNAME=koha
NAME=koha-zebra-ctl.$DBNAME
LOGDIR=/var/log/koha
ERRLOG=$LOGDIR/koha-zebradaemon.err
STDOUT=$LOGDIR/koha-zebradaemon.log
OUTPUT=$LOGDIR/koha-zebradaemon-output.log
KOHA_CONF=/etc/koha/koha-conf.xml
RUNDIR=/var/run/koha/zebradb
LOCKDIR=/var/lock/koha/zebradb
# you may need to change this depending on where zebrasrv is installed
ZEBRASRV=/usr/bin/zebrasrv
ZEBRAOPTIONS="-v none,fatal,warn"

test -f $ZEBRASRV || exit 0

OTHERUSER=''
if [[ $EUID -eq 0 ]]; then
    OTHERUSER="--user=$USER.$GROUP"
fi

case "$1" in
    start)
      echo "Starting Zebra Server"

      # create run and lock directories if needed;
      # /var/run and /var/lock are completely cleared at boot
      # on some platforms
      if [[ ! -d $RUNDIR ]]; then
        umask 022
        mkdir -p $RUNDIR
        if [[ $EUID -eq 0 ]]; then
            chown $USER:$GROUP $RUNDIR
        fi
      fi
      if [[ ! -d $LOCKDIR ]]; then
        umask 022
        mkdir -p $LOCKDIR
        mkdir -p $LOCKDIR/biblios
        mkdir -p $LOCKDIR/authorities
        if [[ $EUID -eq 0 ]]; then
            chown -R $USER:$GROUP $LOCKDIR
        fi
      fi

      daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $ZEBRASRV $ZEBRAOPTIONS -f $KOHA_CONF
      ;;
    stop)
      echo "Stopping Zebra Server"
      daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --stop -- $ZEBRASRV -f $KOHA_CONF
      ;;
    restart)
      echo "Restarting the Zebra Server"
      daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --restart -- $ZEBRASRV -f $KOHA_CONF
      ;;
    *)
      echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
      exit 1
      ;;

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
Commented:
did you try running it from command line?
You have to make significant changes to it to make it run as without being a daemon service.

You will have to get rid of daemon keyword along with its parameters.  But why would you do that?  What are you trying to accomplish?  This is a service script and that specific purpose.  Without being a daemon would make it purpose less.
Top Expert 2011
Commented:
As root, copy this script, say. zebrasrv, into /etc/init.d, then
# chmod +x /etc/init.d/zebrasrv   # make the script executable
# chkconfig add zebrasrv     # add the script into service
# chkconfig --level 35 zebrasrv  # make the script/service run at boot up for runlevel 3 and 5

Now, you can try to use
# service zebrasrv start
to start the daemon.

Author

Commented:
thanks, managed to compile Daemon, initially I couldn't find a source code for my RHEL5

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial