aboutsummaryrefslogtreecommitdiff
blob: 75e558be7b64282afdfd7f30fc8796cb56d0f074 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/sbin/runscript
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-admin/syslog-ng/files/3.6/syslog-ng.rc6,v 1.3 2015/03/29 07:27:06 mr_bones_ Exp $

SYSLOG_NG_CONFIGFILE=${SYSLOG_NG_CONFIGFILE:-/etc/syslog-ng/${RC_SVCNAME}.conf}
SYSLOG_NG_STATEFILE_DIR=${SYSLOG_NG_STATEFILE_DIR:-/var/lib/syslog-ng}
SYSLOG_NG_STATEFILE=${SYSLOG_NG_STATEFILE:-${SYSLOG_NG_STATEFILE_DIR}/syslog-ng.persist}
SYSLOG_NG_PIDFILE_DIR=${SYSLOG_NG_PIDFILE_DIR:-/run}
SYSLOG_NG_PIDFILE=${SYSLOG_NG_PIDFILE:-${SYSLOG_NG_PIDFILE_DIR}/${RC_SVCNAME}.pid}

SYSLOG_NG_GROUP=${SYSLOG_NG_GROUP:-root}
SYSLOG_NG_USER=${SYSLOG_NG_USER:-root}

command="/usr/sbin/syslog-ng"
command_args="--persist-file \"${SYSLOG_NG_STATEFILE}\" --cfgfile \"${SYSLOG_NG_CONFIGFILE}\" --pidfile \"${SYSLOG_NG_PIDFILE}\" ${SYSLOG_NG_OPTS}"
extra_commands="checkconfig"
extra_started_commands="reload"
pidfile="${SYSLOG_NG_PIDFILE}"
start_stop_daemon_args="--user \"${SYSLOG_NG_USER}\":\"${SYSLOG_NG_GROUP}\""
description="Syslog-ng is a syslog replacement with advanced filtering features."
description_checkconfig="Check the configuration file that will be used by \"start\""
description_reload="Reload the configuration without exiting"
required_files="${SYSLOG_NG_CONFIGFILE}"
required_dirs="${SYSLOG_NG_PIDFILE_DIR}"

depend() {
	use clock
	need hostname localmount
	after bootmisc
	provide logger
}

checkconfig() {
	ebegin "Checking your configfile (${SYSLOG_NG_CONFIGFILE})"
	syslog-ng -s -f "${SYSLOG_NG_CONFIGFILE}"
	eend $? "Configuration error. Please fix your configfile (${SYSLOG_NG_CONFIGFILE})"
}

start_pre() {
	checkconfig || return 1
	checkpath \
		-d \
		--mode 0700 \
		--owner "${SYSLOG_NG_USER}:${SYSLOG_NG_GROUP}" \
		"${SYSLOG_NG_STATEFILE_DIR}"
}

stop_pre() {
	[ "$RC_CMD" = restart ] && sleep 1
	return 0
}

reload() {
	checkconfig || return 1
	ebegin "Reloading configuration and re-opening log files"
	start-stop-daemon --signal HUP --pidfile "${pidfile}"
	eend $?
}