~brian-murray/apport/test-fix

« back to all changes in this revision

Viewing changes to debian/apport.init

  • Committer: Martin Pitt
  • Date: 2009-04-05 16:33:44 UTC
  • Revision ID: martin.pitt@canonical.com-20090405163344-xovjznkj37lsqjs5
Move cron.daily, init script, and default file from debian/ to etc/, and
install them in setup.py. These files are appropriate for upstream
installation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
 
3
 
### BEGIN INIT INFO
4
 
# Provides:          apport
5
 
# Required-Start:    $local_fs $remote_fs
6
 
# Required-Stop:     $local_fs $remote_fs
7
 
# Default-Start:     2 3 4 5
8
 
# Default-Stop:      
9
 
# Short-Description: automatic crash report generation
10
 
### END INIT INFO
11
 
 
12
 
PATH=/bin
13
 
DESC="automatic crash report generation"
14
 
NAME=apport
15
 
AGENT=/usr/share/apport/apport
16
 
SCRIPTNAME=/etc/init.d/$NAME
17
 
 
18
 
# Exit if the package is not installed
19
 
[ -x "$AGENT" ] || exit 0
20
 
 
21
 
# read default file
22
 
enabled=1
23
 
[ -e /etc/default/$NAME ] && . /etc/default/$NAME || true
24
 
 
25
 
# Define LSB log_* functions.
26
 
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
27
 
. /lib/lsb/init-functions
28
 
 
29
 
#
30
 
# Function that starts the daemon/service
31
 
#
32
 
do_start()
33
 
{
34
 
        # Return
35
 
        #   0 if daemon has been started
36
 
        #   1 if daemon was already running
37
 
        #   2 if daemon could not be started
38
 
 
39
 
        [ -e /var/crash ] || mkdir -p /var/crash
40
 
        chmod 1777 /var/crash
41
 
 
42
 
        # check for kernel crash dump, convert it to apport report
43
 
        if [ -e /var/crash/vmcore ]; then
44
 
            /usr/share/apport/kernel_crashdump || true
45
 
        fi
46
 
 
47
 
        # check for incomplete suspend/resume or hibernate
48
 
        export PATH="$PATH:/usr/bin"
49
 
        if [ -e /var/lib/pm-utils/status ]; then
50
 
                /usr/share/apport/apportcheckresume || true
51
 
                rm -f /var/lib/pm-utils/status
52
 
                rm -f /var/lib/pm-utils/resume-hang.log
53
 
        fi
54
 
 
55
 
        echo "|$AGENT %p %s %c" > /proc/sys/kernel/core_pattern
56
 
}
57
 
 
58
 
#
59
 
# Function that stops the daemon/service
60
 
#
61
 
do_stop()
62
 
{
63
 
        # Return
64
 
        #   0 if daemon has been stopped
65
 
        #   1 if daemon was already stopped
66
 
        #   2 if daemon could not be stopped
67
 
        #   other if a failure occurred
68
 
 
69
 
        # Check for a hung resume.  If we find one try and grab everything
70
 
        # we can to aid in its discovery.
71
 
        if [ -e /var/lib/pm-utils/status ]; then
72
 
                ps -wwef >/var/lib/pm-utils/resume-hang.log
73
 
        fi
74
 
 
75
 
        if [ "`dd if=/proc/sys/kernel/core_pattern count=1 bs=1 2>/dev/null`" != "|" ]; then
76
 
            return 1
77
 
        else
78
 
            echo "core" > /proc/sys/kernel/core_pattern
79
 
        fi
80
 
}
81
 
 
82
 
case "$1" in
83
 
  start)
84
 
        [ "$enabled" = "1" ] || [ "$force_start" = "1" ] || exit 0
85
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC:" "$NAME"
86
 
        do_start
87
 
        case "$?" in
88
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
89
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
90
 
        esac
91
 
        ;;
92
 
  stop)
93
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC:" "$NAME"
94
 
        do_stop
95
 
        case "$?" in
96
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
97
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
98
 
        esac
99
 
        ;;
100
 
  restart|force-reload)
101
 
        $0 stop || true
102
 
        $0 start
103
 
        ;;
104
 
  *)
105
 
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
106
 
        exit 3
107
 
        ;;
108
 
esac
109
 
 
110
 
: