#!/bin/sh
#
#   "SystemImager"
#
#   Copyright (C) 2002-2004  Brian Elliott Finley
#
#   $Id: systemimager-server-netbootmond 4121 2007-08-04 17:29:41Z arighi $
#
#
# Support for IRIX style chkconfig:
# chkconfig:   2345 20 20
# description: The SystemImager si_netbootmond daemon.
#
#
# Support for LSB compliant init system:
### BEGIN INIT INFO
# Provides: systemimager-server-netbootmond
# Required-Start: $network $syslog
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: SystemImager's daemon for net boot control
# Description: SystemImager's daemon for controlling netboot clients.
#              If clients are configured to always boot from the network, 
#              si_netbootmond can be configured to tell them to boot off their
#              local disks each time they boot after having completed a 
#              successful autoinstall.
### END INIT INFO


PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:
PIDFILE=/var/run/si_netbootmond.pid

case "$1" in
  start)
    echo -n "Starting SystemImager's net boot client monitor: "
    si_netbootmond
    if pgrep si_netbootmond >/dev/null 2>&1; then
        echo "ok."
        exit 0
    else
        echo "failed."
        exit 1
    fi
    ;;
  stop)
    echo -n "Stopping SystemImager's net boot client monitor: "
    [ -f $PIDFILE ] && kill `cat $PIDFILE 2>/dev/null`
    if [ $? -eq 0 ]; then
        echo "ok."
        exit 0
    else
        echo "failed."
        exit 1
    fi
    ;;
  status)
    echo -n "Status of SystemImager's net boot client monitor: si_netbootmond... "
    ([ -f $PIDFILE ] && ps -p `cat $PIDFILE` >/dev/null 2>&1 && echo "running." && exit 0) || (echo "not running." && exit 1)
    ;;
  reload)
    echo "Not implemented."
    ;;
  force-reload|restart)
    sh $0 stop
    sh $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart}"
    exit 1
    ;;
esac

