-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
post-fs-data.sh
110 lines (91 loc) · 2.27 KB
/
post-fs-data.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
mount -o rw,remount /data
MODPATH=${0%/*}
# log
exec 2>$MODPATH/debug-pfsd.log
set -x
# var
API=`getprop ro.build.version.sdk`
ABI=`getprop ro.product.cpu.abi`
# function
permissive() {
if [ "$SELINUX" == Enforcing ]; then
if ! setenforce 0; then
echo 0 > /sys/fs/selinux/enforce
fi
fi
}
magisk_permissive() {
if [ "$SELINUX" == Enforcing ]; then
if [ -x "`command -v magiskpolicy`" ]; then
magiskpolicy --live "permissive *"
else
$MODPATH/$ABI/libmagiskpolicy.so --live "permissive *"
fi
fi
}
sepolicy_sh() {
if [ -f $FILE ]; then
if [ -x "`command -v magiskpolicy`" ]; then
magiskpolicy --live --apply $FILE 2>/dev/null
else
$MODPATH/$ABI/libmagiskpolicy.so --live --apply $FILE 2>/dev/null
fi
fi
}
# selinux
SELINUX=`getenforce`
chmod 0755 $MODPATH/*/libmagiskpolicy.so
#1permissive
#2magisk_permissive
#kFILE=$MODPATH/sepolicy.rule
#ksepolicy_sh
FILE=$MODPATH/sepolicy.pfsd
sepolicy_sh
# 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
if [ -L $MODPATH/system/vendor ]\
&& [ -d $MODPATH/vendor ]; then
chcon -R u:object_r:vendor_file:s0 $MODPATH/vendor
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH/vendor/etc
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH/vendor/odm/etc
else
chcon -R u:object_r:vendor_file:s0 $MODPATH/system/vendor
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH/system/vendor/etc
chcon -R u:object_r:vendor_configs_file:s0 $MODPATH/system/vendor/odm/etc
fi
fi
# function
mount_helper() {
if [ -d /odm ]\
&& [ "`realpath /odm/etc`" == /odm/etc ]; then
DIR=$MODPATH/system/odm
FILES=`find $DIR -type f -name $AUD`
for FILE in $FILES; do
DES=/odm`echo $FILE | sed "s|$DIR||g"`
umount $DES
mount -o bind $FILE $DES
done
fi
if [ -d /my_product ]; then
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"`
umount $DES
mount -o bind $FILE $DES
done
fi
}
# mount
if ! grep -E 'delta|Delta|kitsune' /data/adb/magisk/util_functions.sh; then
mount_helper
fi