#!/sbin/sh # # ADDOND_VERSION=2 # ########################################################################################## # # NanoDroid System Mode OTA survival Script # by Nanolx # # Inspired by 99-flashafterupdate.sh of osm0sis @ xda-developers # Forked from 99-magisk.sh of topjohnwu @ xda-developers # ########################################################################################## source /tmp/backuptool.functions || source /postinstall/tmp/backuptool.functions MODID=NanoDroid OUTFD= VERSION=23.0.99999999 NANODROID_LIST=/data/adb/NanoDroid_FileList print_google_apps() { cat </dev/null return $? } ui_print () { echo -n -e "ui_print ${1}\n" >> /proc/self/fd/${OUTFD} echo -n -e "ui_print\n" >> /proc/self/fd/${OUTFD} } grep_prop() { sed -n "s/^${1}=//p" ${build_props} ${2} | head -n 1 } setup_env () { detect_outfd is_mounted /data || mount -oro /data PATH=/system/bin:/system/xbin:${PATH} if [ ! -d /system/xbin ]; then NANODROID_BINDIR=/system/bin else NANODROID_BINDIR=/system/xbin fi if [ ! -r ${NANODROID_LIST} ]; then echo "No NanoDroid installer information found!" exit 1 fi } detect_outfd () { if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then # We will have to manually find out OUTFD for FD in `ls /proc/$$/fd`; do if readlink /proc/$$/fd/$FD | grep -q pipe; then if ps | grep -v grep | grep -q " 3 $FD "; then OUTFD=$FD break fi fi done fi } backup_action () { sleep 5 ui_print " ++ ${MODID} ${VERSION} addon.d: backup" cat ${NANODROID_LIST} | while read FILE; do echo " + backup: ${FILE}" backup_file "${FILE}" done ui_print " ++ ${MODID} ${VERSION} addon.d: backup done" } restore_action () { sleep 5 ui_print " ++ ${MODID} ${VERSION} addon.d: restore" cat ${NANODROID_LIST} | while read FILE; do echo " + restore: ${FILE}" restore_file "${FILE}" done ui_print " ++ ${MODID} ${VERSION} addon.d: restore done" } postrestore_action () { sleep 5 setup_env ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal" print_google_apps | while read app; do ${NANODROID_BINDIR}/nanodroid-overlay --add ${app} done print_google_data | while read app; do rm -rf /data/data/${app} rm -rf /data/user/*/${app} rm -rf /data/user_de/*/${app} rm -rf /data/app/${app}-* done ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal done" get_config setup if [ "${config_exists}" -eq 1 ]; then source "${config}" if [ "${nanodroid_overlay}" -eq 1 ]; then ui_print " ++ ${MODID} ${VERSION} addon.d: creating Overlays" ${NANODROID_BINDIR}/nanodroid-overlay --create ui_print " ++ ${MODID} ${VERSION} addon.d: creating Overlays done" fi fi } case "${1}" in backup) backup_action ;; restore) restore_action ;; pre-backup) # Stub ;; post-backup) # Stub ;; pre-restore) # Stub ;; post-restore) postrestore_action ;; esac