-
Notifications
You must be signed in to change notification settings - Fork 6
/
redroid_init.sh
executable file
·185 lines (157 loc) · 5.47 KB
/
redroid_init.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
#!/bin/bash
# Config Variables
managePackages=true
manageSetup=true
manageDockerCompose=true
managePm2=true
manageRedroid=true
# Update and install required packages
if $managePackages ; then
apt update -y
apt upgrade -y
apt install docker.io docker-compose npm adb git python3 dos2unix -y
npm install pm2 -g
# Set up environment for redroid
apt install linux-modules-extra-`uname -r` -y
modprobe binder_linux devices="binder,hwbinder,vndbinder"
fi
# Let's get some info
if $manageSetup ; then
read -p "[Required] Cosmog Auth Token: " cosmogToken
if [ -z $cosmogToken ] ; then
echo "Cosmog Token cannot be empty"
exit 1
fi
read -p "[Required] Rotom Worker Endpoint (Port 7070): " rotomWorker
if [ -z $rotomWorker ] ; then
echo "Worker Endpoint cannot be empty"
exit 1
fi
read -p "[Required] Rotom Device Endpoint (Port 7070/control): " rotomDevice
if [ -z $rotomDevice ] ; then
echo "Device Endpoint cannot be empty"
exit 1
fi
read -p "[Required] Rotom API Endpoint (Port 7072): " rotomApi
if [ -z $rotomApi ] ; then
echo "API Endpoint cannot be empty"
exit 1
fi
read -p "[Optional] Rotom Basic Auth Username (''): " rotomUser
rotomUser=${rotomUser:-''}
read -p "[Optional] Rotom Basic Auth Password (''): " rotomPass
rotomPass=${rotomPass:-''}
read -p "[Optional] Rotom Secret? (''): " rotomSecret
rotomSecret=${rotomSecret:-''}
read -p "[Optional] Device Basename? (Virtual): " deviceBase
deviceBase=${deviceBase:-Virtual}
read -p "[Optional] Starting Increment? (1): " deviceNumber
deviceNumber=${deviceNumber:-1}
read -p "[Optional] Public IP? (127.0.0.1): " publicIp
publicIp=${publicIp:-127.0.0.1}
read -p "[Optional] Worker Count? (15): " cosmogWorkers
cosmogWorkers=${cosmogWorkers:-15}
read -p "[Optional] How many instances? (3): " instanceCount
instanceCount=${instanceCount:-3}
read -p "[Optional] Starting Port? (5555): " startingPort
startingPort=${startingPort:-5555}
read -p "[Optional] PoGo Version? (0.307.1): " version
version=${version:-0.307.1}
# Now the setup
port=$startingPort
cd ~/
mkdir -p cosmog/configs
cd cosmog
wget 'https://meow.sylvie.fyi/static/cosmog.apk' -O cosmog.apk
git clone https://github.com/sy1vi3/joltik.git
cd joltik
python3 joltik.py --version "$version"
cp arm64-v8a/libNianticLabsPlugin.so ../
cd ../
git clone https://github.com/sy1vi3/houndour.git
echo "" > houndour/startup.sh
echo "#!/bin/bash
sudo modprobe binder_linux devices="binder,hwbinder,vndbinder"
sudo docker-compose -f ~/cosmog/docker-compose.yml down
sudo docker-compose -f ~/cosmog/docker-compose.yml up -d" >> houndour/startup.sh
echo "{
\"devices\":{" > houndour/houndour.json
echo "services:" >> docker-compose.yml
for i in `seq $instanceCount` ; do
echo " redroid${i}:
privileged: true
volumes:
- ./data${i}:/data
ports:
- 127.0.0.1:${port}:5555
command:
- androidboot.redroid_gpu_mode=guest
- androidboot.use_memfd=true
container_name: redroid${i}
image: 'abing7k/redroid:a11_magisk_arm'
restart: always" >> docker-compose.yml
echo "{
\"device_id\": \"${deviceBase}${deviceNumber}\",
\"rotom_worker_endpoint\": \"${rotomWorker}\",
\"rotom_device_endpoint\": \"${rotomDevice}\",
\"use_local_safetynet\": false,
\"public_ip\": \"${publicIp}\",
\"workers\": ${cosmogWorkers},
\"token\": \"${cosmogToken}\",
\"rotom_secret\": \"${rotomSecret}\",
\"injection_delay_ms\": 5000,
\"pogo_heartbeat_timeout_ms\": 5000,
\"concurrent_login_override\": 6,
\"worker_spawn_delay_override\": 3500
}" >> configs/${i}.json
echo "#!/bin/bash
adb connect localhost:${port}
adb -s localhost:${port} push ./configs/${i}.json /data/local/tmp/cosmog.json
adb -s localhost:${port} shell am start -n com.nianticlabs.pokemongo.ares/com.nianticlabs.pokemongo.ares.MainActivity
sleep 10
" >> send_configs.sh
echo "localhost:${port}" >> vm.txt
echo " \"${deviceBase}${deviceNumber}\": {
\"dockerName\": \"redroid${i}\"
}," >> houndour/houndour.json
port=$(( $port + 1 ))
deviceNumber=$(( $deviceNumber + 1 ))
done
chmod +x send_configs.sh
sed -i '$ s/},/}/' houndour/houndour.json
echo " },
\"check_interval\": 60,
\"timeout_limit\": 5,
\"rotom_url\": \"http://${rotomApi}\",
\"rotom_user\": \"${rotomUser}\",
\"rotom_pass\": \"${rotomPass}\",
\"startup_script_path\": \"./startup.sh\"
}" >> houndour/houndour.json
fi
if $manageDockerCompose ; then
docker-compose up -d
if [ ! -d data1 ] ; then
echo "Something happened. Trying again"
docker-compose down ; docker-compose up -d
fi
echo "Docker up"
fi
if $manageRedroid ; then
# Let's pull in some help
wget 'https://raw.githubusercontent.com/cosmog-org/config-scripts/main/redroid_device.sh' -O redroid_device.sh
wget 'https://raw.githubusercontent.com/cosmog-org/config-scripts/main/redroid_host.sh' -O redroid_host.sh
chmod +x redroid_device.sh
chmod +x redroid_host.sh
dos2unix redroid_device.sh
dos2unix redroid_host.sh
# Give the containers some time
sleep 30
./redroid_host.sh
fi
if $managePm2 ; then
pm2 start ./send_configs.sh --restart-delay 20000
echo "PM2 Up"
cd ~/cosmog/houndour
pm2 start "python3 houndour.py" --name houndour
cd ~/cosmog
fi