Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
9cb1cf75
Commit
9cb1cf75
authored
Sep 26, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scripts
parent
ffa005e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
33 deletions
+46
-33
addon.d.sh
scripts/addon.d.sh
+12
-18
boot_patch.sh
scripts/boot_patch.sh
+2
-2
flash_script.sh
scripts/flash_script.sh
+3
-9
util_functions.sh
scripts/util_functions.sh
+29
-4
No files found.
scripts/addon.d.sh
View file @
9cb1cf75
...
@@ -13,9 +13,11 @@
...
@@ -13,9 +13,11 @@
main
()
{
main
()
{
# Magisk binaries
# Magisk binaries
MAGISKBIN
=
/data/magisk
MAGISKBIN
=
/data/magisk
# This script always run in recovery
# This script always run
s
in recovery
BOOTMODE
=
false
BOOTMODE
=
false
mount /data 2>/dev/null
if
[
!
-d
$MAGISKBIN
]
;
then
if
[
!
-d
$MAGISKBIN
]
;
then
echo
"! Cannot find Magisk binaries!"
echo
"! Cannot find Magisk binaries!"
exit
1
exit
1
...
@@ -24,26 +26,21 @@ main() {
...
@@ -24,26 +26,21 @@ main() {
# Wait for post addon.d processes to finish
# Wait for post addon.d processes to finish
sleep
5
sleep
5
mount
-o
ro /system 2>/dev/null
mount
-o
ro /vendor 2>/dev/null
mount /data 2>/dev/null
# Load utility functions
# Load utility functions
.
$MAGISKBIN
/util_functions.sh
.
$MAGISKBIN
/util_functions.sh
[
-f
/system/build.prop
]
||
abort
"! /system could not be mounted!"
ui_print
"************************"
ui_print
"************************"
ui_print
"* Magisk v
$MAGISK_VER
addon.d"
ui_print
"* Magisk v
$MAGISK_VER
addon.d"
ui_print
"************************"
ui_print
"************************"
api_level_arch_detect
mount_partitions
# Check if system root is installed and remove
api_level_arch_detect
remove_system_su
recovery_actions
recovery_actions
remove_system_su
find_boot_image
find_boot_image
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect boot image"
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect boot image"
ui_print
"- Found Boot Image:
$BOOTIMAGE
"
ui_print
"- Found Boot Image:
$BOOTIMAGE
"
...
@@ -54,18 +51,15 @@ main() {
...
@@ -54,18 +51,15 @@ main() {
# Source the boot patcher
# Source the boot patcher
.
$MAGISKBIN
/boot_patch.sh
"
$BOOTIMAGE
"
.
$MAGISKBIN
/boot_patch.sh
"
$BOOTIMAGE
"
[
-f
stock_boot
*
]
&&
rm
-f
/data/stock_boot
*
2>/dev/null
if
[
-f
stock_boot
*
]
;
then
rm
-f
/data/stock_boot
*
2>/dev/null
ui_print
"- Flashing new boot image"
mv
stock_boot
*
/data
if
[
-L
"
$BOOTIMAGE
"
]
;
then
dd
if
=
new-boot.img
of
=
"
$BOOTIMAGE
"
bs
=
4096
else
cat
new-boot.img /dev/zero |
dd
of
=
"
$BOOTIMAGE
"
bs
=
4096
>
/dev/null 2>&1
fi
fi
flash_boot_image new-boot.img
$BOOTIMAGE
rm
-f
new-boot.img
rm
-f
new-boot.img
cd
/
cd
/
recovery_cleanup
recovery_cleanup
ui_print
"- Done"
ui_print
"- Done"
...
...
scripts/boot_patch.sh
View file @
9cb1cf75
...
@@ -180,7 +180,7 @@ if [ ! -z $SHA1 ]; then
...
@@ -180,7 +180,7 @@ if [ ! -z $SHA1 ]; then
fi
fi
if
$SKIP_INITRAMFS
;
then
if
$SKIP_INITRAMFS
;
then
cpio_add 750 init
./
magiskinit
cpio_add 750 init magiskinit
cpio_mkdir 000 overlay
cpio_mkdir 000 overlay
cpio_add 750 overlay/init.magisk.rc init.magisk.rc
cpio_add 750 overlay/init.magisk.rc init.magisk.rc
cpio_mkdir 750 overlay/sbin
cpio_mkdir 750 overlay/sbin
...
@@ -220,7 +220,7 @@ rm -f ramdisk.cpio.orig
...
@@ -220,7 +220,7 @@ rm -f ramdisk.cpio.orig
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
# skip_initramfs -> want_initramfs
# skip_initramfs -> want_initramfs
./magiskboot
--hexpatch
kernel
\
$SKIP_INITRAMFS
&&
./magiskboot
--hexpatch
kernel
\
736B69705F696E697472616D6673
\
736B69705F696E697472616D6673
\
77616E745F696E697472616D6673
77616E745F696E697472616D6673
...
...
scripts/flash_script.sh
View file @
9cb1cf75
...
@@ -49,7 +49,7 @@ ui_print "************************"
...
@@ -49,7 +49,7 @@ ui_print "************************"
ui_print
"* Magisk v
$MAGISK_VER
Installer"
ui_print
"* Magisk v
$MAGISK_VER
Installer"
ui_print
"************************"
ui_print
"************************"
is_mounted /data
||
mount /data
is_mounted /data
||
mount /data
||
is_mounted /cache
||
mount /cache
||
abort
"! Unable to mount partitions"
mount_partitions
mount_partitions
# read override variables
# read override variables
...
@@ -85,7 +85,7 @@ if $BOOTMODE; then
...
@@ -85,7 +85,7 @@ if $BOOTMODE; then
fi
fi
# Save our stock boot image dump before removing it
# Save our stock boot image dump before removing it
[
-f
$MAGISKBIN
/stock_boot
*
]
&&
mv
$MAGISKBIN
/stock_boot
*
/data
mv
/data/magisk/stock_boot
*
/data 2>/dev/null
# Copy required files
# Copy required files
rm
-rf
$MAGISKBIN
2>/dev/null
rm
-rf
$MAGISKBIN
2>/dev/null
...
@@ -122,16 +122,10 @@ if [ -f stock_boot* ]; then
...
@@ -122,16 +122,10 @@ if [ -f stock_boot* ]; then
mv
stock_boot
*
/data
mv
stock_boot
*
/data
fi
fi
ui_print
"- Flashing new boot image"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
if
[
-L
"
$BOOTIMAGE
"
]
;
then
dd
if
=
new-boot.img
of
=
"
$BOOTIMAGE
"
bs
=
4096
else
cat
new-boot.img /dev/zero |
dd
of
=
"
$BOOTIMAGE
"
bs
=
4096
>
/dev/null 2>&1
fi
rm
-f
new-boot.img
rm
-f
new-boot.img
cd
/
cd
/
# Cleanups
# Cleanups
$BOOTMODE
||
recovery_cleanup
$BOOTMODE
||
recovery_cleanup
rm
-rf
$TMPDIR
rm
-rf
$TMPDIR
...
...
scripts/util_functions.sh
View file @
9cb1cf75
...
@@ -86,12 +86,20 @@ getvar() {
...
@@ -86,12 +86,20 @@ getvar() {
eval
$VARNAME
=
\$
VALUE
eval
$VARNAME
=
\$
VALUE
}
}
resolve_link
()
{
RESOLVED
=
"
$1
"
while
RESOLVE
=
`
readlink
$RESOLVED
`
;
do
RESOLVED
=
$RESOLVE
done
echo
$RESOLVED
}
find_boot_image
()
{
find_boot_image
()
{
if
[
-z
"
$BOOTIMAGE
"
]
;
then
if
[
-z
"
$BOOTIMAGE
"
]
;
then
if
[
!
-z
$SLOT
]
;
then
if
[
!
-z
$SLOT
]
;
then
BOOTIMAGE
=
`
find /dev/block
-iname
boot
$SLOT
|
head
-n
1
`
2>/dev/null
BOOTIMAGE
=
`
find /dev/block
-iname
boot
$SLOT
|
head
-n
1
`
2>/dev/null
else
else
for
BLOCK
in
boot_a kern-a android_boot kernel boot lnx
;
do
for
BLOCK
in
boot_a kern-a android_boot kernel boot lnx
bootimg
;
do
BOOTIMAGE
=
`
find /dev/block
-iname
$BLOCK
|
head
-n
1
`
2>/dev/null
BOOTIMAGE
=
`
find /dev/block
-iname
$BLOCK
|
head
-n
1
`
2>/dev/null
[
!
-z
$BOOTIMAGE
]
&&
break
[
!
-z
$BOOTIMAGE
]
&&
break
done
done
...
@@ -100,11 +108,11 @@ find_boot_image() {
...
@@ -100,11 +108,11 @@ find_boot_image() {
# Recovery fallback
# Recovery fallback
if
[
-z
"
$BOOTIMAGE
"
]
;
then
if
[
-z
"
$BOOTIMAGE
"
]
;
then
for
FSTAB
in
/etc/
*
fstab
*
;
do
for
FSTAB
in
/etc/
*
fstab
*
;
do
BOOTIMAGE
=
`
grep
-v
'#'
$FSTAB
|
grep
-E
'
\b/boot\b
'
|
grep
-oE
'/dev/[a-zA-Z0-9_./-]*'
`
BOOTIMAGE
=
`
grep
-v
'#'
$FSTAB
|
grep
-E
'
/boot[^a-zA-Z]
'
|
grep
-oE
'/dev/[a-zA-Z0-9_./-]*'
`
[
!
-z
$BOOTIMAGE
]
&&
break
[
!
-z
$BOOTIMAGE
]
&&
break
done
done
fi
fi
[
-L
"
$BOOTIMAGE
"
]
&&
BOOTIMAGE
=
`
read
link
$BOOTIMAGE
`
BOOTIMAGE
=
`
resolve_
link
$BOOTIMAGE
`
}
}
migrate_boot_backup
()
{
migrate_boot_backup
()
{
...
@@ -121,7 +129,24 @@ migrate_boot_backup() {
...
@@ -121,7 +129,24 @@ migrate_boot_backup() {
mv
/data/stock_boot.img
$STOCKDUMP
mv
/data/stock_boot.img
$STOCKDUMP
./magiskboot
--compress
$STOCKDUMP
./magiskboot
--compress
$STOCKDUMP
fi
fi
[
-f
/data/magisk/stock_boot
*
]
&&
mv
/data/magisk/stock_boot
*
/data
mv
/data/magisk/stock_boot
*
/data 2>/dev/null
}
flash_boot_image
()
{
case
"
$1
"
in
*
.gz
)
COMMAND
=
"gzip -d <
\"
$1
\"
"
;;
*
)
COMMAND
=
"cat
\"
$1
\"
"
;;
esac
case
"
$2
"
in
/dev/block/
*
)
ui_print
"- Flashing new boot image"
eval
$COMMAND
|
cat
- /dev/zero |
dd
of
=
"
$2
"
bs
=
4096
>
/dev/null 2>&1
;;
*
)
ui_print
"- Storing new boot image"
eval
$COMMAND
|
dd
of
=
"
$2
"
bs
=
4096
>
/dev/null 2>&1
;;
esac
}
}
sign_chromeos
()
{
sign_chromeos
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment