aboutsummaryrefslogtreecommitdiffstats
path: root/unmaintained/sems/sems.initd
blob: fda1e8a83879db044bb8984f9aaa76035f90839e (plain) (blame)
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
#!/sbin/openrc-run
# SIP Express Media Server configuration file
# Follows Gentoo/AlpineLinux standards 
# GPL 2 License - N. Angelacos 2011

SVC="${SVCNAME#*.}"
SEMS_CFG_FILE=${SEMS_CFG_FILE:-/etc/sems/${SVC}.conf}
SEMS_PIDDIR=/var/run/sems
SEMS_PIDFILE=${SEMS_PIDFILE:-${SEMS_PIDDIR}/${SVC}.pid}
SEMS_BINARY=${SEMS_BINARY:-/usr/sbin/sems}
SEMS_USER=${SEMS_USER:-sems}
SEMS_GROUP=${SEMS_GROUP:-sems}

checkconfig() {
	if [ ! -f "${SEMS_CFG_FILE}" ] ; then
		eerror "You need a "${SEMS_CFG_FILE}" file to run sems"
		return 1;
	fi
}


start() {
	checkconfig || return 1
	ebegin "Starting ${SVCNAME}"
	mkdir -p "${SEMS_PIDDIR}"
	chown ${SEMS_USER}:${SEMS_GROUP} "${SEMS_PIDDIR}"

	start-stop-daemon --start --exec "${SEMS_BINARY}" \
		--pidfile "${SEMS_PIDFILE}" \
		--wait ${SEMS_WAIT:-500} \
		-- \
		-f "${SEMS_CFG_FILE}" \
		-P "${SEMS_PIDFILE}" \
		-u "${SEMS_USER}" \
		-g "${SEMS_GROUP}"
	eend $?
}

stop() {
	if [ "${RC_CMD}" = "restart" ] ; then
		checkconfig || return 1
	fi

	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --exec "${SEMS_BINARY}" \
		--pidfile "${SEMS_PIDFILE}" --quiet
	eend $?
}