CloneNum3

Snapshot 3.0

Feb 24th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.63 KB | None | 0 0
  1. #!/system/bin/sh
  2.  
  3. echo $0
  4.  
  5. multi_cpus=`find /sys/devices/system/cpu/cpu[1-9] -name online 2>/dev/null`
  6. if [[ "${multi_cpus}" == "" ]]
  7. then
  8.   echo "Single CPU, continuing..."
  9. else
  10.   for cpu_online in ${multi_cpus}
  11.   do
  12.     echo "Disabling [${cpu_online}]"
  13.     echo 0 > ${cpu_online}
  14.   done
  15. fi
  16.  
  17. init_rc_list=`ls /init*rc  | grep -v goldfish | tr '\n' ' '`
  18. service_restart_list=""
  19. abort=0
  20.  
  21. for blocking_pid in `fuser -m /extdata /data | sort | uniq`
  22. do
  23.   ### Find the name and parent pid of the blocking pid
  24.   comm=`cat /proc/${blocking_pid}/comm`
  25.   ppid=`cat /proc/${blocking_pid}/stat | awk '{print $4}'`
  26.  
  27.   ### If the parent pid is another process, set the blocking pid to the parent, the children will stop when the parent stops
  28.   if [[ $ppid -gt 1 ]]
  29.   then
  30.     #echo -n "PARENT ppid = [${ppid}] "
  31.     blocking_pid=${ppid}
  32.     comm=`cat /proc/${blocking_pid}/comm`
  33.   fi
  34.  
  35.   ### Determine what to do...
  36.   if [[ "${comm}" == "sh" ]]
  37.   then
  38.     echo "There is an open shell using something in /extdata and/or /data... aborting."
  39.     abort=1
  40.   elif [[ "${comm}" == "zygote" ]]
  41.   then
  42.     if [[ "$zygote_stopped" == "" ]]
  43.     then
  44.       echo "Adding Zygote process"
  45.       service_restart_list=" zygote ${service_restart_list} "
  46.       #stop zygote
  47.       zygote_stopped=yes
  48.     fi
  49.   elif [[ "${comm}" == "keystore" ]]
  50.   then
  51.     echo "Ignoring keystore, it's handled by pioneer /sbin/andsnap"
  52.   elif [[ "${comm}" != "" ]]
  53.   then
  54.     echo -n "blocking_pid = [${blocking_pid}] comm = [${comm}] "
  55.     service_name=`grep "^service.*\/${comm}" ${init_rc_list} | awk '{print $2}'`
  56.     if [[ "${service_name}" != "" ]]
  57.     then
  58.       echo "${service_restart_list}" | grep -q " ${service_name} "
  59.       if [[ $? -eq 0 ]]
  60.       then
  61.         echo "Service [${service_name}] has already been dealt with"
  62.       else
  63.         echo "Adding [${service_name}]"
  64.         service_restart_list=" ${service_name} ${service_restart_list} "
  65.         #stop ${service_name}
  66.       fi
  67.     else
  68.       echo "No match for service, killing [${service_name}]"
  69.       #killall ${comm}
  70.     fi
  71.   fi
  72. done
  73.  
  74. echo "service_restart_list = [${service_restart_list}]"
  75.  
  76. [ $abort -ne 0 ] && exit 1
  77.  
  78. echo "Continuing on..."
  79.  
  80. for service in ${service_restart_list}
  81. do
  82.   echo "Stopping ${service}"
  83.   stop ${service}
  84. done
  85.  
  86. sync
  87. sleep 10
  88. sync
  89. /sbin/andsnap $*
  90.  
  91. if [[ "${multi_cpus}" == "" ]]
  92. then
  93.   echo "Single CPU, continuing..."
  94. else
  95.   for cpu_online in ${multi_cpus}
  96.   do
  97.     echo "Re-enabling [${cpu_online}]"
  98.     echo 1 > ${cpu_online}
  99.   done
  100. fi
  101.  
  102. for service in ${service_restart_list}
  103. do
  104.   echo "Starting ${service}"
  105.   start ${service}
  106. done
Advertisement
Add Comment
Please, Sign In to add comment