]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # Starts the abrt daemon | |
3 | # | |
4 | # chkconfig: 35 82 16 | |
5 | # description: Daemon to detect crashing apps | |
6 | # processname: abrtd | |
7 | ### BEGIN INIT INFO | |
8 | # Provides: abrt | |
9 | # Required-Start: $syslog $local_fs | |
10 | # Required-Stop: $syslog $local_fs | |
11 | # Default-Stop: 0 1 2 6 | |
12 | # Default-Start: 3 5 | |
13 | # Short-Description: start and stop abrt daemon | |
14 | # Description: Listen and dispatch crash events | |
15 | ### END INIT INFO | |
16 | ||
17 | # Source function library. | |
18 | . /etc/rc.d/init.d/functions | |
19 | ||
20 | # Get network config | |
21 | . /etc/sysconfig/network | |
22 | ||
23 | # Get service config - may override defaults | |
24 | [ -f /etc/sysconfig/abrtd ] && . /etc/sysconfig/abrtd | |
25 | ||
26 | # Check that networking is up. | |
27 | if is_yes "${NETWORKING}"; then | |
28 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
29 | msg_network_down "abrt daemon" | |
30 | exit 1 | |
31 | fi | |
32 | else | |
33 | exit 0 | |
34 | fi | |
35 | ||
36 | # configtest itself | |
37 | # must return non-zero if check failed | |
38 | # output is discarded if checkconfig is ran without details | |
39 | configtest() { | |
40 | # Check if abrt is executable | |
41 | test -x /usr/sbin/abrtd || return 5 | |
42 | } | |
43 | ||
44 | # wrapper for configtest | |
45 | checkconfig() { | |
46 | local details=${1:-0} | |
47 | ||
48 | if [ $details = 1 ]; then | |
49 | # run config test and display report (status action) | |
50 | show "Checking %s configuration" "abrt daemon"; busy | |
51 | local out | |
52 | out=$(configtest 2>&1) | |
53 | RETVAL=$? | |
54 | if [ $RETVAL = 0 ]; then | |
55 | ok | |
56 | else | |
57 | fail | |
58 | fi | |
59 | [ "$out" ] && echo >&2 "$out" | |
60 | else | |
61 | # run config test and abort with nice message if failed | |
62 | # (for actions checking status before action). | |
63 | configtest >/dev/null 2>&1 | |
64 | RETVAL=$? | |
65 | if [ $RETVAL != 0 ]; then | |
66 | show "Checking %s configuration" "abrt daemon"; fail | |
67 | nls 'Configuration test failed. See details with %s "checkconfig"' $0 | |
68 | exit $RETVAL | |
69 | fi | |
70 | fi | |
71 | } | |
72 | ||
73 | start() { | |
74 | # Check if the service is already running? | |
75 | if [ -f /var/lock/subsys/abrtd ]; then | |
76 | msg_already_running "abrt daemon" | |
77 | return | |
78 | fi | |
79 | ||
80 | checkconfig | |
81 | msg_starting "abrt daemon" | |
82 | daemon /usr/sbin/abrtd | |
83 | RETVAL=$? | |
84 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/abrtd | |
85 | } | |
86 | ||
87 | stop() { | |
88 | if [ ! -f /var/lock/subsys/abrtd ]; then | |
89 | msg_not_running "abrt daemon" | |
90 | return | |
91 | fi | |
92 | ||
93 | # Stop daemons. | |
94 | msg_stopping "abrt daemon" | |
95 | killproc abrtd | |
96 | rm -f /var/lock/subsys/abrtd | |
97 | } | |
98 | ||
99 | condrestart() { | |
100 | if [ ! -f /var/lock/subsys/abrtd ]; then | |
101 | msg_not_running "abrt daemon" | |
102 | RETVAL=$1 | |
103 | return | |
104 | fi | |
105 | ||
106 | checkconfig | |
107 | stop | |
108 | start | |
109 | } | |
110 | ||
111 | RETVAL=0 | |
112 | # See how we were called. | |
113 | case "$1" in | |
114 | start) | |
115 | start | |
116 | ;; | |
117 | stop) | |
118 | stop | |
119 | ;; | |
120 | restart) | |
121 | checkconfig | |
122 | stop | |
123 | start | |
124 | ;; | |
125 | try-restart) | |
126 | condrestart 0 | |
127 | ;; | |
128 | force-reload) | |
129 | condrestart 7 | |
130 | ;; | |
131 | checkconfig|configtest) | |
132 | checkconfig 1 | |
133 | ;; | |
134 | status) | |
135 | status abrtd | |
136 | RETVAL=$? | |
137 | ;; | |
138 | *) | |
139 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|checkconfig|status}" | |
140 | exit 3 | |
141 | esac |