#!/bin/env sh

logger "SNG: Triggering USB CLI Service"
getty_command_line="/sbin/agetty -L 115200 usb_attached_console vt100"

sleep 2
while [ 1 ] 
do 
		 if [ ! -e /dev/usb_attached_console ]; then
		 	#logger "SNG: No /dev/usb_attached_console"
			break;
		 fi
		 if [ $(/usr/bin/pgrep -xf "${getty_command_line}" | /usr/bin/wc --lines) -ne 0 ]; then
			break;
		 fi

		 logger "SNG: Starting USB CLI Service: ${getty_command_line}"
         eval "nice ${getty_command_line} "
done

exit 0
