#!/bin/bash
# chkconfig: 2345 90 90
# description: Cloud Management Init Script

# Source function library.
. /etc/init.d/functions

RETVAL=0

start() {
	if [ -n "$(r1soft-cki --test-connection | grep "Connected successfully")" ]; then
		r1soft-cki
		/etc/init.d/buagent restart
	fi
	return ${RETVAL}
}	

stop() {
	return ${RETVAL}
}

status() {
	return ${RETVAL}
}

restart() {
	stop
	start
}	
reload()  {
	restart
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status
		;;
	restart)
		restart
		;;
	reload)
		reload
		;;
	*)
		echo "Usage: $0 {start|stop|status|restart|reload}"
		exit 2
esac

exit $?

exit 0
