Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/system/bin/sh
- echo $0
- multi_cpus=`find /sys/devices/system/cpu/cpu[1-9] -name online 2>/dev/null`
- if [[ "${multi_cpus}" == "" ]]
- then
- echo "Single CPU, continuing..."
- else
- for cpu_online in ${multi_cpus}
- do
- echo "Disabling [${cpu_online}]"
- echo 0 > ${cpu_online}
- done
- fi
- init_rc_list=`ls /init*rc | grep -v goldfish | tr '\n' ' '`
- service_restart_list=""
- abort=0
- for blocking_pid in `fuser -m /extdata /data | sort | uniq`
- do
- ### Find the name and parent pid of the blocking pid
- comm=`cat /proc/${blocking_pid}/comm`
- ppid=`cat /proc/${blocking_pid}/stat | awk '{print $4}'`
- ### If the parent pid is another process, set the blocking pid to the parent, the children will stop when the parent stops
- if [[ $ppid -gt 1 ]]
- then
- #echo -n "PARENT ppid = [${ppid}] "
- blocking_pid=${ppid}
- comm=`cat /proc/${blocking_pid}/comm`
- fi
- ### Determine what to do...
- if [[ "${comm}" == "sh" ]]
- then
- echo "There is an open shell using something in /extdata and/or /data... aborting."
- abort=1
- elif [[ "${comm}" == "zygote" ]]
- then
- if [[ "$zygote_stopped" == "" ]]
- then
- echo "Adding Zygote process"
- service_restart_list=" zygote ${service_restart_list} "
- #stop zygote
- zygote_stopped=yes
- fi
- elif [[ "${comm}" == "keystore" ]]
- then
- echo "Ignoring keystore, it's handled by pioneer /sbin/andsnap"
- elif [[ "${comm}" != "" ]]
- then
- echo -n "blocking_pid = [${blocking_pid}] comm = [${comm}] "
- service_name=`grep "^service.*\/${comm}" ${init_rc_list} | awk '{print $2}'`
- if [[ "${service_name}" != "" ]]
- then
- echo "${service_restart_list}" | grep -q " ${service_name} "
- if [[ $? -eq 0 ]]
- then
- echo "Service [${service_name}] has already been dealt with"
- else
- echo "Adding [${service_name}]"
- service_restart_list=" ${service_name} ${service_restart_list} "
- #stop ${service_name}
- fi
- else
- echo "No match for service, killing [${service_name}]"
- #killall ${comm}
- fi
- fi
- done
- echo "service_restart_list = [${service_restart_list}]"
- [ $abort -ne 0 ] && exit 1
- echo "Continuing on..."
- for service in ${service_restart_list}
- do
- echo "Stopping ${service}"
- stop ${service}
- done
- sync
- sleep 10
- sync
- /sbin/andsnap $*
- if [[ "${multi_cpus}" == "" ]]
- then
- echo "Single CPU, continuing..."
- else
- for cpu_online in ${multi_cpus}
- do
- echo "Re-enabling [${cpu_online}]"
- echo 1 > ${cpu_online}
- done
- fi
- for service in ${service_restart_list}
- do
- echo "Starting ${service}"
- start ${service}
- done
Advertisement
Add Comment
Please, Sign In to add comment