#!/system/bin/sh
set +e
set +x
set +u
while true ; do
 if [ -e /data/Cuprum_Info/cu_service_working ] ; then
  WORKING_STATE=$(cat /data/Cuprum_Info/cu_service_working)
  if [ $WORKING_STATE = "0" ] ; then
   setlog "Cuprum_Daemon: Cuprum_Mainservice has been killed,try to restart Mainservice..."
   monitor_pid=$(cat /data/Cuprum_Info/monitor_pid)
   su -c kill $monitor_pid 2>/dev/null
   chmod 7777 /data/CuprumTurbo_Lib/cuprum_serviced
   su -c /data/CuprumTurbo_Lib/cuprum_serviced 2>&1 > /dev/null &
  else
   echo "0" > /data/Cuprum_Info/cu_service_working
  fi
 fi
 sleep 60
done
