#!/bin/sh

NUM=1
file="/tmp/LanIPchange"
fw_file="/tmp/firmwareUpdate"
time_file="/tmp/webtimeset"
bbmd_restart_file="/tmp/restart-bbmd"
bbmd_signal_file="/tmp/signal-bbmd"
bbmd_pid_file="/tmp/bbmd.pid"

#check if settings change file exists

while [ $NUM -eq 1 ]; do
	if [ -e $file ]
	then
		sleep 5
		/app/scripts/reboot
	elif [ -e $fw_file ]
	then
		sleep 5
		mv /tmp/apps_EIGRVB_ver*.tgz /tmp/apps.tgz
		/app/scripts/setup-notftp.sh
		sleep 1	
		/app/scripts/reboot
	elif [ -e $time_file ] # set time
	then
		/tmp/webtimeset
		rm $time_file
		hwclock -w &
		sleep 2
	elif [ -e $bbmd_restart_file ]
	then
		rm $bbmd_restart_file $bbmd_signal_file
                pid_value=$(cat $bbmd_pid_file)         
                # kill the bbmd application
                kill -9 $pid_value
                sleep 1
                /app/bin/bbmd &
                sleep 2
	elif [ -e $bbmd_signal_file ]
	then
		rm $bbmd_signal_file
                pid_value=$(cat $bbmd_pid_file)
                kill -SIGHUP $pid_value
                sleep 2
	else
		sleep 2
	fi
done






