This repository has been archived by the owner on Jan 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3daccel-anbox.sh
executable file
·182 lines (145 loc) · 5.8 KB
/
3daccel-anbox.sh
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
180
181
182
set -e
OPENGAPPS_RELEASEDATE="20180706"
OPENGAPPS_FILE="open_gapps-x86_64-7.1-mini-$OPENGAPPS_RELEASEDATE.zip"
OPENGAPPS_URL="https://github.com/opengapps/x86_64/releases/download/$OPENGAPPS_RELEASEDATE/$OPENGAPPS_FILE"
HOUDINI_URL="http://dl.android-x86.org/houdini/7_y/houdini.sfs"
HOUDINI_SO="https://github.com/Rprop/libhoudini/raw/master/4.0.8.45720/system/lib/libhoudini.so"
WORKDIR="$(pwd)/anbox-work"
# check if script was started with BASH
if [ ! "$(ps -p $$ -oargs= | awk '{print $1}' | grep -E 'bash$')" ]; then
echo "Please use BASH to start the script!"
exit 1
fi
# check if user is root
if [ "$(whoami)" != "root" ]; then
echo "Sorry, you are not root. Please run with sudo $0"
exit 1
fi
# check if lzip is installed
if [ ! "$(which lzip)" ]; then
echo -e "lzip is not installed. Please install lzip.\nExample: sudo apt install lzip"
exit 1
fi
# check if squashfs-tools are installed
if [ ! "$(which mksquashfs)" ] || [ ! "$(which unsquashfs)" ]; then
echo -e "squashfs-tools is not installed. Please install squashfs-tools.\nExample: sudo apt install squashfs-tools"
exit 1
else
MKSQUASHFS=$(which mksquashfs)
UNSQUASHFS=$(which unsquashfs)
fi
# check if wget is installed
if [ ! "$(which wget)" ]; then
echo -e "wget is not installed. Please install wget.\nExample: sudo apt install wget"
exit 1
else
WGET=$(which wget)
fi
# check if unzip is installed
if [ ! "$(which unzip)" ]; then
echo -e "unzip is not installed. Please install unzip.\nExample: sudo apt install unzip"
exit 1
else
UNZIP=$(which unzip)
fi
# check if tar is installed
if [ ! "$(which tar)" ]; then
echo -e "tar is not installed. Please install tar.\nExample: sudo apt install tar"
exit 1
else
TAR=$(which tar)
fi
# use sudo if installed
if [ ! "$(which sudo)" ]; then
SUDO=""
else
SUDO=$(which sudo)
fi
echo $WORKDIR
if [ ! -d "$WORKDIR" ]; then
mkdir "$WORKDIR"
fi
cd "$WORKDIR"
if [ -d "$WORKDIR/squashfs-root" ]; then
$SUDO rm -rf squashfs-root
fi
# get image from anbox
cp /var/lib/anbox/android.img .
$SUDO $UNSQUASHFS android.img
# get opengapps and install it
cd "$WORKDIR"
if [ ! -f ./$OPENGAPPS_FILE ]; then
$WGET -q --show-progress $OPENGAPPS_URL
$UNZIP -d opengapps ./$OPENGAPPS_FILE
fi
cd ./opengapps/Core/
for filename in *.tar.lz
do
$TAR --lzip -xvf ./$filename
done
cd "$WORKDIR"
$SUDO cp -r ./$(find opengapps -type d -name "PrebuiltGmsCore") ./squashfs-root/system/priv-app/
$SUDO cp -r ./$(find opengapps -type d -name "GoogleLoginService") ./squashfs-root/system/priv-app/
$SUDO cp -r ./$(find opengapps -type d -name "Phonesky") ./squashfs-root/system/priv-app/
$SUDO cp -r ./$(find opengapps -type d -name "GoogleServicesFramework") ./squashfs-root/system/priv-app/
cd ./squashfs-root/system/priv-app/
$SUDO chown -R 100000:100000 Phonesky GoogleLoginService GoogleServicesFramework PrebuiltGmsCore
# load houdini and spread it
cd "$WORKDIR"
if [ ! -f ./houdini.sfs ]; then
$WGET -q --show-progress $HOUDINI_URL
mkdir -p houdini
$SUDO $UNSQUASHFS -f -d ./houdini ./houdini.sfs
fi
$SUDO cp -r ./houdini/houdini ./squashfs-root/system/bin/
$SUDO cp -r ./houdini/xstdata ./squashfs-root/system/bin/
$SUDO chown -R 100000:100000 ./squashfs-root/system/bin/houdini ./squashfs-root/system/bin/xstdata
$SUDO $WGET -q --show-progress -P ./squashfs-root/system/lib/ $HOUDINI_SO
$SUDO chown -R 100000:100000 ./squashfs-root/system/lib/libhoudini.so
$SUDO mkdir -p ./squashfs-root/system/lib/arm
$SUDO cp -r ./houdini/linker ./squashfs-root/system/lib/arm
$SUDO cp -r ./houdini/*.so ./squashfs-root/system/lib/arm
$SUDO cp -r ./houdini/nb ./squashfs-root/system/lib/arm/
$SUDO chown -R 100000:100000 ./squashfs-root/system/lib/arm
# add houdini parser
mkdir -p ./squashfs-root/system/etc/binfmt_misc
echo ":arm_dyn:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x28::/system/bin/houdini:" >> ./squashfs-root/system/etc/binfmt_misc/arm_dyn
echo ":arm_exe:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28::/system/bin/houdini:" >> ./squashfs-root/system/etc/binfmt_misc/arm_exe
$SUDO chown -R 100000:100000 ./squashfs-root/system/etc/binfmt_misc
# add features
C=$(cat <<-END
<feature name="android.hardware.touchscreen" />\n
<feature name="android.hardware.audio.output" />\n
<feature name="android.hardware.camera" />\n
<feature name="android.hardware.camera.any" />\n
<feature name="android.hardware.location" />\n
<feature name="android.hardware.location.gps" />\n
<feature name="android.hardware.location.network" />\n
<feature name="android.hardware.microphone" />\n
<feature name="android.hardware.screen.portrait" />\n
<feature name="android.hardware.screen.landscape" />\n
<feature name="android.hardware.wifi" />\n
<feature name="android.hardware.bluetooth" />"
END
)
C=$(echo $C | sed 's/\//\\\//g')
C=$(echo $C | sed 's/\"/\\\"/g')
$SUDO sed -i "/<\/permissions>/ s/.*/${C}\n&/" ./squashfs-root/system/etc/permissions/anbox.xml
# make wifi and bt available
$SUDO sed -i "/<unavailable-feature name=\"android.hardware.wifi\" \/>/d" ./squashfs-root/system/etc/permissions/anbox.xml
$SUDO sed -i "/<unavailable-feature name=\"android.hardware.bluetooth\" \/>/d" ./squashfs-root/system/etc/permissions/anbox.xml
# set processors
ARM_TYPE=",armeabi-v7a,armeabi"
$SUDO sed -i "/^ro.product.cpu.abilist=x86_64,x86/ s/$/${ARM_TYPE}/" ./squashfs-root/system/build.prop
$SUDO sed -i "/^ro.product.cpu.abilist32=x86/ s/$/${ARM_TYPE}/" ./squashfs-root/system/build.prop
$SUDO echo "persist.sys.nativebridge=1" >> ./squashfs-root/system/build.prop
# enable opengles
$SUDO echo "ro.opengles.version=131072" >> ./squashfs-root/system/build.prop
#squash img
cd "$WORKDIR"
rm android.img
$SUDO $MKSQUASHFS squashfs-root android.img -b 131072 -comp xz -Xbcj x86
# update anbox image
cd /var/lib/anbox
mv android.img android_bkup.img
mv "$WORKDIR/android.img" android.img