]> git.pld-linux.org Git - packages/apport.git/blame - apport.init
BR: rpmbuild(macros) >= 1.710
[packages/apport.git] / apport.init
CommitLineData
167708a4 1#!/bin/sh
2d0b5ebb
PZ
2#
3# apport Script to control apport handling of core dumps
4#
ecb0fcdd 5# chkconfig: 2345 90 10
2d0b5ebb
PZ
6# description: Starts and stops apport crash handling
7
167708a4
ER
8# $Id$
9
2d0b5ebb 10# Source function library.
167708a4 11. /etc/rc.d/init.d/functions
2d0b5ebb
PZ
12
13# The location of the core pattern file
14PATFILE=/proc/sys/kernel/core_pattern
15# The location of the apport binary
16d15efd 16APPORT='/usr/bin/apport %p %s %c'
2d0b5ebb
PZ
17# Location to save the old core_pattern
18OLDPAT=/var/run/core_pattern
19
20# Return success if apport is already enabled
21apport_is_enabled() {
22 # XXX check the lock here too?
23 grep -q "^|.*apport" $PATFILE
24}
25
26enable_apport() {
27 if ! apport_is_enabled; then
28 cat $PATFILE > $OLDPAT
29 echo "|$APPORT" > $PATFILE
30 fi
31}
32
33disable_apport() {
34 if apport_is_enabled; then
35 cat $OLDPAT > $PATFILE
36 rm -f $OLDPAT
37 fi
38}
39
40start() {
aa1408f4
ER
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
2d0b5ebb
PZ
50}
51
52stop() {
aa1408f4
ER
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
2d0b5ebb
PZ
62}
63
65b88726 64RETVAL=0
2d0b5ebb
PZ
65# See how we were called.
66case "$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
65b88726 76 echo "Apport is enabled."
2d0b5ebb
PZ
77 exit 0
78 else
65b88726 79 echo "Apport is disabled."
2d0b5ebb
PZ
80 exit 1
81 fi
82 ;;
83 restart|reload)
84 stop
85 start
86 ;;
87 *)
65b88726
ER
88 msg_usage "$0 {start|stop|status|restart|reload}"
89 exit 3
2d0b5ebb
PZ
90esac
91
65b88726 92exit $RETVAL
This page took 0.066135 seconds and 4 git commands to generate.