This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
forked from Kneckter/aconf-rdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgocheats.sh
424 lines (372 loc) · 20.4 KB
/
gocheats.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
#!/system/bin/sh
# version 1.5.10
#Version checks
Ver55gocheats="1.0"
Ver55cron="1.3"
export ANDROID_DATA=/data
export ANDROID_ROOT=/system
#Create logfile
if [ ! -e /data/local/tmp/gcconf.log ] ;then
/system/bin/touch /data/local/tmp/gcconf.log
fi
logfile="/data/local/tmp/gcconf.log"
gcconf="/data/local/tmp/config.json"
gcconf_versions="/data/local/gcconf_versions"
[[ -f /data/local/gcconf_download ]] && gcconf_download=$(/system/bin/grep url /data/local/gcconf_download | awk -F "=" '{ print $NF }')
[[ -f /data/local/gcconf_download ]] && gcconf_user=$(/system/bin/grep authUser /data/local/gcconf_download | awk -F "=" '{ print $NF }')
[[ -f /data/local/gcconf_download ]] && gcconf_pass=$(/system/bin/grep authPass /data/local/gcconf_download | awk -F "=" '{ print $NF }')
if [[ -f /data/local/tmp/config.json ]] ;then
origin=$(/system/bin/cat $gcconf | /system/bin/tr , '\n' | /system/bin/grep -w 'device_name' | awk -F "\"" '{ print $4 }')
else
origin=$(/system/bin/cat /data/local/initDName)
fi
# stderr to logfile
exec 2>> $logfile
# add gocheats.sh command to log
echo "" >> $logfile
echo "`date +%Y-%m-%d_%T` ## Executing $(basename $0) $@" >> $logfile
########## Functions
reboot_device(){
echo "`date +%Y-%m-%d_%T` Reboot device" >> $logfile
sleep 60
/system/bin/reboot
}
case "$(uname -m)" in
aarch64) arch="arm64-v8a";;
armv8l) arch="armeabi-v7a";;
esac
install_gocheats(){
# install 55gocheats
mount -o remount,rw /system
mount -o remount,rw /system/etc || true
mount -o remount,rw /system/etc/init.d || true
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55gocheats https://raw.githubusercontent.com/andi2022/gcconf/master/55gocheats || { echo "`date +%Y-%m-%d_%T` Download 55gcconf failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/etc/init.d/55gocheats
echo "`date +%Y-%m-%d_%T` 55gocheats installed, from master" >> $logfile
# install 55cron
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55cron https://raw.githubusercontent.com/andi2022/gcconf/master/55cron || { echo "`date +%Y-%m-%d_%T` Download 55cron failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/etc/init.d/55cron
echo "`date +%Y-%m-%d_%T` 55cron installed, from master" >> $logfile
# install cron job
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/ping_test.sh https://raw.githubusercontent.com/andi2022/gcconf/master/ping_test.sh || { echo "`date +%Y-%m-%d_%T` Download ping_test.sh failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/bin/ping_test.sh
mkdir /data/crontabs || true
touch /data/crontabs/root
echo "15 * * * * /system/bin/ping_test.sh" > /data/crontabs/root
echo "0 23 * * * /system/bin/gocheats.sh -ua" >> /data/crontabs/root
crond -b -c /data/crontabs
mount -o remount,ro /system
# Remove any old MAD files
/system/bin/rm -f 01madbootstrap 42mad 16mad
# get version
gcversions=$(/system/bin/grep 'gocheats' $gcconf_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
# download gocheats
/system/bin/rm -f /sdcard/Download/gocheats.apk
until $download /sdcard/Download/gocheats.apk $gcconf_download/com.gocheats.launcher_v$gcversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/gocheats.apk $gcconf_download/com.gocheats.launcher_v$gcversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download gocheats failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# let us kill pogo as well and clear data
/system/bin/am force-stop com.nianticlabs.pokemongo
/system/bin/pm clear com.nianticlabs.pokemongo
# Install gocheats
/system/bin/pm install -r /sdcard/Download/gocheats.apk
/system/bin/rm -f /sdcard/Download/gocheats.apk
echo "`date +%Y-%m-%d_%T` gocheats installed" >> $logfile
# Grant su access + settings
guid="$(dumpsys package com.gocheats.launcher | /system/bin/grep userId | awk -F'=' '{print $2}')"
magisk --sqlite "DELETE from policies WHERE package_name='com.gocheats.launcher'"
magisk --sqlite "INSERT INTO policies (uid,package_name,policy,until,logging,notification) VALUES($guid,'com.gocheats.launcher',2,0,1,0)"
/system/bin/pm grant com.gocheats.launcher android.permission.READ_EXTERNAL_STORAGE
/system/bin/pm grant com.gocheats.launcher android.permission.WRITE_EXTERNAL_STORAGE
echo "`date +%Y-%m-%d_%T` gocheats granted su and settings set" >> $logfile
# download gocheats config file and adjust orgin to rgc setting
install_config
# check pogo version else remove+install
downgrade_pogo
# start gocheats
/system/bin/monkey -p com.gocheats.launcher 1
sleep 15
# Set for reboot device
reboot=1
}
install_config(){
until $download /data/local/tmp/config.json $gcconf_download/config.json || { echo "`date +%Y-%m-%d_%T` $download /data/local/tmp/config.json $gcconf_download/config.json" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download gocheats config file failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
/system/bin/sed -i 's,dummy,'$origin',g' $gcconf
echo "`date +%Y-%m-%d_%T` gocheats config installed, device_name $origin" >> $logfile
}
update_all(){
pinstalled=$(dumpsys package com.nianticlabs.pokemongo | /system/bin/grep versionName | head -n1 | /system/bin/sed 's/ *versionName=//')
pversions=$(/system/bin/grep 'pogo' $gcconf_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
gcinstalled=$(dumpsys package com.gocheats.launcher | /system/bin/grep versionName | head -n1 | /system/bin/sed 's/ *versionName=//')
gcversions=$(/system/bin/grep 'gocheats' $gcconf_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
eminstalled=$(cat /data/adb/modules/emagisk/module.prop | /system/bin/grep version | head -n1 | /system/bin/sed 's/ *version=v//')
emversions=$(/system/bin/grep 'emagiskversion' $gcconf_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
emstatus=$(/system/bin/grep 'emagiskstatus' $gcconf_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
if [[ "$pinstalled" != "$pversions" ]] ;then
echo "`date +%Y-%m-%d_%T` New pogo version detected, $pinstalled=>$pversions" >> $logfile
/system/bin/rm -f /sdcard/Download/pogo.apk
until $download /sdcard/Download/pogo.apk $gcconf_download/pokemongo_$arch\_$pversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/pogo.apk $gcconf_download/pokemongo_$arch\_$pversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download pogo failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# set pogo to be installed
pogo_install="install"
else
pogo_install="skip"
echo "`date +%Y-%m-%d_%T` PoGo already on correct version" >> $logfile
fi
if [ "$gcinstalled" != "$gcversions" ] ;then
echo "`date +%Y-%m-%d_%T` New gocheats version detected, $gcinstalled=>$gcversions" >> $logfile
/system/bin/rm -f /sdcard/Download/gocheats.apk
until $download /sdcard/Download/gocheats.apk $gcconf_download/com.gocheats.launcher_v$gcversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/gocheats.apk $gcconf_download/com.gocheats.launcher_v$gcversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download gocheats failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# set gocheats to be installed
gocheats_install="install"
else
gocheats_install="skip"
echo "`date +%Y-%m-%d_%T` gocheats already on correct version" >> $logfile
fi
if [[ $emstatus == "on" ]] && [ "$eminstalled" != "$emversions" ] ;then
echo "`date +%Y-%m-%d_%T` New emagisk version detected, $eminstalled=>$emversions" >> $logfile
/system/bin/rm -f /sdcard/Download/emagisk.zip
until $download /sdcard/Download/emagisk.zip $gcconf_download/eMagisk-$emversions.zip || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/emagisk.zip $gcconf_download/eMagisk-$emversions.zip" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download emagisk failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
until $download /data/local/tmp/emagisk.config $gcconf_download/emagisk.config || { echo "`date +%Y-%m-%d_%T` $download /data/local/tmp/emagisk.config $gcconf_download/emagisk.config" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download emagisk config file failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# set emagisk to be installed
emagisk_install="install"
else
emagisk_install="skip"
echo "`date +%Y-%m-%d_%T` emagisk already on correct version or not enabled" >> $logfile
fi
if [ ! -z "$gocheats_install" ] && [ ! -z "$pogo_install" ] && [ ! -z "$emagisk_install" ] ;then
echo "`date +%Y-%m-%d_%T` All updates checked and downloaded if needed" >> $logfile
if [ "$gocheats_install" = "install" ] ;then
echo "`date +%Y-%m-%d_%T` Start updating gocheats" >> $logfile
# install gocheats
echo "`date +%Y-%m-%d_%T` Stopped gocheats service" >> $logfile
am force-stop com.gocheats.launcher
sleep 2
echo "`date +%Y-%m-%d_%T` Uninstall gocheats $gcinstalled" >> $logfile
pm uninstall com.gocheats.launcher
sleep 2
echo "`date +%Y-%m-%d_%T` Reinstall gocheats $gcversions" >> $logfile
/system/bin/pm install -r /sdcard/Download/gocheats.apk || { echo "`date +%Y-%m-%d_%T` Install gocheats failed, downgrade perhaps? Exit script" >> $logfile ; exit 1; }
/system/bin/rm -f /sdcard/Download/gocheats.apk
# Grant su access + settings after reinstall
guid="$(dumpsys package com.gocheats.launcher | /system/bin/grep userId | awk -F'=' '{print $2}')"
magisk --sqlite "DELETE from policies WHERE package_name='com.gocheats.launcher'"
magisk --sqlite "INSERT INTO policies (uid,package_name,policy,until,logging,notification) VALUES($guid,'com.gocheats.launcher',2,0,1,0)"
/system/bin/pm grant com.gocheats.launcher android.permission.READ_EXTERNAL_STORAGE
/system/bin/pm grant com.gocheats.launcher android.permission.WRITE_EXTERNAL_STORAGE
echo "`date +%Y-%m-%d_%T` gocheats granted su access after reinstall" >> $logfile
/system/bin/monkey -p com.gocheats.launcher 1
echo "`date +%Y-%m-%d_%T` Started gocheats" >> $logfile
reboot=1
fi
if [ "$pogo_install" = "install" ] ;then
echo "`date +%Y-%m-%d_%T` Start updating pogo" >> $logfile
# install pogo
echo "`date +%Y-%m-%d_%T` Stopped gocheats service + pogo" >> $logfile
am force-stop com.gocheats.launcher
am force-stop com.nianticlabs.pokemongo
sleep 2
echo "`date +%Y-%m-%d_%T` Uninstall pogo $pinstalled" >> $logfile
pm uninstall com.nianticlabs.pokemongo
sleep 2
echo "`date +%Y-%m-%d_%T` Reinstall pogo $pversions" >> $logfile
/system/bin/pm install -r /sdcard/Download/pogo.apk || { echo "`date +%Y-%m-%d_%T` Install pogo failed, downgrade perhaps? Exit script" >> $logfile ; exit 1; }
/system/bin/rm -f /sdcard/Download/pogo.apk
/system/bin/monkey -p com.gocheats.launcher 1
echo "`date +%Y-%m-%d_%T` Started gocheats" >> $logfile
reboot=1
fi
if [ "$emagisk_install" = "install" ] ;then
echo "`date +%Y-%m-%d_%T` Start updating emagisk" >> $logfile
# install emagisk
magisk --install-module /sdcard/Download/emagisk.zip
/system/bin/rm -f /sdcard/Download/emagisk.zip
reboot=1
fi
if [ "$gocheats_install" != "install" ] && [ "$pogo_install" != "install" ] && [ "$emagisk_install" != "install" ] ; then
echo "`date +%Y-%m-%d_%T` Updates checked, nothing to install" >> $logfile
fi
fi
}
downgrade_pogo(){
pinstalled=$(dumpsys package com.nianticlabs.pokemongo | /system/bin/grep versionName | head -n1 | /system/bin/sed 's/ *versionName=//')
pversions=$(/system/bin/grep 'pogo' $gcconf_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
if [[ "$pinstalled" != "$pversions" ]] ;then
until $download /sdcard/Download/pogo.apk $gcconf_download/pokemongo_$arch\_$pversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/pogo.apk $gcconf_download/pokemongo_$arch\_$pversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download pogo failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
/system/bin/pm uninstall com.nianticlabs.pokemongo
/system/bin/pm install -r /sdcard/Download/pogo.apk
/system/bin/rm -f /sdcard/Download/pogo.apk
echo "`date +%Y-%m-%d_%T` PoGo removed and installed, now $pversions" >> $logfile
else
echo "`date +%Y-%m-%d_%T` pogo version correct, proceed" >> $logfile
fi
}
send_logs(){
if [[ -z $webhook ]] ;then
echo "`date +%Y-%m-%d_%T` No webhook set in job" >> $logfile
else
# gcconf log
curl -S -k -L --fail --show-error -F "payload_json={\"username\": \"aconf log sender\", \"content\": \"gcconf.log for $origin\"}" -F "file1=@$logfile" $webhook &>/dev/null
# monitor log
[[ -f /sdcard/atlas_monitor.log ]] && curl -S -k -L --fail --show-error -F "payload_json={\"username\": \"aconf log sender\", \"content\": \"atlas_monitor.log for $origin\"}" -F "file1=@/sdcard/atlas_monitor.log" $webhook &>/dev/null
# gocheats log
cp /data/local/tmp/gocheats.log /sdcard/gocheats.log
curl -S -k -L --fail --show-error -F "payload_json={\"username\": \"aconf log sender\", \"content\": \"gocheats.log for $origin\"}" -F "file1=@/sdcard/gocheats.log" $webhook &>/dev/null
/system/bin/rm /sdcard/gocheats.log
#logcat
logcat -d > /sdcard/logcat.txt
curl -S -k -L --fail --show-error -F "payload_json={\"username\": \"aconf log sender\", \"content\": \"logcat.txt for $origin\"}" -F "file1=@/sdcard/logcat.txt" $webhook &>/dev/null
/system/bin/rm -f /sdcard/logcat.txt
echo "`date +%Y-%m-%d_%T` Sending logs to discord" >> $logfile
fi
}
########## Execution
#wait on internet
until ping -c1 8.8.8.8 >/dev/null 2>/dev/null || ping -c1 1.1.1.1 >/dev/null 2>/dev/null; do
sleep 10
done
echo "`date +%Y-%m-%d_%T` Internet connection available" >> $logfile
echo "`date +%Y-%m-%d_%T` Wait 60 seconds to finish boot" >> $logfile
sleep 60
#download latest gocheats.sh
if [[ $(basename $0) != "gocheats_new.sh" ]] ;then
mount -o remount,rw /system
oldsh=$(head -2 /system/bin/gocheats.sh | /system/bin/grep '# version' | awk '{ print $NF }')
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/gocheats_new.sh https://raw.githubusercontent.com/andi2022/gcconf/master/gocheats.sh || { echo "`date +%Y-%m-%d_%T` Download gocheats.sh failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/bin/gocheats_new.sh
newsh=$(head -2 /system/bin/gocheats_new.sh | /system/bin/grep '# version' | awk '{ print $NF }')
if [[ "$oldsh" != "$newsh" ]] ;then
echo "`date +%Y-%m-%d_%T` gocheats.sh $oldsh=>$newsh, restarting script" >> $logfile
cp /system/bin/gocheats_new.sh /system/bin/gocheats.sh
mount -o remount,ro /system
/system/bin/gocheats_new.sh $@
exit 1
fi
fi
# verify download credential file and set download
if [[ ! -f /data/local/gcconf_download ]] ;then
echo "`date +%Y-%m-%d_%T` File /data/local/gcconf_download not found, exit script" >> $logfile && exit 1
else
if [[ $gcconf_user == "" ]] ;then
download="/system/bin/curl -s -k -L --fail --show-error -o"
else
download="/system/bin/curl -s -k -L --fail --show-error --user $gcconf_user:$gcconf_pass -o"
fi
fi
# download latest version file
until $download $gcconf_versions $gcconf_download/versions || { echo "`date +%Y-%m-%d_%T` $download $gcconf_versions $gcconf_download/versions" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download gocheats versions file failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
dos2unix $gcconf_versions
echo "`date +%Y-%m-%d_%T` Downloaded latest versions file" >> $logfile
#update 55gocheats if needed
if [[ $(basename $0) = "gocheats_new.sh" ]] ;then
old55=$(head -2 /system/etc/init.d/55gocheats | /system/bin/grep '# version' | awk '{ print $NF }')
if [ "$Ver55gocheats" != "$old55" ] ;then
mount -o remount,rw /system
mount -o remount,rw /system/etc/init.d || true
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55gocheats https://raw.githubusercontent.com/andi2022/gcconf/master/55gocheats || { echo "`date +%Y-%m-%d_%T` Download 55gocheats failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/etc/init.d/55gocheats
mount -o remount,ro /system
mount -o remount,ro /system/etc/init.d || true
new55=$(head -2 /system/etc/init.d/55gocheats | /system/bin/grep '# version' | awk '{ print $NF }')
echo "`date +%Y-%m-%d_%T` 55gocheats $old55=>$new55" >> $logfile
fi
fi
#update 55cron if needed
if [[ $(basename $0) = "gocheats_new.sh" ]] ;then
old55=$(head -2 /system/etc/init.d/55cron | /system/bin/grep '# version' | awk '{ print $NF }')
if [ "$Ver55cron" != "$old55" ] ;then
mount -o remount,rw /system
mount -o remount,rw /system/etc || true
mount -o remount,rw /system/etc/init.d || true
# install 55cron
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55cron https://raw.githubusercontent.com/andi2022/gcconf/master/55cron || { echo "`date +%Y-%m-%d_%T` Download 55cron failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/etc/init.d/55cron
echo "`date +%Y-%m-%d_%T` 55cron installed, from master" >> $logfile
# install cron job
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/ping_test.sh https://raw.githubusercontent.com/andi2022/gcconf/master/ping_test.sh || { echo "`date +%Y-%m-%d_%T` Download ping_test.sh failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/bin/ping_test.sh
mkdir /data/crontabs || true
touch /data/crontabs/root
echo "15 * * * * /system/bin/ping_test.sh" > /data/crontabs/root
echo "0 23 * * * /system/bin/gocheats.sh -ua" >> /data/crontabs/root
crond -b -c /data/crontabs
# remove old cron job file
if [[ -f /system/etc/crontabs/root ]] ;then
mount -o remount,rw /system/etc/crontabs || true
echo "`date +%Y-%m-%d_%T` remove old crontab file /system/etc/crontabs/root" >> $logfile
rm -f /system/etc/crontabs/root
mount -o remount,ro /system/etc/crontabs || true
fi
mount -o remount,ro /system
mount -o remount,ro /system/etc || true
mount -o remount,ro /system/etc/init.d || true
new55=$(head -2 /system/etc/init.d/55cron | /system/bin/grep '# version' | awk '{ print $NF }')
echo "`date +%Y-%m-%d_%T` 55cron $old55=>$new55" >> $logfile
fi
fi
# prevent gcconf causing reboot loop. Add bypass ??
if [ $(/system/bin/cat /data/local/tmp/gcconf.log | /system/bin/grep `date +%Y-%m-%d` | /system/bin/grep rebooted | wc -l) -gt 20 ] ;then
echo "`date +%Y-%m-%d_%T` Device rebooted over 20 times today, gocheats.sh signing out, see you tomorrow" >> $logfile
exit 1
fi
# set hostname = origin, wait till next reboot for it to take effect
if [[ $origin != "" ]] ;then
if [ $(/system/bin/cat /system/build.prop | /system/bin/grep net.hostname | wc -l) = 0 ]; then
mount -o remount,rw /system
echo "`date +%Y-%m-%d_%T` No hostname set, setting it to $origin" >> $logfile
echo "net.hostname=$origin" >> /system/build.prop
mount -o remount,ro /system
else
hostname=$(/system/bin/grep net.hostname /system/build.prop | awk 'BEGIN { FS = "=" } ; { print $2 }')
if [[ $hostname != $origin ]] ;then
mount -o remount,rw /system
echo "`date +%Y-%m-%d_%T` Changing hostname, from $hostname to $origin" >> $logfile
/system/bin/sed -i -e "s/^net.hostname=.*/net.hostname=$origin/g" /system/build.prop
mount -o remount,ro /system
fi
fi
fi
# check gocheats config file exists
if [[ -d /data/data/com.gocheats.launcher ]] && [[ ! -s $gcconf ]] ;then
install_config
am force-stop com.gocheats.launcher
/system/bin/monkey -p com.gocheats.launcher 1
fi
for i in "$@" ;do
case "$i" in
-ig) install_gocheats ;;
-ic) install_config ;;
-ua) update_all ;;
-dp) downgrade_pogo;;
-sl) send_logs;;
esac
done
(( $reboot )) && reboot_device
exit