#! /bin/sh
# Copyright (c) 2003 Sun Microsystems, Inc.
#
# Author: Hidetoshi Tajima <hidetoshi.tajima@sun.com>
#
# /etc/init.d/iiimd for Common Linux system
#
### BEGIN INIT INFO
# Provides:       iiimd
# Required-Start: $network
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:   Internet/Intranet Input Method server.
### END INIT INFO

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

IIIMD="/usr/lib/iiim/iiimd-watchdog"
LOCKER="/var/lock/subsys/iiimd"
OPTIONS=""
RETVAL=0

test -x $IIIMD || exit 5

# First reset status of this service
rc_reset

start() {
        echo -n $"Starting iiimd"
	touch $LOCKER
        startproc $IIIMD $OPTIONS > /dev/null 2>&1 || rc_failed
	RETVAL=$?
        rc_status -v    
}

stop() {
        echo -n "Stopping iiimd"
	killproc iiimd || rc_failed
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f $LOCKER
        rc_status -v
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        echo -n "Checking iiimd"
        rc_status -v
        ;;
  restart|reload)
        stop
	rc_reset
        start
        ;;
  condrestart)
        if [ -f /var/lock/subsys/iiimd ]; then
            stop
            start
        fi
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL


rc_exit
