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

# CANNASERVER_OPTS and CANNASERVER_OWNER is defined in /etc/conf.d/canna
CANNASERVER_LOGFILE="/var/log/canna/CANNA0msgs"

depend() {
	after logger
}

start() {
	if [ -S /tmp/.iroha_unix/IROHA ] ; then
		/usr/sbin/cannakill >/dev/null 2>&1
	fi
	rm -f /tmp/.iroha_unix/IROHA

	if [ "${CANNASERVER_ENABLE_SYSLOG}" = "yes" ] ; then
		CANNASERVER_OPTS="${CANNASERVER_OPTS} -syslog"
	else
		touch "${CANNASERVER_LOGFILE}"
		chmod u+w "${CANNASERVER_LOGFILEj}"
	fi

	if [ ! -z "${CANNASERVER_OWNER}" ] ; then
		if [ -f "${CANNASERVER_LOGFILE}" ] ; then
			chown "${CANNASERVER_OWNER}" "${CANNASERVER_LOGFILE}"
		fi
		CANNASERVER_OPTS="${CANNASERVER_OPTS} -u ${CANNASERVER_OWNER}"
	fi

	ebegin "Starting canna"
	/usr/sbin/cannaserver ${CANNASERVER_OPTS}
	eend $? "Failed to start canna"
}

stop() {
	ebegin "Stopping canna"
	/usr/sbin/cannakill
	eend $? "Failed to stop canna"
}