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