mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-28 16:07:39 +00:00
parent
47e50e8511
commit
ed7e560849
@ -86,23 +86,40 @@ setup_flashable() {
|
||||
}
|
||||
|
||||
ensure_bb() {
|
||||
[ -o standalone ] && return
|
||||
set -o standalone 2>/dev/null && return
|
||||
if set -o | grep -q standalone; then
|
||||
# We are definitely in busybox ash
|
||||
set -o standalone
|
||||
return
|
||||
fi
|
||||
|
||||
# At this point, we are not running in BusyBox ash
|
||||
# Find our busybox binary
|
||||
local BUSYBOX
|
||||
local bb
|
||||
if [ -f $TMPDIR/busybox ]; then
|
||||
BUSYBOX=$TMPDIR/busybox
|
||||
bb=$TMPDIR/busybox
|
||||
elif [ -f $MAGISKBIN/busybox ]; then
|
||||
BUSYBOX=$MAGISKBIN/busybox
|
||||
bb=$MAGISKBIN/busybox
|
||||
else
|
||||
abort "! Cannot find BusyBox"
|
||||
fi
|
||||
chmod 755 $bb
|
||||
|
||||
# Find our current arguments
|
||||
# Run in busybox environment to ensure consistent results
|
||||
# /proc/<pid>/cmdline shall be <interpreter> <script> <arguments...>
|
||||
local cmds=$($bb sh -o standalone -c "
|
||||
tr '\0' '\n' < /proc/$$/cmdline | (while read -r arg; do
|
||||
if [ -z \"\$cmds\" ]; then
|
||||
# Skip the first argument as we want to change the interpreter
|
||||
cmds=\"sh -o standalone\"
|
||||
else
|
||||
cmds=\"\$cmds '\$arg'\"
|
||||
fi
|
||||
done
|
||||
echo \$cmds)")
|
||||
|
||||
# Re-exec our script
|
||||
chmod 755 $BUSYBOX
|
||||
exec $BUSYBOX sh -o standalone $0 "$@"
|
||||
echo $cmds | $bb xargs $bb
|
||||
exit
|
||||
}
|
||||
|
||||
recovery_actions() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user