#!/bin/bash
# $Id: freepopsd,v 1.1 2005/06/27 05:16:40 simo Exp $

# source application-specific settings
[ -f /etc/conf.d/freepopsd ] && . /etc/conf.d/freepopsd

# general config
. /etc/rc.conf
. /etc/rc.d/functions

PID=`pidof -o %PPID /usr/bin/freepopsd`
case "$1" in
  start)
    stat_busy "Starting Freepops Daemon"
    [ -z "$PID" ] && /usr/bin/freepopsd -d $FREEPOPSD_ARGS
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon freepopsd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Freepops Daemon"
    [ ! -z "$PID" ]  && /usr/bin/freepopsd -k &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon freepopsd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
