summaryrefslogtreecommitdiff
blob: 608dfc6f52bc38e8bae0a7e7f80b89a6ff7095cf (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-admin/syslog-ng/files/syslog-ng.rc6,v 1.14 2004/08/05 01:05:13 mr_bones_ Exp $

opts="depend checkconfig start stop reload"

depend() {
	# make networking dependency conditional on configuration
	sed 's/#.*//' /etc/syslog-ng/syslog-ng.conf | \
	grep -Eq '(source|destination).*(tcp|udp)' && need net

	need clock hostname
	provide logger
}

checkconfig() {
	if [ ! -e /etc/syslog-ng/syslog-ng.conf ] ; then
		eerror "You need to create /etc/syslog-ng/syslog-ng.conf first."
		eerror "An example can be found in /etc/syslog-ng/syslog-ng.conf.sample"
		return 1
	fi
	syslog-ng -s /etc/syslog-ng/syslog-ng.conf
	eend $? "Configuration error. Please fix your configfile (/etc/syslog-ng/syslog-ng.conf)"
}

start() {
	checkconfig || return 1
	ebegin "Starting syslog-ng"
	start-stop-daemon --start --quiet --exec /usr/sbin/syslog-ng
	eend $? "Failed to start syslog-ng"
}

stop() {
	ebegin "Stopping syslog-ng"
	start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng.pid
	eend $? "Failed to stop syslog-ng"
	sleep 1 # needed for syslog-ng to stop in case we're restarting
}

reload() {
	if [ ! -f /var/run/syslog-ng.pid ]; then
		eerror "syslog-ng isn't running"
		return 1
	fi
	checkconfig || return 1
	ebegin "Reloading configuration and re-opening log files"
	kill -HUP `cat /var/run/syslog-ng.pid` &>/dev/null
	eend $?
}