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
0eb79e5a
Commit
0eb79e5a
authored
Sep 06, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scripts
parent
eceba268
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
89 deletions
+62
-89
boot_patch.sh
scripts/boot_patch.sh
+5
-11
flash_script.sh
scripts/flash_script.sh
+0
-8
magisk_uninstaller.sh
scripts/magisk_uninstaller.sh
+29
-64
uninstaller_loader.sh
scripts/uninstaller_loader.sh
+1
-5
util_functions.sh
scripts/util_functions.sh
+27
-1
No files found.
scripts/boot_patch.sh
View file @
0eb79e5a
...
...
@@ -117,6 +117,9 @@ chmod -R 755 .
##########################################################################################
# Unpack
##########################################################################################
migrate_boot_backup
CHROMEOS
=
false
ui_print_wrap
"- Unpacking boot image"
...
...
@@ -158,7 +161,7 @@ case $? in
1
)
# Magisk patched
ui_print_wrap
"- Magisk patched image detected!"
# Find SHA1 of stock boot image
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio-stocksha1
ramdisk.cpio
`
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio-stocksha1
ramdisk.cpio
2>/dev/null
`
OK
=
false
./magiskboot
--cpio-restore
ramdisk.cpio
if
[
$?
-eq
0
]
;
then
...
...
@@ -235,15 +238,6 @@ ui_print_wrap "- Repacking boot image"
./magiskboot
--repack
"
$BOOTIMAGE
"
||
abort_wrap
"! Unable to repack boot image!"
# Sign chromeos boot
if
$CHROMEOS
;
then
echo
>
empty
./chromeos/futility vbutil_kernel
--pack
new-boot.img.signed
\
--keyblock
./chromeos/kernel.keyblock
--signprivate
./chromeos/kernel_data_key.vbprivk
\
--version
1
--vmlinuz
new-boot.img
--config
empty
--arch
arm
--bootloader
empty
--flags
0x1
rm
-f
empty new-boot.img
mv
new-boot.img.signed new-boot.img
fi
$CHROMEOS
&&
sign_chromeos
./magiskboot
--cleanup
scripts/flash_script.sh
View file @
0eb79e5a
...
...
@@ -113,14 +113,6 @@ find_boot_image
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect boot image"
ui_print
"- Found Boot Image:
$BOOTIMAGE
"
# Update our previous backup to new format if exists
if
[
-f
/data/stock_boot.img
]
;
then
SHA1
=
`
$MAGISKBIN
/magiskboot
--sha1
/data/stock_boot.img 2>/dev/null
`
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
mv
/data/stock_boot.img
$STOCKDUMP
$MAGISKBIN
/magiskboot
--compress
$STOCKDUMP
fi
SOURCEDMODE
=
true
cd
$MAGISKBIN
...
...
scripts/magisk_uninstaller.sh
View file @
0eb79e5a
...
...
@@ -21,34 +21,13 @@
#
##########################################################################################
# Call ui_print_wrap if exists, or else simply use echo
# Useful when wrapped in flashable zip
ui_print_wrap
()
{
type
ui_print
>
/dev/null 2>&1
&&
ui_print
"
$1
"
||
echo
"
$1
"
}
# Call abort if exists, or else show error message and exit
# Essential when wrapped in flashable zip
abort_wrap
()
{
type
abort
>
/dev/null 2>&1
if
[
$?
-ne
0
]
;
then
ui_print_wrap
"
$1
"
exit
1
else
abort
"
$1
"
fi
}
[
-z
$BOOTMODE
]
&&
BOOTMODE
=
false
MAGISKBIN
=
/data/magisk
CHROMEDIR
=
$MAGISKBIN
/chromeos
# Default permissions
umask
022
if
[
!
-f
$MAGISKBIN
/magiskboot
-o
!
-f
$MAGISKBIN
/util_functions.sh
]
;
then
ui_print_wrap
"! Cannot find
$MAGISKBIN
"
echo
"! Cannot find
$MAGISKBIN
"
exit
1
fi
...
...
@@ -59,87 +38,73 @@ fi
find_boot_image
[
-z
$BOOTIMAGE
]
&&
abort
"! Unable to detect boot image"
ui_print
_wrap
"- Found Boot Image:
$BOOTIMAGE
"
ui_print
"- Found Boot Image:
$BOOTIMAGE
"
cd
$MAGISKBIN
ui_print
_wrap
"- Unpacking boot image"
ui_print
"- Unpacking boot image"
./magiskboot
--unpack
"
$BOOTIMAGE
"
CHROMEOS
=
false
case
$?
in
1
)
abort
_wrap
"! Unable to unpack boot image"
abort
"! Unable to unpack boot image"
;;
2
)
CHROMEOS
=
true
;;
3
)
ui_print
_wrap
"! Sony ELF32 format detected"
abort
_wrap
"! Please use BootBridge from @AdrianDC to flash Magisk"
ui_print
"! Sony ELF32 format detected"
abort
"! Please use BootBridge from @AdrianDC to flash Magisk"
;;
4
)
ui_print
_wrap
"! Sony ELF64 format detected"
abort
_wrap
"! Stock kernel cannot be patched, please use a custom kernel"
ui_print
"! Sony ELF64 format detected"
abort
"! Stock kernel cannot be patched, please use a custom kernel"
esac
# Update our previous backup to new format if exists
if
[
-f
/data/stock_boot.img
]
;
then
SHA1
=
`
./magiskboot
--sha1
/data/stock_boot.img 2>/dev/null
`
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
mv
/data/stock_boot.img
$STOCKDUMP
./magiskboot
--compress
$STOCKDUMP
fi
migrate_boot_backup
# Detect boot image state
./magiskboot
--cpio-test
ramdisk.cpio
case
$?
in
0
)
# Stock boot
ui_print_wrap
"- Stock boot image detected!"
ui_print_wrap
"! Magisk is not installed!"
exit
ui_print
"- Stock boot image detected!"
abort
"! Magisk is not installed!"
;;
1
)
# Magisk patched
ui_print
_wrap
"- Magisk patched image detected!"
ui_print
"- Magisk patched image detected!"
# Find SHA1 of stock boot image
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio-stocksha1
ramdisk.cpio
`
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio-stocksha1
ramdisk.cpio
2>/dev/null
`
[
!
-z
$SHA1
]
&&
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
if
[
-f
${
STOCKDUMP
}
.gz
]
;
then
ui_print
_wrap
"- Boot image backup found!"
./magiskboot
--decompress
${
STOCKDUMP
}
.gz
stock_
boot.img
ui_print
"- Boot image backup found!"
./magiskboot
--decompress
${
STOCKDUMP
}
.gz
new-
boot.img
else
ui_print
_wrap
"! Boot image backup unavailable"
ui_print
_wrap
"- Restoring ramdisk with
backup"
ui_print
"! Boot image backup unavailable"
ui_print
"- Restoring ramdisk with internal
backup"
./magiskboot
--cpio-restore
ramdisk.cpio
./magiskboot
--repack
$BOOTIMAGE
stock_
boot.img
./magiskboot
--repack
$BOOTIMAGE
new-
boot.img
fi
;;
2
)
# Other patched
ui_print
_wrap
"! Boot image patched by other programs!"
abort
_wrap
"! Cannot uninstall with this uninstaller
"
ui_print
"! Boot image patched by other programs!"
abort
"! Cannot uninstall
"
;;
esac
# Sign chromeos boot
if
$CHROMEOS
;
then
echo
>
empty
./chromeos/futility vbutil_kernel
--pack
stock_boot.img.signed
\
--keyblock
./chromeos/kernel.keyblock
--signprivate
./chromeos/kernel_data_key.vbprivk
\
--version
1
--vmlinuz
stock_boot.img
--config
empty
--arch
arm
--bootloader
empty
--flags
0x1
$CHROMEOS
&&
sign_chromeos
rm
-f
empty stock_boot.img
mv
stock_boot.img.signed stock_boot.img
fi
ui_print_wrap
"- Flashing stock/reverted image"
ui_print
"- Flashing stock/reverted image"
if
[
-L
"
$BOOTIMAGE
"
]
;
then
dd
if
=
stock_
boot.img
of
=
"
$BOOTIMAGE
"
bs
=
4096
dd
if
=
new-
boot.img
of
=
"
$BOOTIMAGE
"
bs
=
4096
else
cat
stock_
boot.img /dev/zero |
dd
of
=
"
$BOOTIMAGE
"
bs
=
4096
>
/dev/null 2>&1
cat
new-
boot.img /dev/zero |
dd
of
=
"
$BOOTIMAGE
"
bs
=
4096
>
/dev/null 2>&1
fi
rm
-f
stock_boot.img
rm
-f
new-boot.img
cd
/
ui_print
_wrap
"- Removing Magisk files"
ui_print
"- Removing Magisk files"
rm
-rf
/cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log /cache/.disable_magisk
\
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock /cache/magisk_uninstaller.sh
\
/data/Magisk.apk /data/magisk.apk /data/magisk.img /data/magisk_merge.img /data/magisk_debug.log
\
...
...
scripts/uninstaller_loader.sh
View file @
0eb79e5a
...
...
@@ -30,7 +30,6 @@ fi
# Load utility functions
.
$INSTALLER
/util_functions.sh
get_outfd
##########################################################################################
...
...
@@ -65,10 +64,7 @@ if is_mounted /data; then
# Copy the binaries to /data/magisk, in case they do not exist
rm
-rf
$MAGISKBIN
2>/dev/null
mkdir
-p
$MAGISKBIN
cp
-af
$BINDIR
/.
$MAGISKBIN
cp
-af
$CHROMEDIR
$MAGISKBIN
cp
-af
$TMPDIR
/bin/busybox
$MAGISKBIN
/busybox
cp
-af
$INSTALLER
/util_functions.sh
$MAGISKBIN
cp
-af
$BINDIR
/.
$CHROMEDIR
$TMPDIR
/bin/busybox
$INSTALLER
/util_functions.sh
$MAGISKBIN
chmod
-R
755
$MAGISKBIN
# Run the acttual uninstallation
recovery_actions
...
...
scripts/util_functions.sh
View file @
0eb79e5a
...
...
@@ -73,6 +73,33 @@ find_boot_image() {
[
-L
"
$BOOTIMAGE
"
]
&&
BOOTIMAGE
=
`
readlink
$BOOTIMAGE
`
}
migrate_boot_backup
()
{
# Update the broken boot backup
if
[
-f
/data/stock_boot_.img.gz
]
;
then
./magiskboot
--decompress
/data/stock_boot_.img.gz
mv
/data/stock_boot_.img /data/stock_boot.img
fi
# Update our previous backup to new format if exists
if
[
-f
/data/stock_boot.img
]
;
then
ui_print
"- Migrating boot image backup"
SHA1
=
`
./magiskboot
--sha1
/data/stock_boot.img 2>/dev/null
`
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
mv
/data/stock_boot.img
$STOCKDUMP
./magiskboot
--compress
$STOCKDUMP
fi
}
sign_chromeos
()
{
echo
>
empty
./chromeos/futility vbutil_kernel
--pack
new-boot.img.signed
\
--keyblock
./chromeos/kernel.keyblock
--signprivate
./chromeos/kernel_data_key.vbprivk
\
--version
1
--vmlinuz
new-boot.img
--config
empty
--arch
arm
--bootloader
empty
--flags
0x1
rm
-f
empty new-boot.img
mv
new-boot.img.signed new-boot.img
}
is_mounted
()
{
if
[
!
-z
"
$2
"
]
;
then
cat
/proc/mounts |
grep
$1
|
grep
$2
,
>
/dev/null
...
...
@@ -127,7 +154,6 @@ boot_actions() {
mount
-o
bind
$MAGISKBIN
/dev/magisk/mirror/bin
fi
MAGISKBIN
=
/dev/magisk/mirror/bin
$MAGISKBIN
/magisk magiskpolicy
--live
"allow fsck * * *"
}
recovery_actions
()
{
...
...
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