]>
Commit | Line | Data |
---|---|---|
2d0b5ebb PZ |
1 | #!/bin/bash |
2 | # | |
3 | # apport Script to control apport handling of core dumps | |
4 | # | |
5 | # Author: Will Woods <wwoods@redhat.com> | |
6 | # | |
7 | # chkconfig: - 90 10 | |
8 | # description: Starts and stops apport crash handling | |
9 | ||
10 | # Source function library. | |
11 | . /etc/init.d/functions | |
12 | ||
13 | # The location of the core pattern file | |
14 | PATFILE=/proc/sys/kernel/core_pattern | |
15 | # The location of the apport binary | |
16 | APPORT='/usr/share/apport/apport %p %s %c' | |
17 | # Location to save the old core_pattern | |
18 | OLDPAT=/var/run/core_pattern | |
19 | ||
20 | # Return success if apport is already enabled | |
21 | apport_is_enabled() { | |
22 | # XXX check the lock here too? | |
23 | grep -q "^|.*apport" $PATFILE | |
24 | } | |
25 | ||
26 | enable_apport() { | |
27 | if ! apport_is_enabled; then | |
28 | cat $PATFILE > $OLDPAT | |
29 | echo "|$APPORT" > $PATFILE | |
30 | fi | |
31 | } | |
32 | ||
33 | disable_apport() { | |
34 | if apport_is_enabled; then | |
35 | cat $OLDPAT > $PATFILE | |
36 | rm -f $OLDPAT | |
37 | fi | |
38 | } | |
39 | ||
40 | start() { | |
41 | show "Enabling apport crash handling" | |
42 | busy | |
43 | enable_apport | |
44 | touch /var/lock/subsys/apport | |
45 | ok | |
46 | } | |
47 | ||
48 | stop() { | |
49 | show "Disabling apport crash handling" | |
50 | busy | |
51 | disable_apport | |
52 | rm -f /var/lock/subsys/apport | |
53 | ok | |
54 | } | |
55 | ||
65b88726 | 56 | RETVAL=0 |
2d0b5ebb PZ |
57 | # See how we were called. |
58 | case "$1" in | |
59 | start) | |
60 | start | |
61 | ;; | |
62 | stop) | |
63 | stop | |
64 | ;; | |
65 | status) | |
66 | # FIXME are these the right return values? | |
67 | if grep -q 'apport' $PATFILE; then | |
65b88726 | 68 | echo "Apport is enabled." |
2d0b5ebb PZ |
69 | exit 0 |
70 | else | |
65b88726 | 71 | echo "Apport is disabled." |
2d0b5ebb PZ |
72 | exit 1 |
73 | fi | |
74 | ;; | |
75 | restart|reload) | |
76 | stop | |
77 | start | |
78 | ;; | |
79 | *) | |
65b88726 ER |
80 | msg_usage "$0 {start|stop|status|restart|reload}" |
81 | exit 3 | |
2d0b5ebb PZ |
82 | esac |
83 | ||
65b88726 | 84 | exit $RETVAL |