blob: b81c1a13b6cda5142dca402d13b31a97f94aa688 (
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
|
user=natfrp
confDir="/etc/natfrp"
service=natfrp.service
pre_install() {
id $user >& /dev/null
if [ $? -ne 0 ]; then
useradd -r -M -s /usr/bin/nologin $user
fi
}
post_install() {
if [ ! -f $confDir/config.json ]; then
chown natfrp:natfrp -R $confDir
echo -e 'Please go to the URL below to finish setup.'
env NATFRP_SERVICE_WD=/etc/natfrp NATFRP_FRPC_PATH=/usr/bin/natfrpc natfrp-service webui --init
systemctl daemon-reload
systemctl start $service
fi
if systemctl -q is-active $service; then
systemctl daemon-reload
systemctl restart $service
fi
}
post_upgrade() {
post_install
}
pre_remove() {
if systemctl -q is-enableed $service; then
systemctl disable --now $service
elif systemctl -q is-active $service; then
systemctl stop $service
fi
}
post_remove() {
id $user >& /dev/null
if [ $? -eq 0 ]; then
userdel $user
fi
}
|