#!/bin/sh

#
# Main ISP20 Application Control Shell
#

cd /root/
CURDIR=./
APP=isp20.et3

echo >/dev/console
echo "ISP20 Linux environment" >/dev/console
echo >/dev/console

function background_loop {
	while true
	do

		# Loop here as long as there is an application file
		while [ -f "$CURDIR$APP" ]
		do

			echo OUTPUT_REDIRECT
			echo "$APP exists - run it" OUTPUT_REDIRECT
			echo OUTPUT_REDIRECT
			
			chmod 777 $CURDIR$APP
			$CURDIR$APP
			RETVAL=$?

			echo OUTPUT_REDIRECT
			echo "$APP exits with return value $RETVAL" OUTPUT_REDIRECT
			echo OUTPUT_REDIRECT

		done

		echo
		echo "$APP doesn't exist"
		echo

		# No application file available - launch a login shell on the console
		/sbin/getty -L  console 0 vt100

	done
}

# Launch the background loop using the console for I/O
background_loop </dev/console >/dev/console 2>&1 &
