summaryrefslogtreecommitdiff
blob: 33490e39baf348ce6f4729cf8f89a5d1a7e104d4 (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-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

config_file=${config_file:-/etc/nxlog/${SVCNAME}.conf}
run_dir=${run_dir:-/run/nxlog}

command="/usr/bin/nxlog"
command_args="-c ${config_file}"
pidfile=${run_dir}/${SVCNAME}.pid
user=${user:-nxlog}
group=${group:-nxlog}

extra_started_commands="${opts} reload"

depend() {
	use net
}

check_config() {
	${command} ${command_args} -v >/dev/null
	return $?
}

start_pre() {
    checkpath -d -m 0750 -o "${user}":"${group}" "${run_dir}"
    if [ ! -f ${config_file} ]; then
    	eerror "Missing configuration file ${config_file}"
    	return 1
    fi
    check_config
    return $?
}

reload() {
	ebegin "Reloading ${SVCNAME}"
	check_config
	if [ $? == 0 ]; then
		${command} ${command_args} -r
		eend $?
	else
		eend 1
	fi
}