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
d93fc67a
Commit
d93fc67a
authored
Jun 17, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve detecting device status
parent
838f3cc0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
25 deletions
+24
-25
flash_script.sh
scripts/flash_script.sh
+3
-0
util_functions.sh
scripts/util_functions.sh
+21
-25
No files found.
scripts/flash_script.sh
View file @
d93fc67a
...
@@ -48,6 +48,9 @@ ui_print "************************"
...
@@ -48,6 +48,9 @@ ui_print "************************"
is_mounted /data
||
mount /data
||
is_mounted /cache
||
mount /cache
||
abort
"! Unable to mount partitions"
is_mounted /data
||
mount /data
||
is_mounted /cache
||
mount /cache
||
abort
"! Unable to mount partitions"
mount_partitions
mount_partitions
find_boot_image
find_dtbo_image
# read override variables
# read override variables
getvar KEEPVERITY
getvar KEEPVERITY
getvar KEEPFORCEENCRYPT
getvar KEEPFORCEENCRYPT
...
...
scripts/util_functions.sh
View file @
d93fc67a
...
@@ -47,32 +47,30 @@ ui_print() {
...
@@ -47,32 +47,30 @@ ui_print() {
mount_partitions
()
{
mount_partitions
()
{
# Check A/B slot
# Check A/B slot
SLOT
=
`
getprop ro.boot.slot_suffix
`
if
[
"
`
grep_prop ro.build.ab_update
`
"
=
"true"
]
;
then
if
[
-z
$SLOT
]
;
then
SLOT
=
`
grep_cmdline androidboot.slot_suffix
`
SLOT
=
_
`
getprop ro.boot.slot
`
if
[
-z
$SLOT
]
;
then
[
$SLOT
=
"_"
]
&&
SLOT
=
SLOT
=
_
`
grep_cmdline androidboot.slot
`
[
$SLOT
=
"_"
]
&&
SLOT
=
fi
fi
fi
[
-z
$SLOT
]
||
ui_print
"- A/B partition, current slot:
$SLOT
"
# Check the boot image to make sure the slot actually make sense
find_boot_image
find_dtbo_image
[
-z
$SLOT
]
||
ui_print
"- A/B partition detected, current slot:
$SLOT
"
ui_print
"- Mounting /system, /vendor"
ui_print
"- Mounting /system, /vendor"
is_mounted /system
||
[
-f
/system/build.prop
]
||
mount
-o
ro /system 2>/dev/null
[
-f
/system/build.prop
]
||
is_mounted /system
||
mount
-o
ro /system 2>/dev/null
if
!
is_mounted /system
&&
!
[
-f
/system/build.prop
]
;
then
if
!
is_mounted /system
&&
!
[
-f
/system/build.prop
]
;
then
SYSTEMBLOCK
=
`
find /dev/block
-iname
system
$SLOT
|
head
-n
1
`
SYSTEMBLOCK
=
`
find /dev/block
-iname
system
$SLOT
|
head
-n
1
`
mount
-t
ext4
-o
ro
$SYSTEMBLOCK
/system
mount
-t
ext4
-o
ro
$SYSTEMBLOCK
/system
fi
fi
is_mounted /system
||
[
-f
/system/build.prop
]
||
abort
"! Cannot mount /system"
[
-f
/system/build.prop
]
||
is_mounted /system
||
abort
"! Cannot mount /system"
cat
/proc/mounts |
grep
-E
'/dev/root|/system_root'
>
/dev/null
&&
S
KIP_INITRAMFS
=
true
||
SKIP_INITRAMFS
=
false
cat
/proc/mounts |
grep
-E
'/dev/root|/system_root'
>
/dev/null
&&
S
YSTEM_ROOT
=
true
||
SYSTEM_ROOT
=
false
if
[
-f
/system/init
.rc
]
;
then
if
[
-f
/system/init
]
;
then
S
KIP_INITRAMFS
=
true
S
YSTEM_ROOT
=
true
mkdir
/system_root 2>/dev/null
mkdir
/system_root 2>/dev/null
mount
--move
/system /system_root
mount
--move
/system /system_root
mount
-o
bind
/system_root/system /system
mount
-o
bind
/system_root/system /system
fi
fi
$S
KIP_INITRAMFS
&&
ui_print
"- Device skip_initramfs detected
"
$S
YSTEM_ROOT
&&
ui_print
"- Device using system_root_image
"
if
[
-L
/system/vendor
]
;
then
if
[
-L
/system/vendor
]
;
then
# Seperate /vendor partition
# Seperate /vendor partition
is_mounted /vendor
||
mount
-o
ro /vendor 2>/dev/null
is_mounted /vendor
||
mount
-o
ro /vendor 2>/dev/null
...
@@ -84,6 +82,11 @@ mount_partitions() {
...
@@ -84,6 +82,11 @@ mount_partitions() {
fi
fi
}
}
grep_cmdline
()
{
REGEX
=
"s/^
$1
=//p"
sed
-E
's/ +/\n/g'
/proc/cmdline |
sed
-n
"
$REGEX
"
2>/dev/null
}
grep_prop
()
{
grep_prop
()
{
REGEX
=
"s/^
$1
=//p"
REGEX
=
"s/^
$1
=//p"
shift
shift
...
@@ -95,10 +98,7 @@ grep_prop() {
...
@@ -95,10 +98,7 @@ grep_prop() {
getvar
()
{
getvar
()
{
local
VARNAME
=
$1
local
VARNAME
=
$1
local
VALUE
=
local
VALUE
=
for
DIR
in
/.backup /dev /data /cache /system
;
do
VALUE
=
`
grep_prop
$VARNAME
/.backup/.magisk /data/.magisk /cache/.magisk /system/.magisk
`
VALUE
=
`
grep_prop
$VARNAME
$DIR
/.magisk
`
[
!
-z
$VALUE
]
&&
break
;
done
[
!
-z
$VALUE
]
&&
eval
$VARNAME
=
\$
VALUE
[
!
-z
$VALUE
]
&&
eval
$VARNAME
=
\$
VALUE
}
}
...
@@ -106,10 +106,7 @@ find_boot_image() {
...
@@ -106,10 +106,7 @@ find_boot_image() {
BOOTIMAGE
=
BOOTIMAGE
=
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
fi
else
if
[
-z
$BOOTIMAGE
]
;
then
# The slot info is incorrect...
SLOT
=
for
BLOCK
in
ramdisk boot_a kern-a android_boot kernel boot lnx bootimg
;
do
for
BLOCK
in
ramdisk 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
...
@@ -229,8 +226,7 @@ sign_chromeos() {
...
@@ -229,8 +226,7 @@ sign_chromeos() {
}
}
is_mounted
()
{
is_mounted
()
{
TARGET
=
"
`
readlink
-f
$1
`
"
cat
/proc/mounts |
grep
-q
"
`
readlink
-f
$1
`
"
2>/dev/null
cat
/proc/mounts |
grep
"
$TARGET
"
>
/dev/null
return
$?
return
$?
}
}
...
...
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