-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost-fs-data.sh
More file actions
99 lines (84 loc) · 1.85 KB
/
post-fs-data.sh
File metadata and controls
99 lines (84 loc) · 1.85 KB
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
#!/system/bin/sh
# Magisk Module: ToyBox-Ext v1.0.9
# Copyright (c) zgfg @ xda, 2022-
# GitHub source: https://github.com/zgfg/ToyBox-Ext
# Module's own path (local path)
MODDIR=${0%/*}
# Log file for debugging
LogFile="$MODDIR/post-fs-data.log"
exec 3>&1 4>&2 2>$LogFile 1>&2
set -x
# Log Magisk version and magisk --path
magisk -c
magisk --path
# Source the original toybox binary type
cd $MODDIR
pwd
TBSCRIPT='./tbtype.sh'
if [ -f $TBSCRIPT ]
then
. $TBSCRIPT
fi
# ToyBox-Ext
TB=toybox
TBEXT=toybox-ext
if [ ! -z $TBTYPE ] && [ -f $TBTYPE ]
then
# Replace toybox-ext with the latest downloaded binary
mv $TBTYPE $TBEXT
fi
chmod 755 $TBEXT
# Clean-up old stuff
rm -rf "$MODDIR/system"
# Choose XBIN or BIN path
SDIR=/system/xbin
if [ ! -d $SDIR ]
then
SDIR=/system/bin
fi
TBDIR=$MODDIR$SDIR
mkdir -p $TBDIR
cd $TBDIR
pwd
# ToyBox-Ext applets
TBEXTBIN=$MODDIR/$TBEXT
Applets=$TB$'\n'$TBEXT$'\n'$($TBEXTBIN)
# Create symlinks for toybox-ext applets
for Applet in $Applets
do
if [ ! -x $SDIR/$Applet ]
then
# Create symlink
ln -s $TBEXTBIN $Applet
fi
done
# Stock ToyBox applets
TBSTOCK=$(which $TB)
Applets=""
if [ ! -z "$TBSTOCK" ]
then
TBPATH=$(echo "$TBSTOCK" | sed "s,/$TB$,,")
Applets=$TB$'\n'$($TBSTOCK)
fi
# Create symlinks for toybox-stock applets
for Applet in $Applets
do
if [ ! -h "$Applet" ] && [ ! -x "$TBPATH/$Applet" ] && [ ! -x "$SDIR/$Applet" ]
then
# Create symlink
ln -s $TBSTOCK $Applet
fi
done
chmod 755 *
chcon u:object_r:system_file:s0 *
# Log results for ToyBox-Ext
ls -lZ $TBEXT
$TBEXTBIN --version
ls -l | grep $TBEXT | grep ^lr.x | rev | cut -d ' ' -f 3 | rev
ls -l | grep $TBEXT | grep ^lr.x | wc -l
# Log results for stock ToyBox
$TBSTOCK --version
ls -l | grep $TB | grep -v $TBEXT | grep ^lr.x | rev | cut -d ' ' -f 3 | rev
ls -l | grep $TB | grep -v $TBEXT | grep ^lr.x | wc -l
set +x
exec 1>&3 2>&4 3>&- 4>&-