#!/bin/bash
echo " Main Restart Script...."
sleep 10
while true 
do 
	sleep 2
	if [ -f "/home/root/b110_update.tar" ]; then
		exit
	else
		if pgrep b110_main > /dev/null 
		then
			:
		else
			if [ -f "/home/root/b110_update.tar" ]; then
				exit
			else
				if [ -f "/var/tmp/main.bn" ]; then
					echo "b110_main stopped -> restart"
					sleep 2
					cd /var/tmp
					killall b110_main > /dev/null
					rm /var/tmp/main.bn
					sync
					./b110_main > /dev/null&
				 fi
			 fi
		fi
	fi
done
