forked from Kr328/clash-premium-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
executable file
·113 lines (88 loc) · 2.8 KB
/
installer.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
#!/bin/bash
cd "`dirname $0`"
INSTALL_DIR=/usr/local/bin
function assert() {
"$@"
if [ "$?" != 0 ]; then
echo "Execute $@ failure"
exit 1
fi
}
function assert_command() {
if ! which "$1" > /dev/null 2>&1;then
echo "Command $1 not found"
exit 1
fi
}
function _install() {
assert_command install
assert_command nft
assert_command ip
if [ ! -d "/usr/lib/udev/rules.d" ];then
echo "udev not found"
exit 1
fi
if [ ! -d "/usr/lib/systemd/system" ];then
echo "systemd not found"
exit 1
fi
if ! grep net_cls "/proc/cgroups" 2> /dev/null > /dev/null ;then
echo "cgroup not support net_cls"
exit 1
fi
if [ ! -f "./clash-premium" ];then
echo "Clash core not found."
echo "Please download it from https://github.com/Dreamacro/clash/releases/tag/premium, and rename to ./clash"
fi
assert install -d -m 0755 /etc/default/
assert install -d -m 0755 /usr/lib/clash/
assert install -m 0755 ./clash-premium ${INSTALL_DIR}/clash-premium
assert install -m 0644 scripts/clash-default /etc/default/clash
assert install -m 0755 scripts/bypass-proxy-pid ${INSTALL_DIR}/bypass-proxy-pid
assert install -m 0755 scripts/bypass-proxy ${INSTALL_DIR}/bypass-proxy
assert install -m 0700 scripts/clean-tun.sh /usr/lib/clash/clean-tun.sh
assert install -m 0700 scripts/setup-tun.sh /usr/lib/clash/setup-tun.sh
assert install -m 0700 scripts/setup-cgroup.sh /usr/lib/clash/setup-cgroup.sh
assert install -m 0644 scripts/clash.service /usr/lib/systemd/system/clash-premium.service
assert install -m 0644 scripts/99-clash.rules /usr/lib/udev/rules.d/99-clash.rules
echo "Install successfully"
echo ""
echo "Home directory at /srv/clash"
echo ""
echo "All dns traffic will be redirected to 1.0.0.1:53"
echo "Please use clash core's 'tun.dns-hijack' to handle it"
echo ""
echo "Use 'systemctl start clash' to start"
echo "Use 'systemctl enable clash' to enable auto-restart on boot"
exit 0
}
function _uninstall() {
assert_command systemctl
assert_command rm
systemctl stop clash
systemctl disable clash
rm -rf /usr/lib/clash
rm -rf /usr/lib/systemd/system/clash-premium.service
rm -rf /usr/lib/udev/rules.d/99-clash.rules
rm -rf ${INSTALL_DIR}/clash
rm -rf ${INSTALL_DIR}/bypass-proxy-uid
rm -rf ${INSTALL_DIR}/bypass-proxy
echo "Uninstall successfully"
exit 0
}
function _help() {
echo "Clash Premiun Installer"
echo ""
echo "Usage: ./installer.sh [option]"
echo ""
echo "Options:"
echo " install - install clash premiun core"
echo " uninstall - uninstall installed clash premiun core"
echo ""
exit 0
}
case "$1" in
"install") _install;;
"uninstall") _uninstall;;
*) _help;
esac