forked from kalasutra/Clash_For_Magisk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize.sh
78 lines (67 loc) · 2.36 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
SKIPUNZIP=1
status=""
architecture=""
system_gid="1000"
system_uid="1000"
clash_data_dir="/data/clash"
modules_dir="/data/adb/modules"
ca_path="/system/etc/security/cacerts"
CPFM_mode_dir="${modules_dir}/clash_premium"
mod_config="${clash_data_dir}/clash.config"
geoip_file_path="${clash_data_dir}/Country.mmdb"
if [ -d "${CPFM_mode_dir}" ] ; then
touch ${CPFM_mode_dir}/remove && ui_print "- CPFM模块在重启后将会被删除."
fi
case "${ARCH}" in
arm)
architecture="armv7"
;;
arm64)
architecture="armv8"
;;
x86)
architecture="386"
;;
x64)
architecture="amd64"
;;
esac
mkdir -p ${MODPATH}/system/bin
mkdir -p ${clash_data_dir}
mkdir -p ${MODPATH}${ca_path}
unzip -o "${ZIPFILE}" -x 'META-INF/*' -d $MODPATH >&2
if [ "$(md5sum ${MODPATH}/clash.config | awk '{print $1}')" != "$(md5sum ${mod_config} | awk '{print $1}')" ] ; then
if [ -f "${mod_config}" ] ; then
mv -f ${mod_config} ${clash_data_dir}/config.backup
ui_print "- 配置文件有变化,原配置文件已备份为config.backup."
ui_print "- 建议查看配置文件无误后再重启手机."
fi
mv ${MODPATH}/clash.config ${clash_data_dir}/
else
rm -rf ${MODPATH}/clash.config
fi
if [ ! -f "${clash_data_dir}/template" ] ; then
mv ${MODPATH}/template ${clash_data_dir}/
else
rm -rf ${MODPATH}/template
fi
tar -xjf ${MODPATH}/binary/${ARCH}.tar.bz2 -C ${MODPATH}/system/bin/
mv ${MODPATH}/cacert.pem ${MODPATH}${ca_path}
mv ${MODPATH}/clash-dashboard ${clash_data_dir}/
rm -rf ${MODPATH}/binary
if [ ! -f "${clash_data_dir}/packages.list" ] ; then
touch ${clash_data_dir}/packages.list
fi
sleep 1
ui_print "- 开始设置环境权限."
set_perm_recursive ${MODPATH} 0 0 0755 0644
set_perm ${MODPATH}/system/bin/setcap 0 0 0755
set_perm ${MODPATH}/system/bin/getcap 0 0 0755
set_perm ${MODPATH}/system/bin/getpcaps 0 0 0755
set_perm ${MODPATH}${ca_path}/cacert.pem 0 0 0644
set_perm ${MODPATH}/system/bin/curl 0 0 0755
set_perm_recursive ${MODPATH}/scripts ${system_uid} ${system_gid} 0755 0755
set_perm_recursive ${clash_data_dir} ${system_uid} ${system_gid} 0755 0644
set_perm ${MODPATH}/system/bin/clash ${system_uid} ${system_gid} 6755
set_perm ${clash_data_dir}/clash.config ${system_uid} ${system_gid} 0755
set_perm ${clash_data_dir}/packages.list ${system_uid} ${system_gid} 0644