Magisk/scripts/update_binary.sh

39 lines
835 B
Bash
Raw Normal View History

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