summaryrefslogtreecommitdiffstats
path: root/abrt-oops.init
blob: cb64daca772ae2acaf1f0c724605816e8f8c7fe8 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# Start ABRT kernel log watcher
#
# chkconfig: 35 82 16
# description: Watches system log for oops messages, creates ABRT dump directories for each oops
### BEGIN INIT INFO
# Provides: abrt-oops
# Required-Start: $abrtd
# Default-Stop: 0 1 2 6
# Default-Start: 3 5
# Short-Description: Watches system log for oops messages, creates ABRT dump directories for each oops
# Description: Watches system log for oops messages, creates ABRT dump directories for each oops
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# For debugging
dry_run=false
verbose=false

# We don't have pid files, therefore have to use
# a flag file in /var/lock/subsys to enable GUI service tools
# to figure out our status
LOCK="/var/lock/subsys/abrt-oops"

RETVAL=0

check() {
	# Check that we're a privileged user
	[ "`id -u`" = 0 ] || exit 4
}

start() {
	check
	killall abrt-dump-oops 2>/dev/null
	setsid abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages </dev/null >/dev/null 2>&1 &
	$dry_run || touch -- "$LOCK"
	return $RETVAL
}

stop() {
	check
	killall abrt-dump-oops
	$dry_run || rm -f -- "$LOCK"
	return $RETVAL
}

restart() {
	stop
	start
}

reload() {
	restart
}

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
reload)
	reload
	;;
force-reload)
	echo "$0: Unimplemented feature."
	RETVAL=3
	;;
restart)
	restart
	;;
condrestart)
	# Is it already running?
	if test -f "$LOCK"; then   # yes
		$verbose && printf "Running, restarting\n"
		restart
	fi
	;;
status)
	# Is it already running?
	if test -f "$LOCK"; then   # yes
		$verbose && printf "Running\n"
		RETVAL=0
	else
		$verbose && printf "Not running\n"
		RETVAL=3  # "stopped normally"
	fi
	;;
*)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
	RETVAL=2
esac

exit $RETVAL