Docs GODI Archive
Projects Blog Link DB

Search GODI:


More options
File doc/apps-umlmon/etc/init.d/umlmon GODI Package apps-umlmon
 
   umlmon  
#! /bin/sh

# LSB compliance:

### BEGIN INIT INFO
# Provides: umlmon
# Required-Start: $network $named $syslog $time
# Required-Stop: $network $named $syslog $time
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the UMLMON monitors
### END INIT INFO

prefix="/home/cityd/autobuild/3.10"
ua="$prefix/sbin/umladmin"
ud="$prefix/sbin/umldir"

start_dir () {
	start_dir=1
        if [ -f /var/run/umlmon/directory.pid ]; then
                pid=$(cat /var/run/umlmon/directory.pid)
                if kill -0 $pid >/dev/null 2>/dev/null; then
                        start_dir=0
                fi
        fi

	if [ $start_dir = 1 ]; then
		echo "  Starting umldir"
		$ud 2>/dev/null
	fi
}

stop_dir () {
	if [ -f /var/run/umlmon/directory.pid ]; then
		pid=$(cat /var/run/umlmon/directory.pid)
		if kill -0 $pid >/dev/null 2>/dev/null; then
			:
		else
			echo "umldir is not running"
			return
		fi
	else
		echo "umldir is not running"
		return
	fi

	echo "  Shutting down umldir"
	kill $pid
}

try_restart_dir () {
	if [ -f /var/run/umlmon/directory.pid ]; then
		pid=$(cat /var/run/umlmon/directory.pid)
		if kill -0 $pid >/dev/null 2>/dev/null; then
			stop_dir
			start_dir
		else
			echo "umldir is not running"
			return
		fi
	else
 		echo "umldir is not running"
		return
	fi	
}

try_restart() {
	inactive="$($ua list -inactive)"
	active="$($ua list -active)"
	if [ -n "$inactive$active" ]; then
		echo "Stopping UMLMON"
		$ua stop
		echo "Starting UMLMON"
		$ua start
	else
		echo "umlmon is not running"
	fi
}

status() {
	status=0
	for pidfile in /var/run/umlmon/*.pid; do
		[ -f "$pidfile" ] || { status=3; break; }
		pid="$(cat "$pidfile")"
		if kill -0 $pid >/dev/null 2>/dev/null; then
			:
		else
			status=1
		fi		
	done
	exit $status
}

case "$1" in
    start)
        echo "Starting UMLMON"
        if [ "$#" = 1 ]; then
	    $ua start
	    start_dir
	else
	    $ua start "$2"
	fi
	;;
    stop)
        echo "Shutting down UMLMON"
        if [ "$#" = 1 ]; then
	    stop_dir
	    $ua stop
	else
	    $ua stop "$2"
	fi
	;;
    restart|force-reload)
        echo "Restarting UMLMON"
         if [ "$#" = 1 ]; then
	     stop_dir
	     $ua stop
	     $ua start
	     start_dir
	 else
	     $ua stop "$2"
	     $ua start "$2"
	 fi
	 ;;
    reload)
	exit 3
	;;
    try-restart)
	try_restart_dir
	try_restart
	;;
    status)
	status
	;;
    update)
        echo "Updating UMLMON monitors"
        if [ "$#" = 1 ]; then
	    $ua update
	else
	    $ua update "$2"
	fi
	;;
    *)
        echo "$0 (start|stop|restart|force-reload|try-restart|status|update) [vm_id]" >&2
	exit 1
	;;
esac

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml