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
9a8eeace
Commit
9a8eeace
authored
Jun 21, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix output of addon.d, and add support for addon.d-v2
parent
45b0bf5b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
42 deletions
+83
-42
addon.d.sh
scripts/addon.d.sh
+65
-25
flash_script.sh
scripts/flash_script.sh
+1
-1
util_functions.sh
scripts/util_functions.sh
+17
-16
No files found.
scripts/addon.d.sh
View file @
9a8eeace
#!/sbin/sh
#!/sbin/sh
# ADDOND_VERSION=2
##########################################################################################
##########################################################################################
#
#
# Magisk Survival Script for ROMs with addon.d support
# Magisk Survival Script for ROMs with addon.d support
...
@@ -9,42 +10,44 @@
...
@@ -9,42 +10,44 @@
##########################################################################################
##########################################################################################
.
/tmp/backuptool.functions
.
/tmp/backuptool.functions
[
-z
$backuptool_ab
]
&&
backuptool_ab
=
false
main
()
{
initialize
()
{
# Magisk binaries
# This path should work in any cases
MAGISKBIN
=
/data/adb/magisk
TMPDIR
=
/dev/tmp
APK
=
/data/adb/magisk.apk
[
-f
$APK
]
||
APK
=
/data/magisk/magisk.apk
[
-f
$APK
]
||
APK
=
/data/app/com.topjohnwu.magisk
*
/
*
.apk
mount /data 2>/dev/null
mount /data 2>/dev/null
MAGISKBIN
=
/data/adb/magisk
if
[
!
-d
$MAGISKBIN
]
;
then
if
[
!
-d
$MAGISKBIN
]
;
then
echo
"! Cannot find Magisk binaries!"
echo
"! Cannot find Magisk binaries!"
exit
1
exit
1
fi
fi
# Wait for post addon.d processes to finish
sleep
5
# Load utility functions
# Load utility functions
.
$MAGISKBIN
/util_functions.sh
.
$MAGISKBIN
/util_functions.sh
APK
=
/data/adb/magisk.apk
[
-f
$APK
]
||
APK
=
/data/magisk/magisk.apk
[
-f
$APK
]
||
APK
=
/data/app/com.topjohnwu.magisk
*
/
*
.apk
}
show_logo
()
{
ui_print
"************************"
ui_print
"************************"
ui_print
"* Magisk v
$MAGISK_VER
addon.d"
ui_print
"* Magisk v
$MAGISK_VER
addon.d"
ui_print
"************************"
ui_print
"************************"
}
mount_partitions
detection
()
{
find_boot_image
api_level_arch_detect
find_dtbo_image
recovery_actions
remove_system_su
[
-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/ramdisk image:
$BOOTIMAGE
"
[
-z
$DTBOIMAGE
]
||
ui_print
"- Found dtbo image:
$DTBOIMAGE
"
get_flags
}
installation
()
{
[
-f
$APK
]
&&
eval
$BOOTSIGNER
-verify
<
$BOOTIMAGE
&&
BOOTSIGNED
=
true
[
-f
$APK
]
&&
eval
$BOOTSIGNER
-verify
<
$BOOTIMAGE
&&
BOOTSIGNED
=
true
$BOOTSIGNED
&&
ui_print
"- Boot image is signed with AVB 1.0"
$BOOTSIGNED
&&
ui_print
"- Boot image is signed with AVB 1.0"
...
@@ -52,23 +55,54 @@ main() {
...
@@ -52,23 +55,54 @@ main() {
cd
$MAGISKBIN
cd
$MAGISKBIN
# Source the boot patcher
# Source the boot patcher
.
$MAGISKBIN
/boot_patch.sh
"
$BOOTIMAGE
"
.
.
/boot_patch.sh
"
$BOOTIMAGE
"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
rm
-f
new-boot.img
rm
-f
new-boot.img
if
[
-f
stock_boot
*
]
;
then
if
[
-f
stock_boot
*
]
;
then
rm
-f
/data/stock_boot
*
2>/dev/null
rm
-f
/data/stock_boot
*
2>/dev/null
mv
stock_boot
*
/data
$DATA
&&
mv
stock_boot
*
/data
fi
$KEEPVERITY
||
patch_dtbo_image
if
[
-f
stock_dtbo
*
]
;
then
rm
-f
/data/stock_dtbo
*
2>/dev/null
$DATA
&&
mv
stock_dtbo
*
/data
fi
fi
cd
/
cd
/
recovery_cleanup
}
finalize
()
{
ui_print
"- Done"
ui_print
"- Done"
exit
0
exit
0
}
}
main_v1
()
{
# Wait for post addon.d processes to finish
sleep
5
recovery_actions
show_logo
mount_partitions
detection
installation
recovery_cleanup
finalize
}
main_v2
()
{
boot_actions
show_logo
mount_partitions
# Swap the slot
if
[
!
-z
$SLOT
]
;
then
[
$SLOT
=
_a
]
&&
SLOT
=
_b
||
SLOT
=
_a
;
fi
detection
installation
finalize
}
case
"
$1
"
in
case
"
$1
"
in
backup
)
backup
)
# Stub
# Stub
...
@@ -86,9 +120,15 @@ case "$1" in
...
@@ -86,9 +120,15 @@ case "$1" in
# Stub
# Stub
;;
;;
post-restore
)
post-restore
)
# Get the FD for ui_print
initialize
OUTFD
=
`
ps |
grep
-v
grep
|
grep
-oE
"update(.*)"
|
cut
-d
" "
-f3
`
if
$backuptool_ab
;
then
# Run the main function in a parallel subshell
# addon.d-v2
(
main
)
&
main_v2
else
OUTFD
=
1
get_outfd
# Run in background, hack for addon.d-v1
(
main_v1
)
&
fi
;;
;;
esac
esac
scripts/flash_script.sh
View file @
9a8eeace
...
@@ -120,7 +120,7 @@ SOURCEDMODE=true
...
@@ -120,7 +120,7 @@ SOURCEDMODE=true
cd
$MAGISKBIN
cd
$MAGISKBIN
# Source the boot patcher
# Source the boot patcher
.
$COMMONDIR
/boot_patch.sh
"
$BOOTIMAGE
"
.
.
/boot_patch.sh
"
$BOOTIMAGE
"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
rm
-f
new-boot.img
rm
-f
new-boot.img
...
...
scripts/util_functions.sh
View file @
9a8eeace
...
@@ -23,15 +23,11 @@ BOOTSIGNER="/system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp \$APK com.top
...
@@ -23,15 +23,11 @@ BOOTSIGNER="/system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp \$APK com.top
BOOTSIGNED
=
false
BOOTSIGNED
=
false
get_outfd
()
{
get_outfd
()
{
readlink
/proc/
$$
/fd/
$OUTFD
2>/dev/null |
grep
/tmp
>
/dev/null
if
[
$OUTFD
-eq
1
]
;
then
if
[
"
$?
"
-eq
"0"
]
;
then
# We will have to manually find out OUTFD
OUTFD
=
0
for
FD
in
`
ls
/proc/self/fd
`
;
do
if
readlink
/proc/self/fd/
$FD
|
grep
-q
pipe
;
then
for
FD
in
`
ls
/proc/
$$
/fd
`
;
do
if
ps |
grep
-v
grep
|
grep
-q
" 3
$FD
"
;
then
readlink
/proc/
$$
/fd/
$FD
2>/dev/null |
grep
pipe
>
/dev/null
if
[
"
$?
"
-eq
"0"
]
;
then
ps |
grep
" 3
$FD
"
|
grep
-v
grep
>
/dev/null
if
[
"
$?
"
-eq
"0"
]
;
then
OUTFD
=
$FD
OUTFD
=
$FD
break
break
fi
fi
...
@@ -299,12 +295,23 @@ api_level_arch_detect() {
...
@@ -299,12 +295,23 @@ api_level_arch_detect() {
if
[
"
$ABILONG
"
=
"x86_64"
]
;
then
ARCH
=
x64
;
ARCH32
=
x86
;
IS64BIT
=
true
;
fi
;
if
[
"
$ABILONG
"
=
"x86_64"
]
;
then
ARCH
=
x64
;
ARCH32
=
x86
;
IS64BIT
=
true
;
fi
;
}
}
setup_bb
()
{
if
[
!
-d
$TMPDIR
/bin
]
;
then
# Add busybox to PATH
mkdir
-p
$TMPDIR
/bin
ln
-s
$MAGISKBIN
/busybox
$TMPDIR
/bin/busybox
$MAGISKBIN
/busybox
--install
-s
$TMPDIR
/bin
export
PATH
=
$TMPDIR
/bin:
$PATH
fi
}
boot_actions
()
{
boot_actions
()
{
if
[
!
-d
/sbin/.core/mirror/bin
]
;
then
if
[
!
-d
/sbin/.core/mirror/bin
]
;
then
mkdir
-p
/sbin/.core/mirror/bin
mkdir
-p
/sbin/.core/mirror/bin
mount
-o
bind
$MAGISKBIN
/sbin/.core/mirror/bin
mount
-o
bind
$MAGISKBIN
/sbin/.core/mirror/bin
fi
fi
MAGISKBIN
=
/sbin/.core/mirror/bin
MAGISKBIN
=
/sbin/.core/mirror/bin
setup_bb
}
}
recovery_actions
()
{
recovery_actions
()
{
...
@@ -312,13 +319,7 @@ recovery_actions() {
...
@@ -312,13 +319,7 @@ recovery_actions() {
mount
-o
bind
/dev/urandom /dev/random
mount
-o
bind
/dev/urandom /dev/random
# Preserve environment varibles
# Preserve environment varibles
OLD_PATH
=
$PATH
OLD_PATH
=
$PATH
if
[
!
-d
$TMPDIR
/bin
]
;
then
setup_bb
# Add busybox to PATH
mkdir
-p
$TMPDIR
/bin
ln
-s
$MAGISKBIN
/busybox
$TMPDIR
/bin/busybox
$MAGISKBIN
/busybox
--install
-s
$TMPDIR
/bin
export
PATH
=
$TMPDIR
/bin:
$PATH
fi
# Temporarily block out all custom recovery binaries/libs
# Temporarily block out all custom recovery binaries/libs
mv
/sbin /sbin_tmp
mv
/sbin /sbin_tmp
# Unset library paths
# Unset library paths
...
...
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