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

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

mesg n

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

s5=${s1##*event}

s2=`expr ${s5}`

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

cd /root/bin-AOI

file="newupdate.tar.gz"
tardir="./newupdate"
cammerdir="cammer*"
fileupdate="./update.sh"
if [ -f $file ]
then
    rm -rf $tardir 
    mkdir $tardir
    tar -zxvf $file -C $tardir
    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 -f $file
    rm -rf $tardir 
fi

mkdir -p /root/bin-AOI/cnt_net/cnt_log
python3.4 ./cnt_net/upnetcard.py >> /root/bin-AOI/cnt_net/cnt_log/pylog.log

rmmod pinctrl_sunrisepoint
mknod /dev/led c 233 0
insmod led.ko

sleep 6s

#chktime
timefile="use_chk_server_time"
if [ -f $timefile ]
then
    serverip=$(cat $timefile)
    cp /usr/share/zoneinfo/GMT /etc/localtime
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    ntpdate $serverip &
    rm -f $timefile
fi

#update reboot
rebootfile="need_reboot_by_update"
if [ -f $rebootfile ]
then
    rm -f $rebootfile
    reboot
fi

./application -qws











