-
Notifications
You must be signed in to change notification settings - Fork 4
/
wooper.sh
656 lines (578 loc) · 29.2 KB
/
wooper.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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
logfil#!/system/bin/sh
# version 1.7.0
#Version checks
Ver55wooper="1.0"
Ver55cron="1.0"
VerMonitor="1.2.0"
android_version=`getprop ro.build.version.release | sed -e 's/\..*//'`
#Create logfile
if [ ! -e /data/local/tmp/wooper.log ] ;then
/system/bin/touch /data/local/tmp/wooper.log
fi
logfile="/data/local/tmp/wooper.log"
exeggcute="/data/local/tmp/config.json"
wooper_versions="/data/local/wooper_versions"
wooper_adb_keys="data/local/wooper_adb_keys"
adb_keys="/data/misc/adb/adb_keys"
branchoverwrite="/data/local/tmp/branch"
[[ -f /data/local/wooper_download ]] && wooper_download=$(/system/bin/grep url /data/local/wooper_download | awk -F "=" '{ print $NF }')
[[ -f /data/local/wooper_download ]] && wooper_user=$(/system/bin/grep authUser /data/local/wooper_download | awk -F "=" '{ print $NF }')
[[ -f /data/local/wooper_download ]] && wooper_pass=$(/system/bin/grep authPass /data/local/wooper_download | awk -F "=" '{ print $NF }')
if [[ -f /data/local/tmp/config.json ]] ;then
origin=$(/system/bin/cat $exeggcute | /system/bin/tr , '\n' | /system/bin/grep -w 'device_name' | awk -F "\"" '{ print $4 }')
else
origin=$(/system/bin/cat /data/local/initDName)
fi
pogo_package_samsung="com.nianticlabs.pokemongo.ares"
pogo_package_google="com.nianticlabs.pokemongo"
# stderr to logfile
exec 2>> $logfile
# add wooper.sh command to log
echo "" >> $logfile
echo "`date +%Y-%m-%d_%T` ## Executing $(basename $0) $@" >> $logfile
########## Functions
# logger
logger() {
if [[ ! -z $discord_webhook ]] ;then
echo "`date +%Y-%m-%d_%T` wooper.sh: $1" >> $logfile
if [[ -z $origin ]] ;then
curl -S -k -L --fail --show-error -F "payload_json={\"username\": \"wooper.sh\", \"content\": \" $1 \"}" $discord_webhook &>/dev/null
else
curl -S -k -L --fail --show-error -F "payload_json={\"username\": \"wooper.sh\", \"content\": \" $origin: $1 \"}" $discord_webhook &>/dev/null
fi
else
echo "`date +%Y-%m-%d_%T` wooper.sh: $1" >> $logfile
fi
}
read_versionfile(){
if [[ -f $wooper_versions ]] ;then
discord_webhook=$(grep 'discord_webhook' $wooper_versions | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
fi
if [[ -z $discord_webhook ]] ;then
discord_webhook=$(grep discord_webhook /data/local/wooper_download | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
fi
#Scriptbrach
branch=$(grep 'branch' $wooper_versions | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
if [[ -z $branch ]] ;then
branch=main
fi
#Overwrite branch with a local config file for testing on a single device
if [ -e "$branchoverwrite" ]; then
branch=$(grep 'branch' $branchoverwrite | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
fi
#apk google or samsung
apk=$(grep '^apk=' $wooper_versions | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
if [[ "$apk" == "samsung" ]]; then
:
else
apk="google"
fi
if [ "$apk" == "samsung" ]; then
pogo_package=$pogo_package_samsung
elif [ "$apk" == "google" ]; then
pogo_package=$pogo_package_google
else
pogo_package=$pogo_package_google
fi
# apkbundle enabled or disabled
apkm=$(grep '^apkm=' $wooper_versions | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
# adbfingerprint anabled or disabled
adbfingerprint=$(grep '^adbfingerprint=' $wooper_versions | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
#logger apk=$apk
#logger pogoPackage=$pogo_package
}
read_versionfile
reboot_device(){
echo "`date +%Y-%m-%d_%T` Reboot device" >> $logfile
sleep 15
/system/bin/reboot
}
case "$(uname -m)" in
aarch64) arch="arm64-v8a";;
armv8l) arch="armeabi-v7a";;
esac
mount_system_rw() {
if [ $android_version -ge 9 ]; then
# if a magisk module is installed that puts stuff under /system/etc, we're screwed, though.
# because then /system/etc ends up full of bindmounts.. and you can't place new files under it.
mount -o remount,rw /
else
mount -o remount,rw /system
mount -o remount,rw /system/etc/init.d
fi
}
mount_system_ro() {
if [ $android_version -ge 9 ]; then
mount -o remount,ro /
else
mount -o remount,ro /system
mount -o remount,ro /system/etc/init.d
fi
}
download_versionfile() {
# verify download credential file and set download
if [[ ! -f /data/local/wooper_download ]] ;then
echo "`date +%Y-%m-%d_%T` File /data/local/wooper_download not found, exit script" >> $logfile && exit 1
else
if [[ $wooper_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 $wooper_user:$wooper_pass -o"
fi
fi
# download latest version file
until $download $wooper_versions $wooper_download/versions || { echo "`date +%Y-%m-%d_%T` $download $wooper_versions $wooper_download/versions" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download gocheats versions file failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
dos2unix $wooper_versions
echo "`date +%Y-%m-%d_%T` Downloaded latest versions file" >> $logfile
read_versionfile
}
download_adb_keys() {
until $download $wooper_adb_keys $wooper_download/adb_keys || { echo "`date +%Y-%m-%d_%T` $download $wooper_adb_keys $wooper_download/adb_keys" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download adb_keys file failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
dos2unix $wooper_adb_keys
echo "`date +%Y-%m-%d_%T` Downloaded latest adb_keys file" >> $logfile
}
copy_adb_keys_if_newer() {
# Check if the destination file exists
if [ ! -f "$adb_keys" ]; then
logger "Install adb_keys"
cp -f "$wooper_adb_keys" "$adb_keys"
chmod 644 $adb_keys
else
# Compare file contents
if ! diff "$wooper_adb_keys" "$adb_keys" >/dev/null; then
logger "Newer adb_keys found, copy updated version"
cp -f "$wooper_adb_keys" "$adb_keys"
chmod 644 "$adb_keys"
else
echo "$(date +%Y-%m-%d_%T) latest adb_keys file already installed" >> "$logfile"
fi
fi
}
install_wooper(){
download_versionfile
# search discord webhook url for install log
discord_webhook=$(grep 'discord_webhook' $wooper_versions | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
if [[ -z $discord_webhook ]] ;then
discord_webhook=$(grep discord_webhook /data/local/wooper_download | awk -F "=" '{ print $NF }' | sed -e 's/^"//' -e 's/"$//')
fi
# install 55wooper
mount_system_rw
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55wooper https://raw.githubusercontent.com/andi2022/wooper/$branch/55wooper || { echo "`date +%Y-%m-%d_%T` Download 55wooper failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/etc/init.d/55wooper
logger "55wooper installed"
# install 55cron
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55cron https://raw.githubusercontent.com/andi2022/wooper/$branch/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
logger "55cron installed"
# install cron job
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/ping_test.sh https://raw.githubusercontent.com/andi2022/wooper/$branch/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
crond -b -c /data/crontabs
logger "cron jobs installed"
# install wooper monitor
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/wooper_monitor.sh https://raw.githubusercontent.com/andi2022/wooper/$branch/wooper_monitor.sh || { echo "`date +%Y-%m-%d_%T` Download wooper_monitor.sh failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/bin/wooper_monitor.sh
logger "wooper monitor installed"
mount_system_ro
# get version
exeggcuteversions=$(/system/bin/grep 'exeggcute' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
# download exeggcute
/system/bin/rm -f /sdcard/Download/exeggcute.apk
until $download /sdcard/Download/exeggcute.apk $wooper_download/com.exeggcute.launcher_v$exeggcuteversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/exeggcute.apk $wooper_download/com.exeggcute.launcher_v$exeggcuteversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download exeggcute failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# let us kill pogo as well and clear data
/system/bin/am force-stop $pogo_package > /dev/null 2>&1
/system/bin/pm clear $pogo_package > /dev/null 2>&1
# Install exeggcute
/system/bin/pm install -r /sdcard/Download/exeggcute.apk > /dev/null 2>&1
/system/bin/rm -f /sdcard/Download/exeggcute.apk
logger "exeggcute installed"
# Grant su access + settings
euid="$(dumpsys package com.gocheats.launcher | /system/bin/grep userId | awk -F'=' '{print $2}')"
magisk --sqlite "REPLACE INTO policies (uid,policy,until,logging,notification) VALUES($euid,2,0,1,1);"
/system/bin/pm grant com.gocheats.launcher android.permission.READ_EXTERNAL_STORAGE
/system/bin/pm grant com.gocheats.launcher android.permission.WRITE_EXTERNAL_STORAGE
logger "exeggcute granted su"
# download gocheats config file and adjust orgin
install_config
# check pogo version else remove+install
downgrade_pogo
# start execute
/system/bin/monkey -p com.gocheats.launcher 1 > /dev/null 2>&1
sleep 15
# Set for reboot device
reboot=1
}
install_config(){
until $download /data/local/tmp/config.json $wooper_download/config.json || { echo "`date +%Y-%m-%d_%T` $download /data/local/tmp/config.json $wooper_download/config.json" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download exeggcute config file failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
/system/bin/sed -i 's,dummy,'$origin',g' $exeggcute
logger "exeggcute config installed"
}
check_apkinstall_settings(){
# Desired settings
desired_package_verifier_enable=0
desired_verifier_verify_adb_installs=0
desired_package_verifier_user_consent=-1
# Get current settings
current_package_verifier_enable=$(settings get global package_verifier_enable)
current_verifier_verify_adb_installs=$(settings get global verifier_verify_adb_installs)
current_package_verifier_user_consent=$(settings get global package_verifier_user_consent)
# Check and set settings if necessary
if [ "$current_package_verifier_enable" != "$desired_package_verifier_enable" ]; then
settings put global package_verifier_enable $desired_package_verifier_enable
logger "disable package verifier"
fi
if [ "$current_verifier_verify_adb_installs" != "$desired_verifier_verify_adb_installs" ]; then
settings put global verifier_verify_adb_installs $desired_verifier_verify_adb_installs
logger "disable adb package verifier"
fi
if [ "$current_package_verifier_user_consent" != "$desired_package_verifier_user_consent" ]; then
settings put global package_verifier_user_consent $desired_package_verifier_user_consent
logger "disable package verifier user consent"
fi
}
update_all(){
download_versionfile
pinstalled=$(dumpsys package $pogo_package | /system/bin/grep versionName | head -n1 | /system/bin/sed 's/ *versionName=//')
pversions=$(/system/bin/grep 'pogo' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
exeggcuteinstalled=$(dumpsys package com.gocheats.launcher | /system/bin/grep versionName | head -n1 | /system/bin/sed 's/ *versionName=//')
exeggcuteversions=$(/system/bin/grep 'exeggcute' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
globalworkers=$(/system/bin/grep 'globalworkers' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
workerscount=$(/system/bin/grep 'workerscount' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
exeggcuteworkerscount=$(grep 'workers_count' $exeggcute | sed -r 's/^ [^:]*: ([0-9]+),?$/\1/')
playintegrityfixinstalled=$(cat /data/adb/modules/playintegrityfix/module.prop | /system/bin/grep version | head -n1 | /system/bin/sed 's/ *version=v//')
playintegrityfixupdate=$(/system/bin/grep 'playintegrityfixupdate' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
playintegrityfixversions=$(/system/bin/grep 'playintegrityfixversion' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
if [[ "$apk" = "google" ]] ;then
if pm list packages | grep -w "^package:$pogo_package_samsung$"; then
logger "Configured PoGo APK is $apk, a Samsung version is detected and will be uninstalled."
am force-stop $pogo_package_samsung
sleep 2
pm uninstall $pogo_package_samsung
fi
fi
if [[ "$apk" = "samsung" ]] ;then
if pm list packages | grep -w "^package:$pogo_package_google$"; then
logger "Configured PoGo APK is $apk, a Google version is detected and will be uninstalled."
am force-stop $pogo_package_google
sleep 2
pm uninstall $pogo_package_google
fi
fi
if [[ "$pinstalled" != "$pversions" ]] ;then
logger "New pogo version detected, $pinstalled=>$pversions"
if [[ "$apkm" = "true" ]] ;then
/system/bin/rm -f /sdcard/Download/pogo.apkm
/system/bin/rm -f -r /sdcard/Download/pogoapkm
until $download /sdcard/Download/pogo.apkm $wooper_download/com.nianticlabs.pokemongo_$arch\_$pversions.apkm || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/pogo.apkm $wooper_download/com.nianticlabs.pokemongo_$arch_$pversions.apkm" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download pogo failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
mkdir /sdcard/Download/pogoapkm
logger "Extract pogo.apkm $versions"
unzip /sdcard/Download/pogo.apkm -d /sdcard/Download/pogoapkm
/system/bin/rm -f /sdcard/Download/pogo.apkm
else
/system/bin/rm -f /sdcard/Download/pogo.apk
until $download /sdcard/Download/pogo.apk $wooper_download/pokemongo_$arch\_$pversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/pogo.apk $wooper_download/pokemongo_$arch\_$pversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download pogo failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
fi
# 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 [ "$exeggcuteinstalled" != "$exeggcuteversions" ] ;then
logger "New exeggcute version detected, $exeggcuteinstalled=>$exeggcuteversions"
/system/bin/rm -f /sdcard/Download/exeggcute.apk
until $download /sdcard/Download/exeggcute.apk $wooper_download/com.exeggcute.launcher_v$exeggcuteversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/exeggcute.apk $wooper_download/com.exeggcute.launcher_v$exeggcuteversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download exeggcute failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# set exeggcute to be installed
exeggcute_install="install"
else
exeggcute_install="skip"
echo "`date +%Y-%m-%d_%T` exeggcute already on correct version" >> $logfile
fi
if [[ $playintegrityfixupdate == "true" ]] && [ "$playintegrityfixinstalled" != "$playintegrityfixversions" ] ;then
logger "New PlayIntegrityFix version detected, $playintegrityfixinstalled=>$playintegrityfixversions"
/system/bin/rm -f /sdcard/Download/playintegrityfix.zip
until $download /sdcard/Download/playintegrityfix.zip $wooper_download/PlayIntegrityFix_v$playintegrityfixversions.zip || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/playintegrityfix.zip $wooper_download/PlayIntegrityFix_v$playintegrityfixversions.zip" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download PlayIntegrityFix failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
# set PlayIntegrityFix to be installed
playintegrityfix_install="install"
else
playintegrityfix_install="skip"
echo "`date +%Y-%m-%d_%T` PlayIntegrityFix already on correct version or not enabled" >> $logfile
fi
if [[ $globalworkers == "true" ]] && [ "$exeggcuteworkerscount" != "$workerscount" ] ;then
logger "New global workers count detected, $exeggcuteworkerscount=>$workerscount"
sed -i "s/\"workers_count\": [0-9]*/\"workers_count\": $workerscount/" $exeggcute
logger "New workers count $workerscount is active, restarting exeggcute"
am force-stop com.gocheats.launcher
sleep 2
/system/bin/monkey -p com.gocheats.launcher 1 > /dev/null 2>&1
else
echo "`date +%Y-%m-%d_%T` workers count ok or not enabled" >> $logfile
fi
if [ ! -z "$exeggcute_install" ] && [ ! -z "$pogo_install" ] && [ ! -z "$playintegrityfix_install" ] ;then
echo "`date +%Y-%m-%d_%T` All updates checked and downloaded if needed" >> $logfile
if [ "$exeggcute_install" = "install" ] ;then
logger "Start updating exeggcute"
# install gocheats
am force-stop com.gocheats.launcher
sleep 2
pm uninstall com.gocheats.launcher
sleep 2
/system/bin/pm install -r /sdcard/Download/exeggcute.apk || { echo "`date +%Y-%m-%d_%T` Install gocheats failed, downgrade perhaps? Exit script" >> $logfile ; exit 1; }
/system/bin/rm -f /sdcard/Download/exeggcute.apk
# Grant su access + settings after reinstall
euid="$(dumpsys package com.gocheats.launcher | /system/bin/grep userId | awk -F'=' '{print $2}')"
magisk --sqlite "REPLACE INTO policies (uid,policy,until,logging,notification) VALUES($euid,2,0,1,1);"
/system/bin/pm grant com.gocheats.launcher android.permission.READ_EXTERNAL_STORAGE
/system/bin/pm grant com.gocheats.launcher android.permission.WRITE_EXTERNAL_STORAGE
/system/bin/monkey -p com.gocheats.launcher 1 > /dev/null 2>&1
logger "exeggcute updated, launcher started"
fi
if [ "$pogo_install" = "install" ] ;then
logger "Start updating pogo"
# install pogo
am force-stop com.gocheats.launcher
am force-stop $pogo_package
sleep 2
pm uninstall $pogo_package
sleep 2
if [ "$apkm" = "true" ] ;then
/system/bin/pm install -r /sdcard/Download/pogoapkm/base.apk && /system/bin/pm install -p com.nianticlabs.pokemongo -r /sdcard/Download/pogoapkm/split_config.*.apk || { logger "install pogo failed, downgrade perhaps? Exit script" ; exit 1; }
/system/bin/rm -f -r /sdcard/Download/pogoapkm
else
/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
fi
/system/bin/monkey -p com.gocheats.launcher 1 > /dev/null 2>&1
logger "PoGo $pversions, launcher started"
# restart wooper monitor
if [[ $(grep useMonitor $wooper_versions | awk -F "=" '{ print $NF }') == "true" ]] && [ -f /system/bin/wooper_monitor.sh ] ;then
checkMonitor=$(pgrep -f /system/bin/wooper_monitor.sh)
if [ ! -z $checkMonitor ] ;then
kill -9 $checkMonitor
sleep 2
/system/bin/wooper_monitor.sh >/dev/null 2>&1 &
logger "wooper monitor restarted after PoGo update"
fi
fi
fi
if [ "$playintegrityfix_install" = "install" ] ;then
logger "start updating playintegrityfix"
# install playintegrityfix
magisk --install-module /sdcard/Download/playintegrityfix.zip
/system/bin/rm -f /sdcard/Download/playintegrityfix.zip
reboot=1
fi
if [ "$exeggcute_install" != "install" ] && [ "$pogo_install" != "install" ] && [ "$playintegrityfix_install" != "install" ] ; then
echo "`date +%Y-%m-%d_%T` Updates checked, nothing to install" >> $logfile
fi
fi
}
downgrade_pogo(){
pinstalled=$(dumpsys package $pogo_package | /system/bin/grep versionName | head -n1 | /system/bin/sed 's/ *versionName=//')
pversions=$(/system/bin/grep 'pogo' $wooper_versions | /system/bin/grep -v '_' | awk -F "=" '{ print $NF }')
if [[ "$pinstalled" != "$pversions" ]] ;then
if [[ "$apkm" = "true" ]] ;then
/system/bin/rm -f /sdcard/Download/pogo.apkm
/system/bin/rm -f -r /sdcard/Download/pogoapkm
until $download /sdcard/Download/pogo.apkm $wooper_download/com.nianticlabs.pokemongo_$arch\_$pversions.apkm || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/pogo.apkm $wooper_download/com.nianticlabs.pokemongo_$arch_$pversions.apkm" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download pogo failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
mkdir /sdcard/Download/pogoapkm
logger "Extract pogo.apkm $versions"
unzip /sdcard/Download/pogo.apkm -d /sdcard/Download/pogoapkm
/system/bin/rm -f /sdcard/Download/pogo.apkm
else
/system/bin/rm -f /sdcard/Download/pogo.apk
until $download /sdcard/Download/pogo.apk $wooper_download/pokemongo_$arch\_$pversions.apk || { echo "`date +%Y-%m-%d_%T` $download /sdcard/Download/pogo.apk $wooper_download/pokemongo_$arch\_$pversions.apk" >> $logfile ; echo "`date +%Y-%m-%d_%T` Download pogo failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
fi
# install pogo
am force-stop com.gocheats.launcher
am force-stop $pogo_package
sleep 2
pm uninstall $pogo_package
sleep 2
if [ "$apkm" = "true" ] ;then
/system/bin/pm install -r /sdcard/Download/pogoapkm/base.apk && /system/bin/pm install -p com.nianticlabs.pokemongo -r /sdcard/Download/pogoapkm/split_config.*.apk || { logger "install pogo failed, downgrade perhaps? Exit script" ; exit 1; }
/system/bin/rm -f -r /sdcard/Download/pogoapkm
else
/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
fi
logger "PoGo installed, now $pversions"
/system/bin/monkey -p com.gocheats.launcher 1 > /dev/null 2>&1
else
echo "`date +%Y-%m-%d_%T` pogo version correct, proceed" >> $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 30 seconds, safety delay" >> $logfile
sleep 30
download_versionfile
#download latest wooper.sh
if [[ $(basename $0) != "wooper_new.sh" ]] ;then
mount_system_rw
oldsh=$(head -2 /system/bin/wooper.sh | /system/bin/grep '# version' | awk '{ print $NF }')
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/wooper_new.sh https://raw.githubusercontent.com/andi2022/wooper/$branch/wooper.sh || { echo "`date +%Y-%m-%d_%T` Download wooper.sh failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/bin/wooper_new.sh
newsh=$(head -2 /system/bin/wooper_new.sh | /system/bin/grep '# version' | awk '{ print $NF }')
if [[ "$oldsh" != "$newsh" ]] ;then
logger "wooper.sh updated $oldsh=>$newsh | Github branch $branch, restarting script"
cp /system/bin/wooper_new.sh /system/bin/wooper.sh
mount_system_ro
/system/bin/wooper_new.sh $@
exit 1
fi
fi
#update 55wooper if needed
if [[ $(basename $0) = "wooper_new.sh" ]] ;then
old55=$(head -2 /system/etc/init.d/55wooper | /system/bin/grep '# version' | awk '{ print $NF }')
if [ "$Ver55wooper" != "$old55" ] ;then
mount_system_rw
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55wooper https://raw.githubusercontent.com/andi2022/wooper/$branch/55wooper || { echo "`date +%Y-%m-%d_%T` Download 55wooper failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/etc/init.d/55wooper
mount_system_ro
new55=$(head -2 /system/etc/init.d/55wooper | /system/bin/grep '# version' | awk '{ print $NF }')
logger "55wooper updated $old55=>$new55 | Github branch $branch"
fi
fi
#update 55cron if needed
if [[ $(basename $0) = "wooper_new.sh" ]] ;then
old55=$(head -2 /system/etc/init.d/55cron | /system/bin/grep '# version' | awk '{ print $NF }')
if [ "$Ver55cron" != "$old55" ] ;then
mount_system_rw
# install 55cron
until /system/bin/curl -s -k -L --fail --show-error -o /system/etc/init.d/55cron https://raw.githubusercontent.com/andi2022/wooper/$branch/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/wooper/$branch/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
crond -b -c /data/crontabs
mount_system_ro
new55=$(head -2 /system/etc/init.d/55cron | /system/bin/grep '# version' | awk '{ print $NF }')
logger "55cron updated $old55=>$new55 | Github branch $branch"
fi
fi
#update wooper monitor if needed
if [[ $(basename $0) = "wooper_new.sh" ]] ;then
[ -f /system/bin/wooper_monitor.sh ] && oldMonitor=$(head -2 /system/bin/wooper_monitor.sh | grep '# version' | awk '{ print $NF }') || oldMonitor="0"
if [ $VerMonitor != $oldMonitor ] ;then
mount_system_rw
until /system/bin/curl -s -k -L --fail --show-error -o /system/bin/wooper_monitor.sh https://raw.githubusercontent.com/andi2022/wooper/$branch/wooper_monitor.sh || { echo "`date +%Y-%m-%d_%T` Download wooper_monitor.sh failed, exit script" >> $logfile ; exit 1; } ;do
sleep 2
done
chmod +x /system/bin/wooper_monitor.sh
mount_system_ro
newMonitor=$(head -2 /system/bin/wooper_monitor.sh | grep '# version' | awk '{ print $NF }')
logger "wooper monitor updated $oldMonitor => $newMonitor | Github branch $branch"
# restart wooper monitor
if [[ $(grep useMonitor $wooper_versions | awk -F "=" '{ print $NF }') == "true" ]] && [ -f /system/bin/wooper_monitor.sh ] ;then
checkMonitor=$(pgrep -f /system/bin/wooper_monitor.sh)
if [ ! -z $checkMonitor ] ;then
kill -9 $checkMonitor
sleep 2
/system/bin/wooper_monitor.sh >/dev/null 2>&1 &
logger "wooper monitor restarted"
fi
fi
fi
fi
# prevent wooper causing reboot loop. Add bypass ??
if [ $(/system/bin/cat /data/local/tmp/wooper.log | /system/bin/grep `date +%Y-%m-%d` | /system/bin/grep rebooted | wc -l) -gt 20 ] ;then
logger "Device rebooted over 20 times today, wooper.sh signing out, see you tomorrow"
echo "`date +%Y-%m-%d_%T` Device rebooted over 20 times today, wooper.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_system_rw
echo "`date +%Y-%m-%d_%T` No hostname set, setting it to $origin" >> $logfile
echo "net.hostname=$origin" >> /system/build.prop
mount_system_ro
else
hostname=$(/system/bin/grep net.hostname /system/build.prop | awk 'BEGIN { FS = "=" } ; { print $2 }')
if [[ $hostname != $origin ]] ;then
mount_system_rw
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_system_ro
fi
fi
fi
# check exeggcute config file exists
if [[ -d /data/data/com.gocheats.launcher ]] && [[ ! -s $exeggcute ]] ;then
install_config
am force-stop com.gocheats.launcher
/system/bin/monkey -p com.gocheats.launcher 1 > /dev/null 2>&1
fi
# enable wooper monitor
if [[ $(grep useMonitor $wooper_versions | awk -F "=" '{ print $NF }' | awk '{ gsub(/ /,""); print }') == "true" ]] && [ -f /system/bin/wooper_monitor.sh ] ;then
checkMonitor=$(pgrep -f /system/bin/wooper_monitor.sh)
if [ -z $checkMonitor ] ;then
/system/bin/wooper_monitor.sh >/dev/null 2>&1 &
echo "`date +%Y-%m-%d_%T` wooper.sh: wooper monitor enabled" >> $logfile
fi
fi
# check apk install settings
check_apkinstall_settings
# install or update adb_keys if config is enabled
if [ "$adbfingerprint" = "true" ] ;then
download_adb_keys
copy_adb_keys_if_newer
fi
for i in "$@" ;do
case "$i" in
-iw) install_wooper ;;
-ic) install_config ;;
-ua) update_all ;;
-dp) downgrade_pogo;;
esac
done
(( $reboot )) && reboot_device
exit