1 |
#!/bin/bash |
2 |
# Start ABRT kernel log watcher |
3 |
# |
4 |
# chkconfig: 35 82 16 |
5 |
# description: Watches system log for oops messages, creates ABRT dump directories for each oops |
6 |
### BEGIN INIT INFO |
7 |
# Provides: abrt-oops |
8 |
# Required-Start: $abrtd |
9 |
# Required-Stop: $abrtd |
10 |
# Default-Stop: 0 1 2 6 |
11 |
# Default-Start: 3 5 |
12 |
# Short-Description: Watches system log for oops messages, creates ABRT dump directories for each oops |
13 |
# Description: Watches system log for oops messages, creates ABRT dump directories for each oops |
14 |
### END INIT INFO |
15 |
|
16 |
# Source function library. |
17 |
. /etc/rc.d/init.d/functions |
18 |
|
19 |
# For debugging |
20 |
dry_run=false |
21 |
verbose=false |
22 |
|
23 |
# We don't have pid files, therefore have to use |
24 |
# a flag file in /var/lock/subsys to enable GUI service tools |
25 |
# to figure out our status |
26 |
LOCK="/var/lock/subsys/abrt-oops" |
27 |
|
28 |
RETVAL=0 |
29 |
|
30 |
check() { |
31 |
# Check that we're a privileged user |
32 |
[ "`id -u`" = 0 ] || exit 4 |
33 |
} |
34 |
|
35 |
start() { |
36 |
check |
37 |
killall abrt-dump-oops 2>/dev/null |
38 |
setsid abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages </dev/null >/dev/null 2>&1 & |
39 |
$dry_run || touch -- "$LOCK" |
40 |
return $RETVAL |
41 |
} |
42 |
|
43 |
stop() { |
44 |
check |
45 |
killall abrt-dump-oops |
46 |
$dry_run || rm -f -- "$LOCK" |
47 |
return $RETVAL |
48 |
} |
49 |
|
50 |
restart() { |
51 |
stop |
52 |
start |
53 |
} |
54 |
|
55 |
reload() { |
56 |
restart |
57 |
} |
58 |
|
59 |
case "$1" in |
60 |
start) |
61 |
start |
62 |
;; |
63 |
stop) |
64 |
stop |
65 |
;; |
66 |
reload) |
67 |
reload |
68 |
;; |
69 |
force-reload) |
70 |
echo "$0: Unimplemented feature." |
71 |
RETVAL=3 |
72 |
;; |
73 |
restart) |
74 |
restart |
75 |
;; |
76 |
condrestart) |
77 |
# Is it already running? |
78 |
if test -f "$LOCK"; then # yes |
79 |
$verbose && printf "Running, restarting\n" |
80 |
restart |
81 |
fi |
82 |
;; |
83 |
status) |
84 |
status abrt-dump-oops |
85 |
RETVAL=$? |
86 |
;; |
87 |
*) |
88 |
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}" |
89 |
RETVAL=2 |
90 |
esac |
91 |
|
92 |
exit $RETVAL |
93 |
|