#!/bin/sh
echo "Damon shell run..."

one=1

while :
do
	bmcapp_cnt=`ps | grep -c bmc_app`
	if [ $bmcapp_cnt -le $one ];then
		echo "damon.sh restart bmc_app..."
		/usr/bin/bmc_app &
	fi

	goahead_cnt=`ps | grep -c goahead-3.6.5`
	if [ $goahead_cnt -le $one ];then
		echo "damon.sh restart goahead-3.6.5..."
		/usr/bin/goahead-3.6.5 -v --home /etc/goahead &
	fi

	ethRun_cnt=`ifconfig eth0 | grep -c RUNNING`
	if [ $ethRun_cnt -lt $one ];then
		ifconfig eth0 down up
	fi

	sleep 5

done
