#!/bin/sh
# chkconfig: 2345 90 10
# description: UTM Billing System Core

### BEGIN INIT INFO
# Provides: utm5_core
# Required-Start: $mysql $syslog
# Required-Stop: $mysql $syslog
# Should-Start: $network $time
# Should-Stop: $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: utm5_core
# Description: UTM Billing System Core
### END INIT INFO

trap '' 1 2 3 15

pid_file=/var/run/utm5_core.pid
utm_exec=safe_utm5_core
err_log=/netup/utm5/log/utm5_core.log
exec_dir=/netup/utm5/bin


case "$1" in
start)
        if [ -x $exec_dir/$utm_exec ]; 
		then
            echo "Starting utm5_core"
			$exec_dir/$utm_exec start &
		else
			echo $exec_dir/$utm_exec no such file
        fi
		;;
stop)
        echo "Stopping utm5_core"
	if [ `uname` = 'SunOS' ]
	then
            pkill -SIGTERM -x utm5_core
            sleep 7
            pkill -9 -x safe_utm5_core
            pkill -9 -x utm5_core
	else
            killall -SIGTERM utm5_core
            sleep 7
            kill -9 `ps ax | grep utm5_core | grep -v stop | grep safe | awk '{print $1}'` 2>/dev/null
            killall -9 utm5_core
	fi
        ;;
*)
        echo "Usage: `basename $0` {start|stop}" >&2
        exit 64
        ;;
esac
