mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
scripts: fix addon.d after merge to trampoline
- pass addon.d arguments through trampoline or nothing will happen - exit immediately after handing over from trampoline - better grep for recovery OUTFD which should work in all cases - output to logcat when booted and no binaries are found - use /postinstall/tmp path to call functions from addon.d-v2 in progress - remove unnecessary check for $MAGISKBIN since we're already executing from within it - make sure we're not in $TMPDIR again before we delete it - use $MAGISKBIN wherever possible in case it ever needs to be changed
This commit is contained in:
parent
9582379e1b
commit
f5c099e9a7
@ -9,14 +9,22 @@
|
|||||||
|
|
||||||
trampoline() {
|
trampoline() {
|
||||||
mount /data 2>/dev/null
|
mount /data 2>/dev/null
|
||||||
if [ -f /data/adb/magisk/addon.d.sh ]; then
|
if [ -f $MAGISKBIN/addon.d.sh ]; then
|
||||||
exec sh /data/adb/magisk/addon.d.sh "$@"
|
exec sh $MAGISKBIN/addon.d.sh "$@"
|
||||||
|
exit $?
|
||||||
else
|
else
|
||||||
OUTFD=$(ps | grep -v 'grep' | grep -oE 'update(.*)' | cut -d" " -f3)
|
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
||||||
[ "$OUTFD" == "$((OUTFD * 1))" ] || OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'update(.*)' | cut -d" " -f3)
|
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
||||||
[ "$OUTFD" == "$((OUTFD * 1))" ] || OUTFD=$(ps | grep -v 'grep' | grep -oE 'status_fd=(.*)' | cut -d= -f2)
|
|
||||||
[ "$OUTFD" == "$((OUTFD * 1))" ] || OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'status_fd=(.*)' | cut -d= -f2)
|
if ! $BOOTMODE; then
|
||||||
ui_print() { echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD; }
|
# 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)
|
||||||
|
fi
|
||||||
|
ui_print() { $BOOTMODE && log -t Magisk -- "$1" || echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD; }
|
||||||
|
|
||||||
ui_print "************************"
|
ui_print "************************"
|
||||||
ui_print "* Magisk addon.d failed"
|
ui_print "* Magisk addon.d failed"
|
||||||
@ -28,10 +36,11 @@ trampoline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Always use the script in /data
|
# Always use the script in /data
|
||||||
[ "$0" = /data/adb/magisk/addon.d.sh ] || trampoline
|
MAGISKBIN=/data/adb/magisk
|
||||||
|
[ "$0" = $MAGISKBIN/addon.d.sh ] || trampoline "$@"
|
||||||
|
|
||||||
V1_FUNCS=/tmp/backuptool.functions
|
V1_FUNCS=/tmp/backuptool.functions
|
||||||
V2_FUNCS=/postinstall/system/bin/backuptool_ab.functions
|
V2_FUNCS=/postinstall/tmp/backuptool.functions
|
||||||
|
|
||||||
if [ -f $V1_FUNCS ]; then
|
if [ -f $V1_FUNCS ]; then
|
||||||
. $V1_FUNCS
|
. $V1_FUNCS
|
||||||
@ -43,13 +52,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
MAGISKBIN=/data/adb/magisk
|
|
||||||
|
|
||||||
if [ ! -d $MAGISKBIN ]; then
|
|
||||||
echo "! Cannot find Magisk binaries!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Load utility functions
|
# Load utility functions
|
||||||
. $MAGISKBIN/util_functions.sh
|
. $MAGISKBIN/util_functions.sh
|
||||||
|
|
||||||
@ -95,6 +97,7 @@ main() {
|
|||||||
install_magisk
|
install_magisk
|
||||||
|
|
||||||
# Cleanups
|
# Cleanups
|
||||||
|
cd /
|
||||||
$BOOTMODE || recovery_cleanup
|
$BOOTMODE || recovery_cleanup
|
||||||
rm -rf $TMPDIR
|
rm -rf $TMPDIR
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user