Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > b9f8d43f832eefee980a2cd70b9fef6a > files > 4

gofer-0.54-1.fc14.noarch.rpm

#!/bin/bash
# goferd         This shell script controls the gofer daemon.
# Author:       Jeff Ortel <jortel@redhat.com>
# chkconfig:    345 97 2
# description:  Gofer agent responds to commands from gofer server.
# processname:  python
#

. /etc/init.d/functions

BINDIR=/usr/bin
PROG=goferd
LOCK=/var/lock/subsys/$PROG
PID=/var/run/$PROG.pid

start() {
  if [ -e $PID ]; then
    pid=$(cat $PID)
  fi
  kill -0 $pid >/dev/null 2>&1
  RETVAL=$?
  if [ $RETVAL -eq "0" ]; then
    echo "$PROG ($pid) already running."
    return $RETVAL
  fi
  echo -n "Starting $PROG"
  $BINDIR/$PROG
  RETVAL=$?
  if [ $RETVAL -eq "0" ]; then
    touch $LOCK
    success
  else
    failure
  fi
  echo
  return $RETVAL
}

stop() {
  echo -n "Stopping $PROG"
  if [ -e $PID ]; then
    pid=$(cat $PID)
  fi
  kill -9 $pid >/dev/null 2>&1
  RETVAL=$?
  if [ $RETVAL -eq "0" ]; then
    rm -f $LOCK
    success
  else
    failure
  fi
  echo
  return $RETVAL
}

status() {
  if [ -e $PID ]; then
    pid=$(cat $PID)
  fi
  kill -0 $pid >/dev/null 2>&1
  RETVAL=$?
  if [ $RETVAL -eq "0" ]; then
    echo "$PROG ($pid) is running."
  else
    echo "$PROG is not running."
  fi
}

restart() {
  stop
  sleep 2
  start
}

case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  restart)
  restart
  ;;
  status)
  status
  ;;
  *)
  echo $"Usage: $0 {start|stop|status|restart|}"
  exit 1
esac

exit $RETVAL