#!/bin/sh
#

RUNNINGAPPSDIR=/ross/app/bin
RUNNINGAPPSDIRCONFIGPATH=/ross/etc/runningAppsPath
HP="$RUNNINGAPPSDIR"/ultrix_hotplugd

if [ -f "$RUNNINGAPPSDIRCONFIGPATH" ]; then
        RADPATH=$(cat $RUNNINGAPPSDIRCONFIGPATH)
        if [ -d "$RADPATH" ]; then
                RUNNINGAPPSDIR=$RADPATH
        fi
fi

HP="$RUNNINGAPPSDIR"/ultrix_hotplugd
MV="$RUNNINGAPPSDIR"/mv_control

do_max_fans() {
	#set ns fans to 100 % during wait.
	devmem 0x8aa00800 32 0xffffff
	devmem 0x8aa00204 32 0xffffff
	echo -e "Fans set to 100%\n"  | logger -p local4.notice -t rrti-init 
}

start() {
	$HP -m -p $$
}

stop() {
	echo -n "Stopping hotplug service: "
	killall ultrix_hotplugd
	echo "Done."
}

restart() {
	stop
	start
}

case "$1" in
	start)
	do_max_fans | logger -p local4.notice -t startup-init 
	start
	;;
	stop)
	stop
	;;
	restart|reload)
	restart
	;;
	*)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac

exit $?
