scripts: sync avd_magisk.sh with mgiskinit

This commit is contained in:
vvb2060 2024-12-06 12:55:10 +08:00 committed by John Wu
parent 4fb539c110
commit b09ceeb43c

View File

@ -37,7 +37,7 @@ if [ -z "$FIRST_STAGE" ]; then
export ASH_STANDALONE=1 export ASH_STANDALONE=1
if [ $(./busybox id -u) -ne 0 ]; then if [ $(./busybox id -u) -ne 0 ]; then
# Re-exec script with root # Re-exec script with root
exec /system/xbin/su 0 ./busybox sh $0 exec /system/xbin/su 0 /data/local/tmp/busybox sh $0
else else
# Re-exec script with busybox # Re-exec script with busybox
exec ./busybox sh $0 exec ./busybox sh $0
@ -66,7 +66,7 @@ fi
# Stop zygote (and previous setup if exists) # Stop zygote (and previous setup if exists)
magisk --stop 2>/dev/null magisk --stop 2>/dev/null
stop stop zygote
if [ -d /debug_ramdisk ]; then if [ -d /debug_ramdisk ]; then
umount -l /debug_ramdisk 2>/dev/null umount -l /debug_ramdisk 2>/dev/null
fi fi
@ -141,16 +141,17 @@ ln -s ./magisk $MAGISKTMP/resetprop
ln -s ./magiskpolicy $MAGISKTMP/supolicy ln -s ./magiskpolicy $MAGISKTMP/supolicy
mkdir -p $MAGISKTMP/.magisk/device mkdir -p $MAGISKTMP/.magisk/device
mkdir -p $MAGISKTMP/.magisk/worker
mount -t tmpfs -o 'mode=0755' magisk $MAGISKTMP/.magisk/worker
mount --make-private $MAGISKTMP/.magisk/worker
touch $MAGISKTMP/.magisk/config touch $MAGISKTMP/.magisk/config
export MAGISKTMP export MAGISKTMP
MAKEDEV=1 $MAGISKTMP/magisk --preinit-device 2>&1 MAKEDEV=1 $MAGISKTMP/magisk --preinit-device 2>&1
RULESCMD="" RULESCMD=""
for r in $MAGISKTMP/.magisk/preinit/*/sepolicy.rule; do rule="$MAGISKTMP/.magisk/preinit/sepolicy.rule"
[ -f "$r" ] || continue [ -f "$rule" ] && RULESCMD="--apply $rule"
RULESCMD="$RULESCMD --apply $r"
done
# SELinux stuffs # SELinux stuffs
if [ -d /sys/fs/selinux ]; then if [ -d /sys/fs/selinux ]; then
@ -165,5 +166,8 @@ fi
# Boot up # Boot up
$MAGISKTMP/magisk --post-fs-data $MAGISKTMP/magisk --post-fs-data
start start zygote
$MAGISKTMP/magisk --service $MAGISKTMP/magisk --service
# Make sure reset nb prop after zygote starts
sleep 2
$MAGISKTMP/magisk --boot-complete