Mandriva FreeB service

bradymiller wrote on Friday, March 24, 2006:

hi,
Here’s a service script that will work on Mandriva.
I ended up just starting the freeb service without the daemon command. The start, status, stop, and restart commands all seem to work. It also works during computer startup. Not sure where to put this, figured the developer thread would be the best place.

#! /bin/bash
#
# freeb          Start/Stop the freeb daemon.
#
# chkconfig: 345 92 8
# description: freeb is an insurance billing printing daemon that
#              works with the OpenEMR medical record software program
# processname: freeb
# pidfile: /var/run/freeb.pid
#
# Above pidfile will NOT be made
#

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

# Some  defaults
freeb="/usr/share/freeb/bin/FreeB_Server.pl"
prog="freeb"
RETVAL=0

start() {
    gprintf "Starting %s: " "$prog"
    #NO pid file will be made
    $freeb & < /dev/null
    echo "                   [homemade OK]"
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/freeb
    return $RETVAL
}

stop() {
    gprintf "Stopping %s: " "$prog"
    killproc $freeb
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/freeb
    return $RETVAL
}   

rhstatus() {
    status $freeb
}   

restart() {
      stop
    start
}   

case "$1" in
  start)
      start
    ;;
  stop)
      stop
    ;;
  restart)
      restart
    ;;
  status)
      rhstatus
    ;;
  *)
    gprintf "Usage: %s {start|stop|restart}\n" "$0"
    exit 1
esac

exit $?