1. #!/bin/bash
  2.  
  3.  . /etc/rc.conf
  4.  . /etc/rc.d/functions
  5.  PID=`pidof -o %PPID /usr/sbin/mongoose`
  6.  
  7.  case "$1" in
  8.      start)
  9.        stat_busy "Starting mongoose http server"
  10.        /usr/sbin/mongoose /etc/mongoose/mongoose.conf 2> /dev/null >/dev/null &
  11.        if [ $? -gt 0 ]; then
  12.            stat_fail
  13.        else
  14.            add_daemon mongoose
  15.            stat_done
  16.        fi
  17.        ;;
  18.      stop)
  19.        stat_busy "Stopping mongoose http server"
  20.        [ ! -z "$PID" ] && kill $PID &>/dev/null
  21.        if [ $? -gt 0 ]; then
  22.            stat_fail
  23.        else
  24.            rm_daemon mongoose
  25.            stat_done
  26.        fi
  27.        ;;
  28.      restart)
  29.        $0 stop
  30.        sleep 5
  31.        $0 start
  32.        ;;
  33.      *)
  34.        echo "Usage $0 {start|stop|restart}"
  35.        ;;
  36.  esac