-
Notifications
You must be signed in to change notification settings - Fork 2
/
magisk
executable file
·179 lines (168 loc) · 6.78 KB
/
magisk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash
SYSTEM=$(cat /var/lib/waydroid/waydroid.cfg | grep images_path | cut -d' ' -f 3)/system.img
VENDOR=$(cat /var/lib/waydroid/waydroid.cfg | grep images_path | cut -d' ' -f 3)/vendor.img
ARCH=$(cat /var/lib/waydroid/waydroid.cfg | grep arch | cut -d' ' -f 3)
arg1=""
arg2=""
if ! [ -z "$1" ]; then
arg1="$1"
fi
if ! [ -z "$2" ]; then
arg2="$2"
fi
function prep() {
echo "Hi, welcome to simple Magisk Delta installer for Waydroid"
if ! [[ $ARCH = "x86_64" || $ARCH = "arm64" ]]; then
echo "Sorry but," $ARCH "is not supported yet, by this script! Quitting."
exit
fi
}
function waydroid_down() {
echo "Stopping waydroid!"
waydroid session stop
sudo waydroid container stop
if grep -Fxq "runit" /tmp/init.txt; then
sudo sv down waydroid-container
else
sudo systemctl stop waydroid-container.service
fi
}
function rm_magisk() {
echo "Removing any previous installation of Magisk"
sudo rm -rf ~/.local/share/waydroid/data/adb/lspd
sudo rm -rf ~/.local/share/waydroid/data/adb/magisk
sudo rm -rf ~/.local/share/waydroid/data/adb/magisk.db
sudo rm -rf ~/.local/share/waydroid/data/adb/post-fs-data.d
sudo rm -rf ~/.local/share/waydroid/data/adb/service.d
sudo rm -rf ~/.local/share/waydroid/data/data/io.github.huskydg.magisk
sudo rm -rf ~/.local/share/waydroid/data/data/io.github.huskydg.magisk.png
sudo rm -rf /var/lib/waydroid/overlay/sbin/*
sudo rm -rf /var/lib/waydroid/overlay/system/etc/init/bootanim.rc
sudo rm -rf /var/lib/waydroid/overlay/system/etc/init/bootanim.rc.gz
sudo rm -rf /var/lib/waydroid/overlay/system/etc/init/magisk
sudo rm -rf /var/lib/waydroid/overlay/system/addon.d
sudo rm -rf /var/lib/waydroid/overlay_rw/system/sbin/.magisk
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/etc/init/bootanim.rc
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/etc/init/bootanim.rc.gz
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/etc/init/magisk
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/addon.d
sudo rm -rf /var/lib/waydroid/overlay_rw/vendor/etc/selinux/*
}
function del_magisk() {
echo "Removing Magisk!"
sudo rm -rf ~/.local/share/waydroid/data/adb/lspd
sudo rm -rf ~/.local/share/waydroid/data/adb/magisk
sudo rm -rf ~/.local/share/waydroid/data/adb/magisk.db
sudo rm -rf ~/.local/share/waydroid/data/adb/modules
sudo rm -rf ~/.local/share/waydroid/data/adb/post-fs-data.d
sudo rm -rf ~/.local/share/waydroid/data/adb/service.d
sudo rm -rf ~/.local/share/waydroid/data/data/io.github.huskydg.magisk
sudo rm -rf ~/.local/share/waydroid/data/data/io.github.huskydg.magisk.png
sudo rm -rf /var/lib/waydroid/overlay/sbin/*
sudo rm -rf /var/lib/waydroid/overlay/system/etc/init/bootanim.rc
sudo gzip -dk /var/lib/waydroid/overlay/system/etc/init/bootanim.rc.gz
sudo rm -rf /var/lib/waydroid/overlay/system/etc/init/magisk
sudo rm -rf /var/lib/waydroid/overlay/system/addon.d
sudo rm -rf /var/lib/waydroid/overlay_rw/system/sbin/.magisk
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/etc/init/bootanim.rc
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/etc/init/bootanim.rc.gz
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/etc/init/magisk
sudo rm -rf /var/lib/waydroid/overlay_rw/system/system/addon.d
sudo rm -rf /var/lib/waydroid/overlay_rw/vendor/etc/selinux/precompiled_sepolicy
sudo gzip -dk /var/lib/waydroid/overlay_rw/vendor/etc/selinux/precompiled_sepolicy.gz
}
function res_magisk() {
echo "Reseting Magisk and removing all modules!"
sudo rm -rf ~/.local/share/waydroid/data/adb/lspd
sudo rm -rf ~/.local/share/waydroid/data/adb/magisk.db
sudo rm -rf ~/.local/share/waydroid/data/adb/modules
sudo rm -rf ~/.local/share/waydroid/data/adb/post-fs-data.d
sudo rm -rf ~/.local/share/waydroid/data/adb/service.d
}
function resize_images() {
echo "Resizing images"
sudo e2fsck -yf $SYSTEM
sudo resize2fs $SYSTEM 3G
sudo e2fsck -yf $VENDOR
sudo resize2fs $VENDOR 1G
}
function install_magisk() {
echo "Downloading magisk"
if [ $ARCH = "arm64" ]; then
wget -q https://storage.googleapis.com/mistrmochov/magiskWaydroid/magiskarm64_1.0.tar.gz -O /tmp/magisk.tar.gz
else
wget -q https://storage.googleapis.com/mistrmochov/magiskWaydroid/magisk_1.0.tar.gz -O /tmp/magisk.tar.gz
fi
echo "Unpacking magisk"
if [ -f /tmp/magisk.tar.gz ]; then
rm_magisk
sudo tar -xf /tmp/magisk.tar.gz -C /tmp
echo "Copying files!"
if [ $ARCH = "x86_64" ]; then
sudo cp -r /tmp/magisk/overlay /var/lib/waydroid/
sudo cp -r /tmp/magisk/overlay_rw /var/lib/waydroid/
if [[ "$arg2" = "--modules" || "$arg1" = "--modules" ]]; then
sudo cp -r /tmp/magisk/data_modules/* ~/.local/share/waydroid/data/
else
sudo cp -r /tmp/magisk/data ~/.local/share/waydroid/
fi
else
sudo cp -r /tmp/magisk/overlay /var/lib/waydroid/
sudo cp -r /tmp/magisk/data ~/.local/share/waydroid/
fi
sudo rm -rf /tmp/magisk /tmp/magisk.tar.gz
else
echo "Sorry but the magisk couldn't be downloaded, please try again later!"
fi
}
function waydroid_up() {
echo "Starting waydroid-container.service"
if grep -Fxq "runit" /tmp/init.txt; then
sudo sv up waydroid-container
else
sudo systemctl start waydroid-container.service
fi
}
function install() {
touch /tmp/init.txt
ps -p 1 -o command >/tmp/init.txt
waydroid_down
resize_images
install_magisk
waydroid_up
echo "Installation has finished, now start up waydroid and after waydroid fully boots and If magisk was successfully installed then just simply reboot your Waydroid or proceed direct install to system through Magisk app. Enjoy Magisk <3"
rm /tmp/init.txt
}
function promt() {
if [ "$arg1" = "" ]; then
echo "Please provide an argument: install/install --modules/remove/reset"
else
if [ "$arg1" = "install" ]; then
install
elif [ "$arg1" = "--modules" ]; then
if [ "$arg2" = "install" ]; then
install
else
echo "Bad arguments"
fi
elif [[ "$arg1" = "remove" || "$arg1" = "reset" ]]; then
touch /tmp/init.txt
ps -p 1 -o command >/tmp/init.txt
waydroid_down
if [ "$arg1" = "reset" ]; then
res_magisk
echo "Magisk has been restored."
else
del_magisk
echo "Magisk has been removed."
fi
waydroid_up
rm -rf /tmp/init.txt
else
echo "Bad arguments"
fi
fi
}
prep
promt
echo "Quitting"