-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpost-fs-data.sh
More file actions
116 lines (97 loc) · 2.42 KB
/
Copy pathpost-fs-data.sh
File metadata and controls
116 lines (97 loc) · 2.42 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
100
101
102
103
104
105
mount -o rw,remount /data
MODPATH=${0%/*}
# log
exec 2>$MODPATH/debug-pfsd.log
set -x
# function
set_perm() {
chown $2:$3 $1 || return 1
chmod $4 $1 || return 1
local CON=$5
[ -z $CON ] && CON=u:object_r:system_file:s0
chcon $CON $1 || return 1
}
set_perm_recursive() {
find $1 -type d 2>/dev/null | while read dir; do
set_perm $dir $2 $3 $4 $6
done
find $1 -type f -o -type l 2>/dev/null | while read file; do
set_perm $file $2 $3 $5 $6
done
}
# permission
set_perm_recursive $MODPATH 0 0 0755 0644
# var
API=`getprop ro.build.version.sdk`
ABI=`getprop ro.product.cpu.abi`
if [ ! -d $MODPATH/vendor ]\
|| [ -L $MODPATH/vendor ]; then
MODSYSTEM=/system
fi
MOD=/data/adb/modules/nomount
NM=$MOD/bin/nm
NOMOUNT=false
[ ! -f $MOD/disable ] && [ -x $NM ] && $NM v >/dev/null 2>&1 && NOMOUNT=true
# run
. $MODPATH/copy.sh
. $MODPATH/.aml.sh
# permission
if [ "$API" -ge 26 ]; then
DIRS=`find $MODPATH/vendor\
$MODPATH/system/vendor -type d`
for DIR in $DIRS; do
chown 0.2000 $DIR
done
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH/system/odm/etc
chcon -R u:object_r:vendor_file:s0 $MODPATH$MODSYSTEM/vendor
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH$MODSYSTEM/vendor/etc
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH$MODSYSTEM/vendor/odm/etc
fi
# function
mount_odm() {
DIR=$MODPATH/system/odm
FILES=`find $DIR -type f -name $AUD`
for FILE in $FILES; do
DES=/odm`echo $FILE | sed "s|$DIR||g"`
RDES=`realpath $DES`
if [ -f $RDES ]; then
if $NOMOUNT; then
$NM del $RDES 2>/dev/null || true
$NM add $RDES $FILE
else
umount $RDES
mount -o bind $FILE $RDES
fi
fi
done
}
mount_my_product() {
DIR=$MODPATH/system/my_product
FILES=`find $DIR -type f -name $AUD`
for FILE in $FILES; do
DES=/my_product`echo $FILE | sed "s|$DIR||g"`
RDES=`realpath $DES`
if [ -f $RDES ]; then
if $NOMOUNT; then
$NM del $RDES 2>/dev/null || true
$NM add $RDES $FILE
else
umount $RDES
mount -o bind $FILE $RDES
fi
fi
done
}
# mount
if [ -d /odm ] && [ "`realpath /odm/etc`" == /odm/etc ]\
&& ! grep /odm /data/adb/magisk/magisk\
&& ! grep /odm /data/adb/magisk/magisk64\
&& ! grep /odm /data/adb/magisk/magisk32; then
mount_odm
fi
if [ -d /my_product ]\
&& ! grep /my_product /data/adb/magisk/magisk\
&& ! grep /my_product /data/adb/magisk/magisk64\
&& ! grep /my_product /data/adb/magisk/magisk32; then
mount_my_product
fi