summaryrefslogtreecommitdiff
blob: 0f33ccfa9cdbbe225e5b05d54a53f733ddd5519f (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
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

KEYFILE=${KEYFILE:="/etc/spiped/keyfile"}
SPIPED_USER=${SPIPED_USER:="nobody"}
PIDFILE="/run/spiped/spiped.pid"

command="spiped"
command_args="${OPTS} -s [${SRCHOST}]:${SRCPORT} -t ${TARGETHOST}:${TARGETPORT} -k ${KEYFILE} -p ${PIDFILE}"

depend() {
	use net
	before logger
}

checkconfig() {
  if [[ ! "$IS_CONFIGURED" == "yes" ]]; then
    eerror "You need to setup /etc/conf.d/spiped first!"
    return 1
  fi
}

start() {
	checkconfig || return 1

	ebegin "Starting ${SVCNAME}"
	checkpath -d -o "${SPIPED_USER}" -m750 "$(dirname "${PIDFILE}")"

	start-stop-daemon --start \
		--user ${SPIPED_USER} \
		--pidfile ${PIDFILE} \
		--exec $command -- $command_args
        
	eend $?
}

stop() {
	ebegin "Stopping ${SVCNAME}"
        
	start-stop-daemon --stop \
		--pidfile ${PIDFILE}
        
	eend $?
}