#! /bin/sh
# Copyright (c) 2001 SuSE Gmbh Nueremberg, Germany. All rights reserved.
# Adapted by W.Soeker, Cleware GmbH
#
# <info@cleware.de>
#
### BEGIN INIT INFO
# Provides:       send2cc
# Required-Start: usb-service
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    initscript for the ClewareControl services
### END INIT INFO
#
# init.d/send2cc

. /etc/rc.config

SEND2CC_BIN=/usr/sbin/send2cc
CCSERVERNAME=Benny

if [ ! -x $SEND2CC_BIN ] ; then
       echo -n "send2cc demon not installed ! "
       exit 5
fi

# The echo return value for success (defined in /etc/rc.config).
#return=$rc_done

. /etc/rc.status
rc_reset


case "$1" in
    start)
        echo -n "Starting ClewareControl service"
        checkproc $SEND2CC_BIN
        if [ $? -eq 0 ] ; then
          echo -n "  Warning: send2cc already running! "
        fi
        startproc $SEND2CC_BIN -s $CCSERVERNAME -r
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down ClewareControl service"
	checkproc $SEND2CC_BIN || echo -n "  Warning: send2cc not running! "
	killproc -TERM $SEND2CC_BIN
	rc_status -v
	;;
    try-restart)
       $0 stop  &&  $0 start
       rc_status
       ;;
    restart)
       $0 stop
       $0 start
       rc_status
       ;;
    force-reload)
       $0 reload
       rc_status
       ;;
    reload)
       echo -n "Reloading ClewareControl service"
       checkproc $SEND2CC_BIN || echo -n "  Warning: send2cc not running! "
       killproc -HUP $SEND2CC_BIN
       rc_status -v
       ;;
    status)
       echo -n "Checking for ClewareControl service"
       checkproc $SEND2CC_BIN
       rc_status -v
       ;;
    probe)
       test echo reload
       ;;
    *)
       echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
       exit 1
       ;;
esac
rc_exit
