# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    fi
fi

mesg n

sleep 2s

export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal

s3='TSLIB_TSDEVICE=/dev/input/event'
s4='QWS_MOUSE_PROTO=Tslib:/dev/input/event'

s1=$(cat /proc/bus/input/devices | grep -A4 'TouchController"')

if [ -z ${s1}]
then
	s1=$(cat /proc/bus/input/devices | grep -A4 'PenMount')
fi

if [ -z ${s1}]
then
	s1=$(cat /proc/bus/input/devices | grep -A4 'HID')
fi

if [ -z ${s1}]
then
	index=1
	while [ $index -lt 3 ]
	do
		s1=$(cat /proc/bus/input/devices | grep -m$index -A4 'ILITEK-TP')
		chk=${s1##*event}
		if [[ $chk =~ "js" ]]
		then
			let index++
			continue
		else
			break
		fi
		let index++
	done
fi

s5=${s1##*event}
s5=${s5%%?js*}

s2=`expr ${s5}`

export ${s3}${s2}
export ${s4}${s2}

cd /root/bin-AOI
chmod -R 777 *

#>>>>>>>>>>>>>>>>>>>>update>>>>>>>>>>>>>>>>>>>>
file_gz="newupdate.tar.gz"
file_rar="newupdate.rar"
file_xz="newupdate.tar.xz"
tardir="./newupdate"
cammerdir="cammer*"
fileupdate="./update.sh"

isfindupdate=0
if [ -f $file_gz -o -f $file_rar -o -f $file_xz ];
then
    rm -rf $tardir 
    mkdir $tardir
	isfindupdate=$[$isfindupdate+1]
	
	if [ -f $file_xz ];	#tar.xz
	then
		tar -Jxvf $file_xz -C $tardir
		rm -f $file_xz
	elif [ -f $file_rar ];	#rar
	then
		mv $file_rar $tardir
		cd $tardir
		rar x $file_rar
		rm -f $file_rar
	elif [ -f $file_gz ];	#tar.gz
	then
		tar -zxvf $file_gz -C $tardir
		rm -f $file_gz
	fi
fi

cd /root/bin-AOI
if [ $isfindupdate == 1 ];
then
	chmod -R 777 *
    if ls $tardir/$cammerdir > $tardir/cam 2>&1;then
    rm -rf $cammerdir
    rm -rf $tardir/cam
    fi
    cp -rf $tardir/* ./
    if [ -f $fileupdate ];
    then
        $fileupdate
        cd /root/bin-AOI
        rm -f $fileupdate
    fi
    rm -rf $tardir
fi
#<<<<<<<<<<<<<<<<<<<<update<<<<<<<<<<<<<<<<<<<<

cd /root/bin-AOI
rmmod pinctrl_sunrisepoint
mknod /dev/led c 233 0
insmod led.ko

#>>>>>>>>>>>>>>>>>>>>special_action>>>>>>>>>>>>>>>>>>>>
#执行特殊脚本
cd /root/bin-AOI
framerun="framerun.sh"
if [ -f $framerun ];
then 
    ./$framerun
fi
rm -f $framerun
#更新时间
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#hwclock --hctosys 
#<<<<<<<<<<<<<<<<<<<<special_script<<<<<<<<<<<<<<<<<<<<

cd /root/bin-AOI
mkdir -p /root/bin-AOI/cnt_net/cnt_log
python3 ./cnt_net/bsymv20_upnetcard.py >> /root/bin-AOI/cnt_net/cnt_log/pylog.log

sleep 16s

./application -qws



























