mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Merge addon.d scripts
This commit is contained in:
parent
4dd8d75cc0
commit
b3bc1a3907
@ -1,11 +1,34 @@
|
||||
##########################################################################################
|
||||
#!/sbin/sh
|
||||
# ADDOND_VERSION=2
|
||||
########################################################
|
||||
#
|
||||
# Magisk Survival Script for ROMs with addon.d support
|
||||
# by topjohnwu
|
||||
# by topjohnwu and osm0sis
|
||||
#
|
||||
# Inspired by 99-flashafterupdate.sh of osm0sis @ xda-developers
|
||||
#
|
||||
##########################################################################################
|
||||
########################################################
|
||||
|
||||
trampoline() {
|
||||
mount /data 2>/dev/null
|
||||
if [ -f /data/adb/magisk/addon.d.sh ]; then
|
||||
exec sh /data/adb/magisk/addon.d.sh "$@"
|
||||
else
|
||||
OUTFD=$(ps | grep -v 'grep' | grep -oE 'update(.*)' | cut -d" " -f3)
|
||||
[ "$OUTFD" -eq "$OUTFD" ] 2>/dev/null || OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'update(.*)' | cut -d" " -f3)
|
||||
[ "$OUTFD" -eq "$OUTFD" ] 2>/dev/null || OUTFD=$(ps | grep -v 'grep' | grep -oE 'status_fd=(.*)' | cut -d= -f2)
|
||||
[ "$OUTFD" -eq "$OUTFD" ] 2>/dev/null || OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'status_fd=(.*)' | cut -d= -f2)
|
||||
ui_print() { echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD; }
|
||||
|
||||
ui_print "************************"
|
||||
ui_print "* Magisk addon.d failed"
|
||||
ui_print "************************"
|
||||
ui_print "! Cannot find Magisk binaries - was data wiped or not decrypted?"
|
||||
ui_print "! Reflash OTA from decrypted recovery or reflash Magisk"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Always use the script in /data
|
||||
[ "$0" = /data/adb/magisk/addon.d.sh ] || trampoline
|
||||
|
||||
V1_FUNCS=/tmp/backuptool.functions
|
||||
V2_FUNCS=/postinstall/system/bin/backuptool_ab.functions
|
||||
|
@ -80,28 +80,7 @@ if [ -d /system/addon.d ]; then
|
||||
ui_print "- Adding addon.d survival script"
|
||||
mount -o rw,remount /system
|
||||
ADDOND=/system/addon.d/99-magisk.sh
|
||||
cat <<'EOF' > $ADDOND
|
||||
#!/sbin/sh
|
||||
# ADDOND_VERSION=2
|
||||
|
||||
mount /data 2>/dev/null
|
||||
|
||||
if [ -f /data/adb/magisk/addon.d.sh ]; then
|
||||
exec sh /data/adb/magisk/addon.d.sh "$@"
|
||||
else
|
||||
OUTFD=$(ps | grep -v 'grep' | grep -oE 'update(.*)' | cut -d" " -f3)
|
||||
[ ! -z $OUTFD -a "$OUTFD" -eq "$OUTFD" ] 2>/dev/null || OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'update(.*)' | cut -d" " -f3)
|
||||
[ ! -z $OUTFD -a "$OUTFD" -eq "$OUTFD" ] 2>/dev/null || OUTFD=$(ps | grep -v 'grep' | grep -oE 'status_fd=(.*)' | cut -d= -f2)
|
||||
[ ! -z $OUTFD -a "$OUTFD" -eq "$OUTFD" ] 2>/dev/null || OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'status_fd=(.*)' | cut -d= -f2)
|
||||
ui_print() { echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD; }
|
||||
|
||||
ui_print "************************"
|
||||
ui_print "* Magisk addon.d failed"
|
||||
ui_print "************************"
|
||||
ui_print "! Cannot find Magisk binaries - was data wiped or not decrypted?"
|
||||
ui_print "! Reflash OTA from decrypted recovery or reflash Magisk"
|
||||
fi
|
||||
EOF
|
||||
cp -af $COMMONDIR/addon.d.sh $ADDOND
|
||||
chmod 755 $ADDOND
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user