2018-05-13 12:14:10 +02:00
|
|
|
env_check() {
|
|
|
|
for file in busybox magisk magiskboot magiskinit util_functions.sh boot_patch.sh; do
|
2018-06-25 18:29:01 +02:00
|
|
|
[ -f /data/adb/magisk/$file ] || return 1
|
2018-05-13 12:14:10 +02:00
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
2018-06-25 18:29:01 +02:00
|
|
|
|
2018-07-04 11:15:26 +02:00
|
|
|
fix_env() {
|
|
|
|
cd /data/adb/magisk
|
|
|
|
sh update-binary extract
|
|
|
|
rm -f update-binary magisk.apk
|
|
|
|
cd /
|
2018-11-15 07:36:03 +01:00
|
|
|
rm -rf /sbin/.magisk/busybox/*
|
|
|
|
/sbin/.magisk/mirror/bin/busybox --install -s /sbin/.magisk/busybox
|
2018-07-04 11:15:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
direct_install() {
|
|
|
|
rm -rf /data/adb/magisk/* 2>/dev/null
|
|
|
|
mkdir -p /data/adb/magisk 2>/dev/null
|
|
|
|
chmod 700 /data/adb
|
2018-08-12 20:57:03 +02:00
|
|
|
cp -rf $1/* /data/adb/magisk
|
|
|
|
rm -rf /data/adb/magisk/new-boot.img
|
2018-08-10 12:59:14 +02:00
|
|
|
echo "- Flashing new boot image"
|
2018-08-12 20:57:03 +02:00
|
|
|
flash_image $1/new-boot.img $2
|
2018-08-11 09:56:12 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "! Insufficient partition size"
|
|
|
|
return 1
|
|
|
|
fi
|
2018-08-12 20:57:03 +02:00
|
|
|
rm -rf $1
|
2018-08-11 09:56:12 +02:00
|
|
|
return 0
|
2018-07-04 11:15:26 +02:00
|
|
|
}
|
|
|
|
|
2018-06-25 18:29:01 +02:00
|
|
|
mm_patch_dtbo() {
|
|
|
|
if $KEEPVERITY; then
|
2018-08-10 12:59:14 +02:00
|
|
|
return 1
|
2018-06-25 18:29:01 +02:00
|
|
|
else
|
|
|
|
find_dtbo_image
|
2018-08-10 12:59:14 +02:00
|
|
|
patch_dtbo_image
|
2018-06-25 18:29:01 +02:00
|
|
|
fi
|
|
|
|
}
|
2018-06-26 23:58:56 +02:00
|
|
|
|
|
|
|
restore_imgs() {
|
2018-11-20 11:24:40 +01:00
|
|
|
local SHA1=`grep_prop SHA1 /sbin/.magisk/config`
|
2018-11-15 06:33:20 +01:00
|
|
|
[ -z $SHA1 ] && local SHA1=`cat /.backup/.sha1`
|
2018-06-26 23:58:56 +02:00
|
|
|
[ -z $SHA1 ] && return 1
|
2018-07-20 19:59:28 +02:00
|
|
|
local STOCKBOOT=/data/stock_boot_${SHA1}.img.gz
|
|
|
|
local STOCKDTBO=/data/stock_dtbo.img.gz
|
2018-06-26 23:58:56 +02:00
|
|
|
[ -f $STOCKBOOT ] || return 1
|
|
|
|
|
|
|
|
find_boot_image
|
|
|
|
find_dtbo_image
|
|
|
|
|
2018-08-10 12:59:14 +02:00
|
|
|
if [ -f $STOCKDTBO -a -b "$DTBOIMAGE" ]; then
|
|
|
|
flash_image $STOCKDTBO $DTBOIMAGE
|
2018-06-26 23:58:56 +02:00
|
|
|
fi
|
2018-08-10 12:59:14 +02:00
|
|
|
if [ -f $STOCKBOOT -a -b "$BOOTIMAGE" ]; then
|
|
|
|
flash_image $STOCKBOOT $BOOTIMAGE
|
2018-06-26 23:58:56 +02:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
2018-07-20 19:59:28 +02:00
|
|
|
|
|
|
|
post_ota() {
|
|
|
|
cd $1
|
|
|
|
chmod 755 bootctl
|
2018-12-13 10:35:50 +01:00
|
|
|
../../../../../app/src/full/res/raw/bootctl hal-info || return
|
|
|
|
[ `../../../../../app/src/full/res/raw/bootctl get-current-slot` -eq 0 ] && SLOT_NUM=1 || SLOT_NUM=0
|
|
|
|
../../../../../app/src/full/res/raw/bootctl set-active-boot-slot $SLOT_NUM
|
2018-07-20 19:59:28 +02:00
|
|
|
echo '${0%/*}/../bootctl mark-boot-successful;rm -f ${0%/*}/../bootctl $0' > post-fs-data.d/post_ota.sh
|
|
|
|
chmod 755 post-fs-data.d/post_ota.sh
|
|
|
|
cd /
|
|
|
|
}
|
2018-11-15 19:57:41 +01:00
|
|
|
|
|
|
|
add_hosts_module() {
|
|
|
|
# Do not touch existing hosts module
|
|
|
|
[ -d /sbin/.magisk/img/hosts ] && return
|
|
|
|
cd /sbin/.magisk/img
|
|
|
|
mkdir -p hosts/system/etc
|
|
|
|
cat << EOF > hosts/module.prop
|
|
|
|
id=hosts
|
|
|
|
name=Systemless Hosts
|
|
|
|
version=1.0
|
|
|
|
versionCode=1
|
|
|
|
author=Magisk Manager
|
|
|
|
description=Magisk Manager built-in systemless hosts module
|
|
|
|
minMagisk=17000
|
|
|
|
EOF
|
|
|
|
if [ -f .core/hosts ]; then
|
|
|
|
# Migrate old hosts file to new module
|
|
|
|
mv -f .core/hosts hosts/system/etc/hosts
|
|
|
|
else
|
2018-11-27 09:26:05 +01:00
|
|
|
cp -f /system/etc/hosts hosts/system/etc/hosts
|
2018-11-15 19:57:41 +01:00
|
|
|
fi
|
2018-11-27 09:26:05 +01:00
|
|
|
magisk --clone-attr /system/etc/hosts hosts/system/etc/hosts
|
2018-11-15 19:57:41 +01:00
|
|
|
touch hosts/update
|
|
|
|
touch hosts/auto_mount
|
|
|
|
cd /
|
|
|
|
}
|
2018-11-27 09:24:26 +01:00
|
|
|
|
|
|
|
rm_launch() {
|
|
|
|
db_clean $1
|
|
|
|
pm uninstall $2
|
2018-12-09 09:52:13 +01:00
|
|
|
am start -n ${3}/a.c
|
2018-11-27 09:24:26 +01:00
|
|
|
exit
|
|
|
|
}
|