-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomize.sh
129 lines (112 loc) · 2.5 KB
/
customize.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
#!/system/bin/sh
# Magisk Module: ToyBox-Ext v1.0.9
# Copyright (c) zgfg @ xda, 2022-
# GitHub source: https://github.com/zgfg/ToyBox-Ext
if [ -z $BOOTMODE ] || [ "$BOOTMODE" != "true" ]
then
abort "ERROR: Install from Magisk app, not from TWRP!"
fi
# Log file for debugging - uncomment for logging
#LogFile="$MODPATH/customize.log"
if [ ! -z $LogFile ]
then
exec 3>&1 4>&2 2>$LogFile 1>&2
set -x
date +%c
# Log Magisk version and magisk --path
magisk -c
magisk --path
# Log dual-slots ROM info
getprop ro.product.cpu.abi
getprop ro.product.cpu.abilist
fi
# Module's own path (local path)
cd $MODPATH
pwd
# toybox ARMv7 and higher binaries
TBTYPEList="
toybox-aarch64
toybox-armv7m
toybox-armv7l
"
# toybox binary to be installed
TBEXT=toybox-ext
# Find the applicable binary
TBTYPE=""
for TB in $TBTYPEList
do
if [ -z $TBTYPE ]
then
# Test if binary executes
echo "Testing archived $TB"
chmod 755 $TB
Applets=$(./$TB)
if [ ! -z "$Applets" ]
then
# Applicable binary found
TBTYPE=$TB
mv $TBTYPE $TBEXT
Version=$(./$TBEXT --version)
echo "Archived $TBTYPE $Version installed"
continue
fi
fi
# Delete binary (already found or doesn't execute)
rm -f $TB
done
if [ -z $TBTYPE ]
then
# Applicable binary not found
echo
echo "ERROR: ToyBox not installed!"
echo
echo "$(cat /proc/cpuinfo)"
echo
exit -1
fi
# Current time
DLTIME=$(date +"%s")
# Save the toybox binary type and installation time
TBSCRIPT='./tbtype.sh'
echo "TBTYPE=$TBTYPE" > $TBSCRIPT
echo "LASTDLTIME=$DLTIME" >> $TBSCRIPT
# Download latest binary
echo "Downloading latest $TBTYPE"
wget -c -T 10 "http://landley.net/toybox/bin/$TBTYPE"
# Test the download
if [ ! -f $TBTYPE ]
then
# Not downloaded
echo "$TBTYPE not downloaded"
else
echo "Testing downloaded $TBTYPE"
# Compare checksums for the old and new binary
MD5Old=$(md5sum $TBEXT | head -c 32)
MD5New=$(md5sum "$TBTYPE" | head -c 32)
if [ "$MD5New" = "$MD5Old" ]
then
# Delete, same as old binary
echo "Downloaded $TBTYPE same version as installed"
rm -f $TBTYPE
else
# Test downloaded binary
chmod 755 $TBTYPE
Applets=$(./$TBTYPE)
if [ -z "$Applets" ]
then
# Delete, not working
echo "Downloaded $TBTYPE not working"
rm -f $TBTYPE
else
# Install
mv $TBTYPE $TBEXT
Version=$(./$TBEXT --version)
echo "Downloaded $TBTYPE $Version installed"
fi
fi
fi
if [ ! -z $LogFile ]
then
set +x
exec 1>&3 2>&4 3>&- 4>&-
fi