-
Notifications
You must be signed in to change notification settings - Fork 2
/
customize.sh
132 lines (114 loc) · 5.06 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
SKIPUNZIP=1
status=""
architecture=""
system_gid="1000"
system_uid="1000"
clash_data_dir="/data/adb/clash"
modules_dir="/data/adb/modules"
bin_path="/system/bin/"
dns_path="/system/etc"
ca_path="${dns_path}/security/cacerts"
clash_data_dir_core="${clash_data_dir}/core"
CPFM_mode_dir="${modules_dir}/clash_premium"
mod_config="${clash_data_dir}/clash.config"
geoip_file_path="${clash_data_dir}/Country.mmdb"
proxy_provider_path="${clash_data_dir}/proxy_provider"
rule_provider_path="${clash_data_dir}/rule_provider"
ui_print "Installing Clash For Magisk..."
if [ -d "${CPFM_mode_dir}" ] ; then
touch ${CPFM_mode_dir}/remove && ui_print "- modul CFM akan dihapus setelah restart."
fi
ui_print "[0] Verifying Architecture : ${ARCH}"
case "${ARCH}" in
arm)
architecture="armv7"
;;
arm64)
architecture="armv8"
;;
esac
ui_print "[10] Making Directory for Clash For Magisk..."
mkdir -p ${MODPATH}/system/bin
mkdir -p ${clash_data_dir}
mkdir -p ${clash_data_dir_core}
mkdir -p ${clash_data_dir}/yacd-gh-pages
mkdir -p ${clash_data_dir}/yacd-gh-pages/meta
mkdir -p ${clash_data_dir}/yacd-gh-pages/yacd
mkdir -p ${clash_data_dir}/webserver
mkdir -p ${clash_data_dir}/webserver/bin
mkdir -p ${clash_data_dir}/webserver/www
mkdir -p ${proxy_provider_path}
mkdir -p ${rule_provider_path}
mkdir -p ${MODPATH}${ca_path}
ui_print "[25] Unzipping files..."
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 "- file konfigurasi telah berubah, dan file konfigurasi asli telah dicadangkan sebagai config.backup."
ui_print "- disarankan untuk memeriksa file konfigurasi sebelum me-restart telepon."
fi
mv ${MODPATH}/clash.config ${clash_data_dir}/
else
rm -rf ${MODPATH}/clash.config
fi
unzip -o ${MODPATH}/compressed/php-bin.zip -d ${clash_data_dir}/webserver/bin >&2
unzip -o ${MODPATH}/compressed/tinyfm.zip -d ${clash_data_dir}/webserver/www >&2
unzip -o ${MODPATH}/compressed/yacd-gh-pages.zip -d ${clash_data_dir}/yacd-gh-pages/yacd >&2
unzip -o ${MODPATH}/compressed/metacubexd.zip -d ${clash_data_dir}/yacd-gh-pages/meta >&2
ui_print "[50] Copying files..."
tar -xjf ${MODPATH}/binary/${ARCH}.tar.bz2 -C ${MODPATH}/system/bin/
mv ${MODPATH}/cacert.pem ${MODPATH}${ca_path}
mv ${MODPATH}/resolv.conf ${MODPATH}${dns_path}
mv ${MODPATH}/clash-dashboard ${clash_data_dir}
mv ${MODPATH}/Country.mmdb ${clash_data_dir}
mv ${MODPATH}/scripts ${clash_data_dir}
mv ${MODPATH}/config.yaml ${clash_data_dir}
mv ${MODPATH}/Command_CFM.prop ${clash_data_dir}
cp ${MODPATH}${bin_path}/clash ${clash_data_dir_core}
mv ${MODPATH}/compressed/addon/index.html ${clash_data_dir}/webserver/www
mv ${MODPATH}/geoip.dat ${clash_data_dir}
mv ${MODPATH}/geosite.dat ${clash_data_dir}
rm -rf ${MODPATH}/binary
rm -f ${MODPATH}/yacd-gh-pages.zip
rm -rf ${MODPATH}/yacd-gh-pages
mv ${MODPATH}/nosignal2.yaml ${clash_data_dir}
mv ${MODPATH}/config/proxy_provider/allProxy.yaml ${proxy_provider_path}
mv ${MODPATH}/config/rule_provider/blockedHost2.yaml ${rule_provider_path}
mv ${MODPATH}/config/rule_provider/umum.yaml ${rule_provider_path}
if [ ! -f "${clash_data_dir}/packages.list" ] ; then
touch ${clash_data_dir}/packages.list
fi
ui_print "[80] Removing Cache & Setting permission..."
sleep 1
set_perm_recursive ${MODPATH} 0 0 0755 0644
set_perm_recursive ${clash_data_dir} ${system_uid} ${system_gid} 0755 0644
set_perm_recursive ${clash_data_dir}/scripts ${system_uid} ${system_gid} 0755 0755
set_perm_recursive ${clash_data_dir}/yacd-gh-pages ${system_uid} ${system_gid} 0755 0644
set_perm_recursive ${clash_data_dir}/core ${system_uid} ${system_gid} 0755 0755
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}/system/bin/ss 0 0 0755
set_perm ${MODPATH}/system/bin/clash 0 0 6755
set_perm ${MODPATH}${ca_path}/cacert.pem 0 0 0644
set_perm ${MODPATH}${dns_path}/resolv.conf 0 0 0755
set_perm ${clash_data_dir}/scripts/clash.tproxy 0 0 0755
set_perm ${clash_data_dir}/scripts/clash.tool 0 0 0755
set_perm ${clash_data_dir}/scripts/clash.inotify 0 0 0755
set_perm ${clash_data_dir}/scripts/clash.service 0 0 0755
set_perm ${clash_data_dir}/clash.config ${system_uid} ${system_gid} 0755
set_perm ${clash_data_dir}/packages.list ${system_uid} ${system_gid} 0644
ui_print "[100] Installing Clash For Magisk done."
ui_print "- CONFIG UTAMA : nosignal2.yaml."
ui_print "- CONFIG AKUN : proxy_provider/allProxy.yaml."
ui_print "- CONFIG RULE : rule_provider/."
ui_print " "
ui_print "- YACD : http://127.0.0.1:9090/ui/yacd"
ui_print "- METACUBEXD : http://127.0.0.1:9090/ui/meta"
ui_print "- FILE MANAGER : http://127.0.0.1:9095/tinyfm"
ui_print " "
ui_print "- Restart Device sebelum menggunakan/mengedit config."
ui_print "- Jangan lupa edit akun."
ui_print " "
ui_print "- https://github.com/nosignals"