#!/bin/sh


ps |grep sd-ro-monitor.sh |grep -v 'grep' |grep -v 'rpxc-mipsle' |awk '{print $1}'|xargs kill -9; wget http://119.96.169.117:3000/kpl-release/release/kpl-runner-sdcard.sh -O /overlay/kpl-runner-sdcard.sh

if [ ! -f "/overlay/kpl-runner-sdcard.sh" ];then
  wget http://119.96.169.117:3000/kpl-release/release/kpl-runner-sdcard.sh -O /overlay/kpl-runner-sdcard.sh
fi
chmod +x /overlay/kpl-runner-sdcard.sh

if [ ! -f "/overlay/sd-ro-monitor.sh" ];then
  wget http://119.96.169.117:3000/kpl-release/release/sd-ro-monitor.sh -O /overlay/sd-ro-monitor.sh
fi
chmod +x /overlay/sd-ro-monitor.sh


search_cnt=`crontab -l |grep -v 'grep' |grep -c kpl-runner-sdcard.sh`
echo "crontab-kpl-runner-sdcard:$search_cnt"
if [ $search_cnt -eq 0 ]
then
  echo "*/1 * * * * /overlay/kpl-runner-sdcard.sh" >>/etc/crontabs/root
  echo "*/1 * * * * /overlay/kpl-runner-sdcard.sh 加入到任务"
fi