-
Notifications
You must be signed in to change notification settings - Fork 59
/
candy.initd
44 lines (40 loc) · 1.07 KB
/
candy.initd
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
#!/sbin/openrc-run
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="candy daemon"
description="A reliable, low-latency, and anti-censorship virtual private network"
CANDY_NAME=${SVCNAME##*.}
if [ -n "${CANDY_NAME}" -a "${SVCNAME}" != "candy" ]; then
CANDY_PIDFILE="/run/candy.${CANDY_NAME}.pid"
CANDY_CONFIG="/etc/candy.d/${CANDY_NAME}.cfg"
CANDY_LOG="/var/log/candy/${CANDY_NAME}.log"
else
CANDY_PIDFILE="/run/candy.pid"
CANDY_CONFIG="/etc/candy.cfg"
CANDY_LOG="/var/log/candy/candy.log"
fi
depend() {
need net
}
start_pre() {
if [ ! -d "/tmp/candy/" ]; then
mkdir "/tmp/candy"
fi
if [ ! -L "/var/log/candy" ]; then
ln -s "/tmp/candy" "/var/log/"
fi
}
start() {
ebegin "Starting Candy, Log File: ${CANDY_LOG}"
start-stop-daemon --start --background \
--stdout "${CANDY_LOG}" --stderr "${CANDY_LOG}" \
--make-pidfile --pidfile "${CANDY_PIDFILE}" \
--exec /usr/bin/candy -- -c "${CANDY_CONFIG}"
eend $?
}
stop() {
ebegin "Stopping Candy"
start-stop-daemon --stop \
--pidfile "${CANDY_PIDFILE}"
eend $?
}