Magisk/scripts/update_binary.sh

38 lines
805 B
Bash
Raw Normal View History

#!/sbin/sh
X86_CNT=__X86_CNT__
2018-05-13 06:26:28 +00:00
extract_bb() {
2019-02-03 14:50:49 +00:00
touch "$BBBIN"
chmod 755 "$BBBIN"
2019-07-16 08:16:29 +00:00
dd if="$0" of="$BBBIN" bs=1024 skip=1 count=$X86_CNT
"$BBBIN" >/dev/null 2>&1 || dd if="$0" of="$BBBIN" bs=1024 skip=$(($X86_CNT + 1))
2018-05-13 06:26:28 +00:00
}
setup_bb() {
mkdir -p $TMPDIR 2>/dev/null
BBBIN=$TMPDIR/busybox
2018-05-13 06:26:28 +00:00
extract_bb
}
export BBBIN
2018-05-13 06:26:28 +00:00
case "$1" in
"extract"|"-x")
BBBIN=./busybox
[ -z "$2" ] || BBBIN="$2"
2018-05-13 06:26:28 +00:00
extract_bb
;;
"sh")
2019-02-24 07:11:11 +00:00
TMPDIR=.
setup_bb
shift
exec ./busybox sh -o standalone "$@"
2018-05-13 06:26:28 +00:00
;;
*)
TMPDIR=/dev/tmp
rm -rf $TMPDIR 2>/dev/null
setup_bb
export INSTALLER=$TMPDIR/install
$BBBIN mkdir -p $INSTALLER
$BBBIN unzip -o "$3" -d $INSTALLER >&2
exec $BBBIN sh -o standalone $INSTALLER/META-INF/com/google/android/updater-script "$@"
2018-05-13 06:26:28 +00:00
;;
esac
exit