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
8cf475f7
Commit
8cf475f7
authored
Sep 03, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add scripts to setup Magisk in AVD
parent
0cb449e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
emulator.sh
scripts/emulator.sh
+79
-0
No files found.
scripts/emulator.sh
0 → 100755
View file @
8cf475f7
#!/usr/bin/env bash
################################################################
# AVD Magisk Setup
################################################################
#
# This script will setup an environment with minimal Magisk that
# Magisk Manager will be happy to run properly within the official
# emulator bundled with Android Studio (AVD).
#
# ONLY use this script for developing Magisk Manager in the
# emulator. The constructed Magisk environment is not a fully
# functional one as if it is running on an actual device.
# The script only supports non system-as-root images, meaning
# AVD images that are newer than API 25 are NOT supported.
# This script is meant to be used for emulators running obscure
# Android versions; use an actual device for modern Androids.
#
# The script assumes you are using x86 emulator images.
# Build binaries with `./build.py binary` before running this script.
#
################################################################
abort
()
{
echo
"
$@
"
exit
1
}
if
[
!
-f
/system/build.prop
]
;
then
# Running on PC
cd
"
`
dirname
"
$0
"
`
/.."
adb push native/out/x86/busybox native/out/x86/magisk scripts/emulator.sh /data/local/tmp
adb root
||
abort
'adb root failed'
adb shell sh /data/local/tmp/emulator.sh
exit
0
fi
cd
/data/local/tmp
chmod
777 busybox
# Currently only support rootfs based emulators
./busybox mount | ./busybox
grep
-q
rootfs
||
abort
'Only support non system-as-root emulators'
# Emulator's adb shell should have root
[
`
./busybox
id
-u
`
-eq
0
]
||
abort
'ADB shell should have root access'
# Check whether already setup
[
-f
/sbin/magisk
]
&&
abort
"Magisk is already setup"
# First setup a good env to work with
rm
-rf
bin
./busybox
mkdir
bin
./busybox
--install
-s
bin
OLD_PATH
=
"
$PATH
"
PATH
=
"/data/local/tmp/bin:
$PATH
"
# Setup sbin mirror
mount
-o
rw,remount /
rm
-rf
/root
mkdir
/root
chmod
750 /root
ln
/sbin/
*
/root
mount
-o
ro,remount /
# Setup sbin overlay
mount
-t
tmpfs tmpfs /sbin
chmod
755 /sbin
ln
-s
/root/
*
/sbin
cp
./magisk /sbin/magisk
chmod
755 /sbin/magisk
ln
-s
./magisk /sbin/su
mkdir
-p
/sbin/.magisk/busybox
cp
-af
./busybox /sbin/.magisk/busybox/busybox
/sbin/.magisk/busybox/busybox
--install
-s
/sbin/.magisk/busybox
# Magisk stuffs
mkdir
-p
/data/adb/modules 2>/dev/null
mkdir
/data/adb/post-fs-data.d 2>/dev/null
mkdir
/data/adb/services.d 2>/dev/null
magisk
--daemon
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