2
0
mirror of https://gitlab.com/Nanolx/NanoDroid synced 2024-10-31 09:20:23 +00:00

System Mode: work-in-progress OTA survival (addon.d)

This commit is contained in:
Christopher Roy Bratusek 2018-04-10 19:58:45 +02:00
parent 968ff6b6f9
commit a8c568dc78
2 changed files with 78 additions and 0 deletions

62
CommonAddon Normal file
View File

@ -0,0 +1,62 @@
#!/sbin/sh
##########################################################################################
#
# 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
#
##########################################################################################
. /tmp/backuptool.functions
MODID=@MODID@
##########################################################################################
# Stuffz
##########################################################################################
OUTFD=$(ps | grep -v grep | grep -oE "update(.*)" | cut -d" " -f3)
ui_print () {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
case "${1}" in
backup)
if [ -r /data/adb/.nanodroid-list ]; then
ui_print "${MODID} addon.d: backup"
cat /data/adb/.nanodroid-list | while read FILE; do
test -z "${FILE}" && continue
echo " ${S}/${FILE}"
backup_file "${S}/${FILE}"
done
ui_print "${MODID} addon.d: backup done"
fi
;;
restore)
if [ -r /data/adb/.nanodroid-list ]; then
ui_print "${MODID} addon.d: restore"
cat /data/adb/.nanodroid-list | while read FILE REPLACEMENT; do
test -z "${FILE}" && continue
[ -f "${C}/${S}/${FILE}" ] && restore_file "${S}/${FILE}" "${FILE}"
done
ui_print "${MODID} addon.d: restore done"
fi
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac

View File

@ -311,6 +311,8 @@ unpack_zip () {
nanodroid_finalize () {
[ "${MODE}" = "MAGISK" ] && magisk_install_finish
[ "${MODE}" = "SYSTEM" ] && install_addond
rm -rf ${INSTALLER}
ui_print " "
@ -852,6 +854,20 @@ install_swipe () {
fi
}
install_addond () {
if [ -d /system/addon.d ]; then
ui_print " << System Mode OTA survival"
cp "${INSTALLER}/CommonAddon" "/system/addon.d/91-nanodroid.sh" || \
error " !! failed to install System Mode OTA survival"
chmod 0755 "/system/addon.d/91-nanodroid.sh"
sed -e "s|@MODID@|${MODID}|g" -i "/system/addon.d/91-nanodroid.sh"
else
ui_print " << ROM does not have addon.d support"
fi
}
##########################################################################################
# Advanced Installation Functions
##########################################################################################