]> git.pld-linux.org Git - packages/apport.git/blob - apport.init
BR: rpmbuild(macros) >= 1.710
[packages/apport.git] / apport.init
1 #!/bin/sh
2 #
3 # apport    Script to control apport handling of core dumps
4 #
5 # chkconfig: 2345 90 10
6 # description:  Starts and stops apport crash handling
7
8 # $Id$
9
10 # Source function library.
11 . /etc/rc.d/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/bin/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         if [ ! -f /var/lock/subsys/apport ]; then
42                 show "Enabling Apport crash handling"
43                 busy
44                 enable_apport
45                 touch /var/lock/subsys/apport
46                 ok
47         else
48                 msg_already_running "Apport crash handling"
49         fi
50 }
51
52 stop() {
53         if [ -f /var/lock/subsys/apport ]; then
54                 show "Disabling Apport crash handling"
55                 busy
56                 disable_apport
57                 rm -f /var/lock/subsys/apport
58                 ok
59         else
60                 msg_not_running "Apport crash handling"
61         fi
62 }
63
64 RETVAL=0
65 # See how we were called.
66 case "$1" in
67   start)
68         start
69         ;;
70   stop)
71         stop
72         ;;
73   status)
74         # FIXME are these the right return values?
75         if grep -q 'apport' $PATFILE; then
76                 echo "Apport is enabled."
77                 exit 0
78         else
79                 echo "Apport is disabled."
80                 exit 1
81         fi
82         ;;
83   restart|reload)
84         stop
85         start
86         ;;
87   *)
88         msg_usage "$0 {start|stop|status|restart|reload}"
89         exit 3
90 esac
91
92 exit $RETVAL
This page took 0.076286 seconds and 3 git commands to generate.