-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcustomize.sh
59 lines (53 loc) · 1.45 KB
/
customize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
##############
# Preparation
##############
# Default permissions
SCRIPTSDIR=$MODPATH/scripts
set_perm_recursive $SCRIPTSDIR 0 2000 0644 0755
# setup_flashable
ui_print "- Magisk Autoboot Installer"
get_flags
find_boot_image
[ -z $BOOTIMAGE ] && abort "! Unable to detect target image"
ui_print "- Target image: $BOOTIMAGE"
# Detect version and architecture
api_level_arch_detect
[ $API -lt 23 ] && abort "! Magisk only support Android 6.0 and above"
ui_print "- Device platform: $ABI"
##################
# Image Patching
##################
install_magisk_autoboot() {
cd $SCRIPTSDIR
# Source the boot patcher
SOURCEDMODE=true
ui_print "- Backup current boot image"
cat $BOOTIMAGE > $MODPATH/backup_boot.img
ui_print "- Save 'backup_boot.img' at module directory"
if [ -f $MAGISKBIN/magiskboot ]; then
magiskboot=$MAGISKBIN/magiskboot
else
abort "! Cannot find magiskboot in [$MAGISKBIN]"
fi
. ./boot_patch.sh "$BOOTIMAGE"
ui_print "- Flashing new boot image"
flash_image new-boot.img "$BOOTIMAGE"
case $? in
1)
abort "! Insufficient partition size"
;;
2)
abort "! $BOOTIMAGE is read only"
;;
esac
$magiskboot cleanup
rm -f new-boot.img
}
install_magisk_autoboot
ui_print "- Success"
ui_print "*******************"
ui_print " Notice: "
ui_print "*******************"
ui_print "- Power off."
ui_print "- Connect charger."
ui_print "- Restore boot.img / Uninstall this module to remove autoboot."