forked from Magisk-Modules-Repo/Pix3lify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pix3lify.sh
441 lines (396 loc) · 12 KB
/
pix3lify.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
# Terminal Magisk Mod Template
# by veez21 @ xda-developers
# Modified by @JohnFawkes - Telegram
# Supersu/all-root compatibility with Unity and @Zackptg5
# Variables
OLDPATH=$PATH
CACHELOC=<CACHELOC>
MODID=Pix3lify
SDCARD=/storage/emulated/0
TMPLOG=Pix3lify_logs.log
TMPLOGLOC=$CACHELOC/Pix3lify_logs
XZLOG=$SDCARD/Pix3lify_logs.tar.xz
DPF=$(find /data/data/com.google.android.dialer* -name "dialer_phenotype_flags.xml")
LIST=/data/system/packages.list
quit() {
PATH=$OLDPATH
exit $?
}
MODPROP=<MODPROP>
$MAGISK && [ ! -f $MODPROP ]
[ -f $MODPROP ] || { echo "Module not detected!"; quit 1; }
# Detect root
_name=$(basename $0)
ls /data >/dev/null 2>&1 || { echo "$MODID needs to run as root!"; echo "type 'su' then '$_name'"; quit 1; }
if [ -f $VEN/build.prop ]; then BUILDS="/system/build.prop $VEN/build.prop"; else BUILDS="/system/build.prop"; fi
#=========================== Set Log Files
mount -o remount,rw $CACHELOC 2>/dev/null
mount -o rw,remount $CACHELOC 2>/dev/null
# > Logs should go in this file
LOG=$CACHELOC/Pix3lify.log
oldLOG=$CACHELOC/Pix3lify-old.log
# > Verbose output goes here
VERLOG=$CACHELOC/Pix3lify-verbose.log
oldVERLOG=$CACHELOC/Pix3lify-verbose-old.log
# Start Logging verbosely
mv -f $VERLOG $oldVERLOG 2>/dev/null
set -x 2>$VERLOG
# Loggers
LOGGERS="
$CACHELOC/magisk.log
$CACHELOC/magisk.log.bak
$MOUNTEDROOT$MODID/Pix3lify-install.log
$SDCARD/Pix3lify-debug.log
$MOUNTEDROOT$MODID/pix3lify
/data/adb/magisk_debug.log
$DPF
$CACHELOC/Pix3lify.log
$CACHELOC/Pix3lify-old.log
$CACHELOC/Pix3lify-verbose-old.log
$CACHELOC/Pix3lify-verbose.log
"
log_handler() {
if [ $(id -u) == 0 ] ; then
echo "" >> $LOG 2>&1
echo -e "$(date +"%m-%d-%Y %H:%M:%S") - $1" >> $LOG 2>&1
fi
}
log_print() {
echo "$1"
log_handler "$1"
}
log_script_chk() {
log_handler "$1"
echo -e "$(date +"%m-%d-%Y %H:%M:%S") - $1" >> $LOG 2>&1
}
get_file_value() {
cat $1 | grep $2 | sed "s|.*$2||" | sed 's|\"||g'
}
#ZACKPTG5 BUSYBOX
#=========================== Set Busybox up
if [ "$(busybox 2>/dev/null)" ]; then
BBox=true
elif $MAGISK && [ -d /sbin/.magisk/busybox ]; then
PATH=/sbin/.magisk/busybox:$PATH
_bb=/sbin/.magisk/busybox/busybox
BBox=true
elif $MAGISK && [ -d /sbin/.core/busybox ]; then
PATH=/sbin/.core/busybox:$PATH
_bb=/sbin/.core/busybox/busybox
BBox=true
elif $MAGISK && [ -d /data/adb/magisk/busybox ]; then
PATH=/data/adb/magisk/busybox:$PATH
_bb=/data/adb/magisk/busybox/busybox
BBox=true
else
BBox=false
echo "! Busybox not detected"
echo "Please install one (@osm0sis' busybox recommended)"
for applet in cat chmod cp grep md5sum mv printf sed sort tar tee tr wget; do
[ "$($applet)" ] || quit 1
done
echo "All required applets present, continuing"
fi
if $BBox; then
alias cat="busybox cat"
alias chmod="busybox chmod"
alias cp="busybox cp"
alias grep="busybox grep"
alias md5sum="busybox md5sum"
alias mv="busybox mv"
alias printf="busybox printf"
alias sed="busybox sed"
alias sort="busybox sort"
alias tar="busybox tar"
alias tee="busybox tee"
alias tr="busybox tr"
alias wget="busybox wget"
fi
if [ -z "$(echo $PATH | grep /sbin:)" ]; then
alias resetprop="/data/adb/magisk/magisk resetprop"
fi
# Log print
log_handler "Functions loaded."
if $BBox; then
BBV=$(busybox | grep "BusyBox v" | sed 's|.*BusyBox ||' | sed 's| (.*||')
log_handler "Using busybox: ${PATH} (${BBV})."
else
log_handler "Using installed applets (not busybox)"
fi
grep_prop() {
REGEX="s/^$1=//p"
shift
FILES=$@
[ -z "$FILES" ] && FILES='/system/build.prop'
sed -n "$REGEX" $FILES 2>/dev/null | head -n 1
}
api_level_arch_detect() {
API=`grep_prop ro.build.version.sdk`
ABI=`grep_prop ro.product.cpu.abi | cut -c-3`
ABI2=`grep_prop ro.product.cpu.abi2 | cut -c-3`
ABILONG=`grep_prop ro.product.cpu.abi`
ARCH=arm
ARCH32=arm
IS64BIT=false
if [ "$ABI" = "x86" ]; then ARCH=x86; ARCH32=x86; fi;
if [ "$ABI2" = "x86" ]; then ARCH=x86; ARCH32=x86; fi;
if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; ARCH32=arm; IS64BIT=true; fi;
if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; ARCH32=x86; IS64BIT=true; fi;
}
magisk_version() {
if grep MAGISK_VER /data/adb/magisk/util_functions.sh; then
log_print "$MAGISK_VERSION $MAGISK_VERSIONCODE" >> $LOG 2>&1
else
log_print "Magisk not installed" >> $LOG 2>&1
fi
}
# Device Info
# BRAND MODEL DEVICE API ABI ABI2 ABILONG ARCH
BRAND=$(getprop ro.product.brand)
MODEL=$(getprop ro.product.model)
DEVICE=$(getprop ro.product.device)
ROM=$(getprop ro.build.display.id)
api_level_arch_detect
# Version Number
VER=$(grep_prop version $MODPROP)
# Version Code
REL=$(grep_prop versionCode $MODPROP)
# Author
AUTHOR=$(grep_prop author $MODPROP)
# Mod Name/Title
MODTITLE=$(grep_prop name $MODPROP)
#Grab Magisk Version
MAGISK_VERSION=$(echo $(get_file_value /data/adb/magisk/util_functions.sh "MAGISK_VER=") | sed 's|-.*||')
MAGISK_VERSIONCODE=$(echo $(get_file_value /data/adb/magisk/util_functions.sh "MAGISK_VER_CODE=") | sed 's|-.*||')
# Colors
G='\e[01;32m' # GREEN TEXT
R='\e[01;31m' # RED TEXT
Y='\e[01;33m' # YELLOW TEXT
B='\e[01;34m' # BLUE TEXT
V='\e[01;35m' # VIOLET TEXT
Bl='\e[01;30m' # BLACK TEXT
C='\e[01;36m' # CYAN TEXT
W='\e[01;37m' # WHITE TEXT
BGBL='\e[1;30;47m' # Background W Text Bl
N='\e[0m' # How to use (example): echo "${G}example${N}"
loadBar=' ' # Load UI
# Remove color codes if -nc or in ADB Shell
[ -n "$1" -a "$1" == "-nc" ] && shift && NC=true
[ "$NC" -o -n "$LOGNAME" ] && {
G=''; R=''; Y=''; B=''; V=''; Bl=''; C=''; W=''; N=''; BGBL=''; loadBar='=';
}
# Divider (based on $MODTITLE, $VER, and $REL characters)
character_no=$(echo $MODTITLE $VER $REL | tr " " '_' | wc -c)
div="${Bl}$(printf '%*s' "${character_no}" '' | tr " " "=")${N}"
# Title Div
title_div() {
no=$(echo $@ | wc -c)
extdiv=$((no-character_no))
echo "${W}$@${N} ${Bl}$(printf '%*s' "$extdiv" '' | tr " " "=")${N}"
}
# https://github.com/fearside/ProgressBar
ProgressBar() {
# Process data
_progress=$(((${1}*100/${2}*100)/100))
_done=$(((${_progress}*4)/10))
_left=$((40-$_done))
# Build progressbar string lengths
_done=$(printf "%${_done}s")
_left=$(printf "%${_left}s")
# 1.2 Build progressbar strings and print the ProgressBar line
# 1.2.1 Output example:
# 1.2.1.1 Progress : [########################################] 100%
printf "\rProgress : ${BGBL}|${N}${_done// /${BGBL}$loadBar${N}}${_left// / }${BGBL}|${N} ${_progress}%%"
}
# test_connection
test_connection() {
echo -n "Testing internet connection "
ping -q -c 1 -W 1 google.com >/dev/null 2>/dev/null && echo "- OK" || { echo "Error"; false; }
}
# Log files will be uploaded to logs.pix3lify.com
upload_logs() {
test_connection
[ $? -ne 0 ] && exit
logup=none;
echo "Uploading logs"
[ -s $XZLOG ] && logup=$(curl -T $XZLOG http://logs.pix3lify.com/submit)
echo "$MODEL ($DEVICE) API $API\n$ROM\n$ID\n
Log: $logup"
exit
}
# Heading
mod_head() {
clear
echo "$div"
echo "${W}$MODTITLE $VER${N}(${Bl}$REL${N})"
echo "by ${W}$AUTHOR${N}"
echo "$div"
echo "${W}$BRAND,$MODEL,$DEVICE,$ROM${N}"
echo "$div"
echo "${W}$PATH${N}"
echo "${W}$BBV${N}"
echo "${W}$_bb${N}"
echo "$div"
if $MAGISK; then
magisk_version
echo "$div"
fi
}
#=========================== Main
# > You can start your MOD here.
# > You can add functions, variables & etc.
# > Rather than editing the default vars above.
#Log Functions
# Saves the previous log (if available) and creates a new one
log_start() {
if [ -f "$LOG" ]; then
mv -f $LOG $oldLOG
fi
touch $LOG
echo " " >> $LOG 2>&1
echo " *********************************************" >> $LOG 2>&1
echo " * Pix3lify *" >> $LOG 2>&1
echo " *********************************************" >> $LOG 2>&1
echo " * $VER *" >> $LOG 2>&1
echo " *********************************************" >> $LOG 2>&1
echo " * Joey Huab, Aidan Holland, Pika *" >> $LOG 2>&1
echo " * John Fawkes, Laster K. (lazerl0rd) *" >> $LOG 2>&1
echo " *********************************************" >> $LOG 2>&1
echo " " >> $LOG 2>&1
log_script_chk "Log start."
}
# PRINT MOD NAME
log_start
collect_logs() {
log_handler "Collecting logs and information."
# Create temporary directory
mkdir -pv $TMPLOGLOC >> $LOG 2>&1
# Saving Magisk and module log files and device original build.prop
for ITEM in $LOGGERS; do
if [ -f "$ITEM" ]; then
case "$ITEM" in
*build.prop*) BPNAME="build_$(echo $ITEM | sed 's|\/build.prop||' | sed 's|.*\/||g').prop"
;;
*) BPNAME=""
;;
esac
cp -af $ITEM ${TMPLOGLOC}/${BPNAME} >> $LOG 2>&1
else
case "$ITEM" in
*/cache)
if [ "$CACHELOC" == "/cache" ]; then
CACHELOCTMP=/cache
else
CACHELOCTMP=/data/cache
fi
ITEMTPM=$(echo $ITEM | sed 's|$CACHELOC|$CACHELOCTMP|')
if [ -f "$ITEMTPM" ]; then
cp -af $ITEMTPM $TMPLOGLOC >> $LOG 2>&1
else
log_handler "$ITEM not available."
fi
;;
*) log_handler "$ITEM not available."
;;
esac
fi
done
# Saving the current prop values
if $MAGISK; then
log_handler "RESETPROPS"
echo "==========================================" >> $LOG 2>&1
resetprop >> $LOG 2>&1
else
log_handler "GETPROPS"
echo "==========================================" >> $LOG 2>&1
getprop >> $LOG 2>&1
fi
if $MAGISK; then
log_print " Collecting Modules Installed "
echo "==========================================" >> $LOG 2>&1
ls $MOUDLEROOT >> $LOG 2>&1
log_print " Collecting Logs for Installed Files "
echo "==========================================" >> $LOG 2>&1
log_handler "$(du -ah $MOUNTEDROOT)" >> $LOG 2>&1
if grep -qF "com.google.android.dialer" $LIST; then
log_print " Collecting Logs for Call Screening Patches "
echo "==========================================" >> $LOG 2>&1
grep "$MODID" -B 1 $DPF >> $LOG 2>&1
else
log_print " Google Dialer not Detected "
echo "==========================================" >> $LOG 2>&1
fi
fi
# Package the files
cd $CACHELOC
tar -zcvf Pix3lify_logs.tar.xz Pix3lify_logs >> $LOG 2>&1
# Copy package to internal storage
mv -f $CACHELOC/Pix3lify_logs.tar.xz $SDCARD >> $LOG 2>&1
if [ -e $SDCARD/Pix3lify_logs.tar.xz ]; then
log_print "Pix3lify_logs.tar.xz Created Successfully."
else
log_print "Archive File Not Created. Error in Script. Please contact the Pix3lify Team"
fi
# Remove temporary directory
rm -rf $TMPLOGLOC >> $LOG 2>&1
log_handler "Logs and information collected."
}
# Load functions
log_start "Running Log script." >> $LOG 2>&1
menu() {
choice=""
while [ "$choice" != "q" ];
do
echo "$div"
echo ""
echo "__________._______ ___________ .____ .___________________.___."
echo "\______ \ \ \/ /\_____ \| | | \_ _____/\__ | |"
echo " | ___/ |\ / _(__ <| | | || __) / | |"
echo " | | | |/ \ / \ |___| || \ \____ |"
echo " |____| |___/___/\ \/______ /_______ \___|\___ / / ______|"
echo " \_/ \/ \/ \/ \/ "
echo ""
echo "$div"
mod_head
echo ""
echo "${G}Welcome to the logging section of PIX3LIFY!${N}"
echo "${G}If you are expirencing any bugs or issues then${N}"
echo "${G}please send us logs. After choosing yes below the script${N}"
echo "${G}will automatically gather the needed files and create a tar.xz${N}"
echo "${G}in your internal storage then send the tar.xz to our server${N}"
echo "${G}It will then delete the tar.xz from your device${N}"
echo "${G}WE DO NOT COLLECT ANY PERSONAL INFORMATION!${N}"
echo "$div"
echo ""
echo -e "${B}Please make a Selection${N}"
echo ""
echo -e "${W}L)${N} ${B}Logging${N}"
echo ""
echo -e "${W}Q)${N} ${B}Quit${N}"
echo "$div"
echo ""
echo -n "${R}[CHOOSE] : ${N}"
read -r choice
case $choice in
l|L) log_print " Collecting logs and creating archive "
magisk_version
collect_logs
upload_logs
rm -f $SDCARD/Pix3lify_logs.tar.xz
break
;;
q|Q) echo "${R}quiting!${N}"
clear
quit
;;
*) echo "${Y}item not available! Try Again${N}"
clear
;;
esac
done
echo -n "${R}quit? < y | n > : ${N}"
read -r mchoice
[ "$mchoice" = "n" ] && menu || clear && quit
}
menu
quit $?