mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-08-12 14:27:47 +00:00
Magisk v8
This commit is contained in:
53
zip_static/common/custom_ramdisk_patch.sh
Normal file
53
zip_static/common/custom_ramdisk_patch.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
RAMDISK=$1
|
||||
BINDIR=/data/magisk
|
||||
|
||||
cpio_add() {
|
||||
/su/bin/sukernel --cpio-add $RAMDISK $RAMDISK $2 $1 $1
|
||||
}
|
||||
|
||||
cpio_extract() {
|
||||
/su/bin/sukernel --cpio-extract $RAMDISK $1 $1
|
||||
}
|
||||
|
||||
cpio_mkdir() {
|
||||
/su/bin/sukernel --cpio-mkdir $RAMDISK $RAMDISK $2 $1
|
||||
}
|
||||
|
||||
rm -rf /tmp/magisk/ramdisk 2>/dev/null
|
||||
mkdir -p /tmp/magisk/ramdisk
|
||||
cd /tmp/magisk/ramdisk
|
||||
|
||||
cat $RAMDISK | cpio -i
|
||||
|
||||
# Patch ramdisk
|
||||
echo "- Patching ramdisk"
|
||||
|
||||
# Add magisk entrypoint
|
||||
for INIT in init*.rc; do
|
||||
if [ $(grep -c "import /init.environ.rc" $INIT) -ne "0" ] && [ $(grep -c "import /init.magisk.rc" $INIT) -eq "0" ]; then
|
||||
sed -i "/import \/init\.environ\.rc/iimport /init.magisk.rc" $INIT
|
||||
cpio_add $INIT 750
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Add magisk PATH
|
||||
if [ $(grep -c "/magisk/.core/busybox" init.environ.rc) -eq "0" ]; then
|
||||
sed -i "/export PATH/ s/\/system\/xbin/\/system\/xbin:\/magisk\/.core\/busybox/g" init.environ.rc
|
||||
cpio_add init.environ.rc 750
|
||||
fi
|
||||
|
||||
# sepolicy patches
|
||||
$BINDIR/sepolicy-inject --magisk -P sepolicy
|
||||
cpio_add sepolicy 644
|
||||
|
||||
# Add new items
|
||||
mkdir -p magisk 2>/dev/null
|
||||
cp -af $BINDIR/init.magisk.rc init.magisk.rc
|
||||
cp -af $BINDIR/magic_mask.sh sbin/magic_mask.sh
|
||||
|
||||
cpio_mkdir magisk 755
|
||||
cpio_add init.magisk.rc 750
|
||||
cpio_add sbin/magic_mask.sh 750
|
@@ -1,9 +1,6 @@
|
||||
# Triggers
|
||||
|
||||
on post-fs
|
||||
# Paths
|
||||
export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/magisk/.core/busybox:/system/xbin
|
||||
|
||||
start magisk_pfs
|
||||
wait /dev/.magisk.unblock 20
|
||||
rm /dev/.magisk.unblock
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
LOGFILE=/cache/magisk.log
|
||||
HIDELOG=/cache/magiskhide.log
|
||||
IMG=/data/magisk.img
|
||||
|
||||
export MOUNTPOINT=/magisk
|
||||
@@ -193,6 +194,7 @@ merge_image() {
|
||||
# Merge (will reserve selinux contexts)
|
||||
cd /cache/merge_img
|
||||
for MOD in *; do
|
||||
log_print "Merging: $MOD"
|
||||
rm -rf /cache/data_img/$MOD
|
||||
cp -afc $MOD /cache/data_img/
|
||||
done
|
||||
@@ -227,8 +229,9 @@ case $1 in
|
||||
if [ -d "/cache/magisk_merge" ]; then
|
||||
cd /cache/magisk_merge
|
||||
for MOD in *; do
|
||||
log_print "Merging: $MOD"
|
||||
rm -rf /cache/magisk/$MOD
|
||||
cp -afc $MOD /cache/magisk/
|
||||
mv $MOD /cache/magisk/$MOD
|
||||
done
|
||||
rm -rf /cache/magisk_merge
|
||||
fi
|
||||
@@ -299,8 +302,6 @@ case $1 in
|
||||
unblock
|
||||
fi
|
||||
|
||||
echo $MOUNTPOINT >> $MOUNTLIST
|
||||
|
||||
log_print "Preparing modules"
|
||||
# First do cleanups
|
||||
rm -rf $DUMMDIR
|
||||
@@ -404,7 +405,7 @@ case $1 in
|
||||
|
||||
service )
|
||||
# Version info
|
||||
setprop magisk.version 7
|
||||
setprop magisk.version 8
|
||||
log_print "Magisk late_start service mode running..."
|
||||
run_scripts service
|
||||
[ -f "$COREDIR/magiskhide/enable" ] && setprop magisk.hide 1
|
||||
@@ -420,8 +421,9 @@ case $1 in
|
||||
cat $COREDIR/magiskhide/hidelist.tmp >> $COREDIR/magiskhide/hidelist
|
||||
rm -f $COREDIR/magiskhide/hidelist.tmp
|
||||
fi
|
||||
chmod 755 $COREDIR/magiskhide $COREDIR/magiskhide/*
|
||||
log_print "Starting Magisk Hide"
|
||||
exec /data/magisk/magiskhide $COREDIR/magiskhide/hidelist
|
||||
exec /data/magisk/magiskhide $COREDIR/magiskhide/hidelist > $HIDELOG
|
||||
;;
|
||||
|
||||
esac
|
||||
|
@@ -1,9 +0,0 @@
|
||||
id=phh
|
||||
name=phh's SuperUser
|
||||
version=Root Helper
|
||||
versionCode=1
|
||||
author=phhusson, topjohnwu
|
||||
description=This is a helper, please upgrade from downloads section :)
|
||||
support=http://forum.xda-developers.com/showthread.php?t=3216394
|
||||
donate=http://forum.xda-developers.com/donatetome.php?u=1915408
|
||||
cacheModule=false
|
@@ -1,40 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
LOGFILE=/cache/magisk.log
|
||||
|
||||
log_print() {
|
||||
echo $1
|
||||
echo "phh: $1" >> $LOGFILE
|
||||
log -p i -t phh "$1"
|
||||
}
|
||||
|
||||
launch_daemonsu() {
|
||||
export PATH=$OLDPATH
|
||||
# Switch contexts
|
||||
echo "u:r:su_daemon:s0" > /proc/self/attr/current
|
||||
# Start daemon
|
||||
exec /magisk/phh/bin/su --daemon
|
||||
}
|
||||
|
||||
# Disable the other root
|
||||
[ -d "/magisk/zzsupersu" ] && touch /magisk/zzsupersu/disable
|
||||
|
||||
log_print "Live patching sepolicy"
|
||||
/magisk/phh/bin/sepolicy-inject --live
|
||||
|
||||
# Expose the root path
|
||||
log_print "Linking supath"
|
||||
rm -rf /magisk/.core/bin
|
||||
ln -s /magisk/phh/bin /magisk/.core/bin
|
||||
|
||||
# Run su.d
|
||||
for script in /magisk/phh/su.d/* ; do
|
||||
if [ -f "$script" ]; then
|
||||
chmod 755 $script
|
||||
log_print "su.d: $script"
|
||||
$script
|
||||
fi
|
||||
done
|
||||
|
||||
log_print "Starting su daemon"
|
||||
(launch_daemonsu &)
|
@@ -1,29 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
cd /magisk/00roothelper
|
||||
|
||||
if [ -f "launch_daemonsu.sh" ]; then
|
||||
# SuperSU mode
|
||||
rm -rf /magisk/supersu /magisk/zzsupersu
|
||||
mkdir -p /magisk/zzsupersu
|
||||
cp supersu.sh /magisk/zzsupersu/post-fs-data.sh
|
||||
cp supersu.prop /magisk/zzsupersu/module.prop
|
||||
cp launch_daemonsu.sh /magisk/zzsupersu/launch_daemonsu.sh
|
||||
chmod 755 /magisk/zzsupersu /magisk/zzsupersu/*
|
||||
else
|
||||
# phh mode
|
||||
if [ -f "/magisk/phh/su" ]; then
|
||||
# Old version detected
|
||||
cp /magisk/phh/su su
|
||||
rm -rf /magisk/phh
|
||||
mkdir -p /magisk/phh/bin
|
||||
mkdir -p /magisk/phh/su.d
|
||||
cp su /magisk/phh/bin/su
|
||||
cp /data/magisk/sepolicy-inject /magisk/phh/bin/sepolicy-inject
|
||||
cp phh.sh /magisk/phh/post-fs-data.sh
|
||||
cp phh.prop /magisk/phh/module.prop
|
||||
chmod 755 /magisk/phh /magisk/phh/* /magisk/phh/bin/*
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf /magisk/00roothelper
|
@@ -1,7 +0,0 @@
|
||||
id=supersu
|
||||
name=SuperSU Helper
|
||||
version=v1
|
||||
versionCode=1
|
||||
author=topjohnwu
|
||||
description=This is a helper module for Chainfire's SuperSU to work with Magisk
|
||||
cacheModule=false
|
@@ -1,11 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
mount -o rw,remount rootfs /
|
||||
mkdir /su 2>/dev/null
|
||||
mount -o ro,remount rootfs /
|
||||
|
||||
chmod 755 /magisk/zzsupersu/launch_daemonsu.sh
|
||||
/magisk/zzsupersu/launch_daemonsu.sh post-fs-data
|
||||
|
||||
rm -rf /magisk/.core/bin
|
||||
ln -s /su/bin /magisk/.core/bin
|
Reference in New Issue
Block a user