forked from geeks-r-us/anbox-playstore-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntutouchanbox-installplaystore.sh
193 lines (152 loc) · 5.5 KB
/
ubuntutouchanbox-installplaystore.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
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
# Copyright 2018 [email protected]
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# For further information see: http://geeks-r-us.de/2017/08/26/android-apps-auf-dem-linux-desktop/
# If you find this piece of software useful and or want to support it's development think of
# buying me a coffee https://www.buymeacoffee.com/YdV7B1rex
# die when an error occurs
set -e
#OPENGAPPS_URL="https://github.com/opengapps/x86_64/releases/download/$OPENGAPPS_RELEASEDATE/$OPENGAPPS_FILE"
OPENGAPPS_RELEASEDATE="20190209"
OPENGAPPS_FILE="open_gapps-arm-7.1-mini-$OPENGAPPS_RELEASEDATE.zip"
####SWITCH FOR TESTING#####
OVERLAYDIR="/home/phablet/anbox-data/rootfs"
SYSTEMDIR="/home/phablet/anbox-data"
WORKDIR="/home/phablet/anbox-work"
######
IMGFILE="$SYSTEMDIR/android.img"
APPDIR="$OVERLAYDIR/system/priv-app"
BINDIR="$OVERLAYDIR/system/bin"
LIBDIR="$OVERLAYDIR/system/lib"
PERMDIR="$OVERLAYDIR/system/etc/permissions/"
#setup google play services +google play permissions after script
#SETUP "Create $WORKDIR with $OPENGAPPS_FILE", run anbox.appmgr once(click settings), install required dependencies, check guide updates, set opengapps release date, testing(recreate anbox-data+anbox-work using new files+device files,check filesystem(unsquashfs -s android.img))
# 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
if [ ! -f "$SYSTEMDIR/android.img" ]; then
echo -e "No android.img at $SYSTEMDIR"
exit 1
fi
if [ ! -d "$WORKDIR" ]; then
echo -e "Create $WORKDIR with $OPENGAPPS_FILE"
exit 1
fi
if [ ! -d "$APPDIR" ]; then
echo -e "$OVERLAYDIR doesn't contain $APPDIR!"
exit 1
fi
if [ ! -d "$BINDIR" ]; then
echo -e "$OVERLAYDIR doesn't contain $BINDIR!"
exit 1
fi
if [ ! -d "$PERMDIR" ]; then
echo -e "$OVERLAYDIR doesn't contain $PERMDIR!"
exit 1
fi
if [ ! -d "$LIBDIR" ]; then
echo -e "$OVERLAYDIR doesn't contain $LIBDIR!"
exit 1
fi
if [ ! -f "$WORKDIR/$OPENGAPPS_FILE" ]; then
echo -e "Place $OPENGAPPS_FILE in $WORKDIR"
exit 1
fi
if [ ! -d "$OVERLAYDIR" ]; then
echo -e "Anbox-data/rootfs folder not found at $OVERLAYDIR"
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
$SUDO anbox-tool disable
sudo mount -o rw,remount /
cd "$WORKDIR"
if [ -d "$WORKDIR/squashfs-root" ]; then
$SUDO rm -rf squashfs-root
fi
#get image from anbox
cp "$SYSTEMDIR/android.img" .
$SUDO $UNSQUASHFS android.img
# get opengapps and install it
cd "$WORKDIR"
$UNZIP -d opengapps ./$OPENGAPPS_FILE
cd ./opengapps/Core/
for filename in *.tar.lz
do
$TAR --lzip -xvf ./$filename
done
cd "$WORKDIR"
APPDIR="$WORKDIR/squashfs-root/system/priv-app"
$SUDO cp -r ./$(find opengapps -type d -name "PrebuiltGmsCore") $APPDIR
$SUDO cp -r ./$(find opengapps -type d -name "GoogleLoginService") $APPDIR
$SUDO cp -r ./$(find opengapps -type d -name "Phonesky") $APPDIR
$SUDO cp -r ./$(find opengapps -type d -name "GoogleServicesFramework") $APPDIR
cd "$APPDIR"
$SUDO chown -R 100000:100000 Phonesky GoogleLoginService GoogleServicesFramework PrebuiltGmsCore
cd "$WORKDIR"
mv android.img androidbackup.img
sudo mksquashfs squashfs-root android.img -comp xz -no-xattrs -b 131072 -Xbcj arm
sudo rm -r squashfs-root
sudo cp android.img "$SYSTEMDIR"
sudo chown root:root "$SYSTEMDIR/android.img"
sudo rm android.img
sudo mount -o ro,remount /
$SUDO anbox-tool enable