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

176 lines
3.6 KiB
Plaintext
Raw Normal View History

#!/sbin/sh
2018-09-02 13:03:32 +00:00
#
# 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
#
##########################################################################################
2020-10-04 17:00:50 +00:00
source /tmp/backuptool.functions || source /postinstall/tmp/backuptool.functions
2020-10-04 17:00:50 +00:00
MODID=NanoDroid
OUTFD=
2020-09-24 18:40:58 +00:00
VERSION=23.0.99999999
NANODROID_LIST=/system/addon.d/NanoDroid_FileList
2020-08-27 15:09:12 +00:00
2019-02-04 19:19:40 +00:00
print_google_apps()
{
cat <<EOF
AMAPNetworkLocation
2018-08-24 22:28:06 +00:00
BaiduNetworkLocation
BlankStore
2018-12-20 20:30:24 +00:00
ConfigUpdater
GCS
2018-08-24 22:28:06 +00:00
GmsCoreSetupPrebuilt
GmsCore_update
GoogleFeedback
GoogleLoginService
GoogleOneTimeInitializer
GoogleServicesFramework
2018-12-20 20:30:24 +00:00
GoogleConnectivityServices
GoogleTTS
2018-08-24 22:28:06 +00:00
LegacyNetworkLocation
MarketUpdater
MarkupGoogle
NetworkLocation
PlayGames
PlayStore
PrebuiltGmsCore
2018-12-20 20:30:24 +00:00
PrebuiltGmsCorePi
PrebuiltGmsCorePix
2018-08-24 22:28:06 +00:00
UnifiedNlp
Velvet
Vending
2019-02-04 19:19:40 +00:00
WhisperPush
EOF
}
# check for configuration files
config_locations="/data/media/0 /external_sd /sdcard1 /data"
get_config () {
config=""
config_exists=0
for path in ${config_locations}; do
if test -r "${path}/.nanodroid-${1}"; then
config="${path}/.nanodroid-${1}"
config_exists=1
return
fi
done
}
2020-10-04 17:00:50 +00:00
is_mounted () {
grep -q "$(readlink -f ${1})" /proc/mounts 2>/dev/null
return $?
}
ui_print () {
2018-04-10 19:13:11 +00:00
echo -n -e "ui_print ${1}\n" >> /proc/self/fd/${OUTFD}
echo -n -e "ui_print\n" >> /proc/self/fd/${OUTFD}
}
grep_prop() {
2020-10-04 17:00:50 +00:00
sed -n "s/^${1}=//p" ${build_props} ${2} | head -n 1
}
2020-10-04 17:00:50 +00:00
2020-08-27 15:09:12 +00:00
setup_env () {
2020-10-04 17:00:50 +00:00
detect_outfd
2020-10-04 17:00:50 +00:00
is_mounted /data || mount -oro /data
2020-10-04 17:00:50 +00:00
PATH=/system/bin:/system/xbin:${PATH}
NANODROID_BINDIR=/system/bin
2020-10-04 17:00:50 +00:00
if [ ! -r ${NANODROID_LIST} ]; then
echo "No NanoDroid installer information found!"
exit 1
fi
}
detect_outfd () {
# taken from Magisk
# update-binary|updater <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
OUTFD=$(ps | grep -v 'grep' | grep -oE 'update(.*) 3 [0-9]+' | cut -d" " -f3)
[ -z $OUTFD ] && OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'update(.*) 3 [0-9]+' | cut -d" " -f3)
# update_engine_sideload --payload=file://<ZIPFILE> --offset=<OFFSET> --headers=<HEADERS> --status_fd=<OUTFD>
[ -z $OUTFD ] && OUTFD=$(ps | grep -v 'grep' | grep -oE 'status_fd=[0-9]+' | cut -d= -f2)
[ -z $OUTFD ] && OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'status_fd=[0-9]+' | cut -d= -f2)
}
2018-09-08 19:42:40 +00:00
backup_action () {
sleep 5
ui_print " ++ ${MODID} ${VERSION} addon.d: backup"
2018-09-08 19:42:40 +00:00
cat ${NANODROID_LIST} | while read FILE; do
echo " + backup: ${FILE}"
backup_file "${FILE}"
done
ui_print " ++ ${MODID} ${VERSION} addon.d: backup done"
2018-09-08 19:42:40 +00:00
}
2018-09-08 19:42:40 +00:00
restore_action () {
sleep 5
ui_print " ++ ${MODID} ${VERSION} addon.d: restore"
2018-09-08 19:42:40 +00:00
cat ${NANODROID_LIST} | while read FILE; do
echo " + restore: ${FILE}"
restore_file "${FILE}"
done
ui_print " ++ ${MODID} ${VERSION} addon.d: restore done"
2018-09-08 19:42:40 +00:00
}
2018-09-08 19:42:40 +00:00
postrestore_action () {
sleep 5
2020-08-27 15:09:12 +00:00
setup_env
ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal"
2019-02-04 19:19:40 +00:00
print_google_apps | while read app; do
${NANODROID_BINDIR}/nanodroid-overlay --add ${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
2018-09-08 19:42:40 +00:00
}
case "${1}" in
backup)
backup_action
;;
restore)
restore_action
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
postrestore_action
;;
esac