You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
scripts: fix sloppy/unpredictable cmd && this || that statements
- be a bit more POSIX to avoid any potential issues when full shell stdout/err are redirected - actual logic chains remain unchanged
This commit is contained in:
@@ -13,7 +13,8 @@ trampoline() {
|
||||
exec sh $MAGISKBIN/addon.d.sh "$@"
|
||||
exit $?
|
||||
elif [ "$1" = post-restore ]; then
|
||||
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
||||
BOOTMODE=false
|
||||
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
||||
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
||||
|
||||
if ! $BOOTMODE; then
|
||||
@@ -24,7 +25,13 @@ trampoline() {
|
||||
[ -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() {
|
||||
if $BOOTMODE; then
|
||||
log -t Magisk -- "$1"
|
||||
else
|
||||
echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD
|
||||
fi
|
||||
}
|
||||
|
||||
ui_print "***********************"
|
||||
ui_print " Magisk addon.d failed"
|
||||
@@ -88,7 +95,12 @@ main() {
|
||||
|
||||
if $backuptool_ab; then
|
||||
# Swap the slot for addon.d-v2
|
||||
if [ ! -z $SLOT ]; then [ $SLOT = _a ] && SLOT=_b || SLOT=_a; fi
|
||||
if [ ! -z $SLOT ]; then
|
||||
case $SLOT in
|
||||
_a) SLOT=_b;;
|
||||
_b) SLOT=_a;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
find_boot_image
|
||||
@@ -128,7 +140,8 @@ case "$1" in
|
||||
post-restore)
|
||||
initialize
|
||||
if $backuptool_ab; then
|
||||
$BOOTMODE && su=su || su=sh
|
||||
su=sh
|
||||
$BOOTMODE && su=su
|
||||
exec $su -c "sh $0 addond-v2"
|
||||
else
|
||||
# Run in background, hack for addon.d-v1
|
||||
|
||||
Reference in New Issue
Block a user