#!/system/bin/sh


wget h http://down.pute.cn:7001/pdndevice_10188.zip -O /data/PdnDevice/pdndevice.zip
unzip /data/PdnDevice/pdndevice.zip

rm /data/PdnDevice/keepantv2.sh
pkill keepantv2
sleep 5
pkill keepantv2
sleep 5
pkill keepantv2
sleep 10
echo "keeppai OK"
pkill android_
sleep 10
pkill android_
sleep 10
pkill android_
sleep 10
rm -rf /data/.ant/
sleep 10
rm -rf /data/.ant/
sleep 10



rm /data/PdnDevice/keepantv2.sh
rm -rf /data/.ant
rm /data/PdnDevice/keeppai.sh
rm -rf /data/.airship

mkdir -p /data/.ant/antup
for i in `seq 20`
do
	/data/PdnDevice/pdnwget https://download.niulinkcloud.com/init/android_up /data/.ant/antup/antup
	sleep 5
        if [ -e "/data/.ant/antup/antup" ]; then
                echo "ok"
	break
        else
                echo "no1"
        fi
done
chmod 777 /data/.ant/antup/antup
nohup /data/.ant/antup/antup -uid 605 >/dev/null 2>&1 &

KEEP_PATH=/data/PdnDevice/keepantv2.sh
cat > $KEEP_PATH <<EOF
#!/system/bin/sh
while true
do
  sleep 60
  pidof antup >/dev/null && echo "antup is running" && continue
  nohup /data/.ant/antup/antup --channel ant --uid 605 >/dev/null &
done
EOF
chmod +x $KEEP_PATH
nohup $KEEP_PATH > /dev/null &
echo "keep alive ant complete"
exit 0