mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-25 18:37:25 +00:00
parent
47e50e8511
commit
ed7e560849
@ -86,23 +86,40 @@ setup_flashable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ensure_bb() {
|
ensure_bb() {
|
||||||
[ -o standalone ] && return
|
if set -o | grep -q standalone; then
|
||||||
set -o standalone 2>/dev/null && return
|
# 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
|
# Find our busybox binary
|
||||||
local BUSYBOX
|
local bb
|
||||||
if [ -f $TMPDIR/busybox ]; then
|
if [ -f $TMPDIR/busybox ]; then
|
||||||
BUSYBOX=$TMPDIR/busybox
|
bb=$TMPDIR/busybox
|
||||||
elif [ -f $MAGISKBIN/busybox ]; then
|
elif [ -f $MAGISKBIN/busybox ]; then
|
||||||
BUSYBOX=$MAGISKBIN/busybox
|
bb=$MAGISKBIN/busybox
|
||||||
else
|
else
|
||||||
abort "! Cannot find BusyBox"
|
abort "! Cannot find BusyBox"
|
||||||
fi
|
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
|
# Re-exec our script
|
||||||
chmod 755 $BUSYBOX
|
echo $cmds | $bb xargs $bb
|
||||||
exec $BUSYBOX sh -o standalone $0 "$@"
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
recovery_actions() {
|
recovery_actions() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user