]> git.pld-linux.org Git - packages/apport.git/blob - apport.init
- initial release
[packages/apport.git] / apport.init
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
56 # See how we were called.
57 case "$1" in
58   start)
59         start
60         ;;
61   stop)
62         stop
63         ;;
64   status)
65         # FIXME are these the right return values?
66         if grep -q 'apport' $PATFILE; then
67                 echo $"Apport is enabled."
68                 exit 0
69         else
70                 echo $"Apport is disabled."
71                 exit 1
72         fi
73         ;;
74   restart|reload)
75         stop
76         start
77         ;;
78   *)
79         echo $"Usage: $0 {start|stop|status|restart|reload}"
80         exit 1
81 esac
82
83 exit 0
84
This page took 0.035574 seconds and 3 git commands to generate.