blob: 6edc1bb9745a12e692d9dc2b17acc1f7858a6d3f (
plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
pre_install() {
#打包的时候替换
PAK_ARCH="amd64"
#错误输出位置
ERR_OUT=/tmp/EasyConnect.install.error
#清空之前可能存在的错误日志信息
if [ -f $ERR_OUT ]
then
echo > $ERR_OUT
fi
uname -a | grep x86_64 > /dev/null
if [ $? -eq 0 ]
then
if [ $PAK_ARCH = "i386" ]
then
echo "deb pkg is 32bit, os is 64bit, can't install..."
echo "deb pkg is 32bit, os is 64bit, can't install..." >>$ERR_OUT
exit -1
fi
else
if [ $PAK_ARCH = "amd64" ]
then
echo "deb pkg is 64bit, os is 32bit, can't install..."
echo "deb pkg is 64bit, os is 32bit, can't install..." >>$ERR_OUT
exit -1
fi
fi
}
post_install() {
#######################################################################
#宏定义
EasyConnectDir=/usr/share/sangfor/EasyConnect
ResourcesDir=${EasyConnectDir}/resources
ECAGENT_IMPORT_CA=${ResourcesDir}"/usr/bin/ECAgent --install-import-cert"
#######################################################################
###################
#添加系统服务
###################
system_add_service()
{
systemctl enable EasyMonitor
systemctl start EasyMonitor
}
add_service()
{
#导入证书
${ECAGENT_IMPORT_CA} > /dev/null 2>&1
system_add_service
}
#更改文件权限
change_authority(){
#文件权限处理
chmod +x ${EasyConnectDir}/EasyConnect
#保证logs文件夹存在
mkdir -p ${ResourcesDir}/logs
chmod 755 ${ResourcesDir}/logs
###CSClient创建的域套接字的句柄在这个地方,要加写权限,可以考录换个目录
chmod 755 ${ResourcesDir}/conf -R
chmod +x ${ResourcesDir}/shell/*
#更改所有者
chown root:root ${ResourcesDir}/bin/ECAgent
chown root:root ${ResourcesDir}/bin/svpnservice
chown root:root ${ResourcesDir}/bin/CSClient
#添加s权限
chmod +s ${ResourcesDir}/bin/ECAgent
chmod +s ${ResourcesDir}/bin/svpnservice
chmod +s ${ResourcesDir}/bin/CSClient
}
#手动启动EasyMonitor,这里处理可能有不妥之处,需要修改
#${ResourcesDir}/bin/EasyMonitor
change_authority
add_service
exit 0
}
pre_upgrade() {
pre_install
}
post_upgrade() {
post_install
}
pre_remove() {
#EasyMonitor位置
EASYMONITOR="/usr/share/sangfor/EasyConnect/resources/bin/EasyMonitor"
###################
#删除系统服务
###################
system_del_service()
{
systemctl stop EasyMonitor
systemctl disable EasyMonitor
}
del_service()
{
system_del_service
}
#杀死可能存在的EC进程
kill_programe()
{
#停止所有相关进程
pidof EasyMonitor
if [ $? -eq 0 ];then
killall EasyMonitor
fi
pidof EasyMonitor
if [ $? -eq 0 ];then
killall -9 EasyMonitor
fi
pidof ECAgent
if [ $? -eq 0 ];then
killall ECAgent
fi
pidof ECAgent
if [ $? -eq 0 ];then
killall -9 ECAgent
fi
pidof EasyConnect
if [ $? -eq 0 ];then
killall EasyConnect
fi
pidof EasyConnect
if [ $? -eq 0 ];then
killall -9 EasyConnect
fi
pidof CSClient
if [ $? -eq 0 ];then
killall CSClient
fi
pidof CSClient
if [ $? -eq 0 ];then
killall -9 CSClient
fi
pidof svpnservice
if [ $? -eq 0 ];then
killall svpnservice
fi
pidof svpnservice
if [ $? -eq 0 ];then
killall -9 svpnservice
fi
}
#恢复之前修改的所有相关的配置信息
recover_ec()
{
#调用EasyMonitor
${EASYMONITOR} -a -r > /dev/null 2>&1
}
#停止服务
del_service
#杀死相关进程
kill_programe
#恢复配置
recover_ec
echo "rm pkg before..."
exit 0
}
post_remove() {
rm -rf /usr/share/sangfor/EasyConnect
exit 0
}
|