5
# Required-Start: $local_fs $remote_fs
6
# Required-Stop: $local_fs $remote_fs
7
# Default-Start: 2 3 4 5
9
# Short-Description: automatic crash report generation
13
DESC="automatic crash report generation"
15
AGENT=/usr/share/apport/apport
16
SCRIPTNAME=/etc/init.d/$NAME
18
# Exit if the package is not installed
19
[ -x "$AGENT" ] || exit 0
23
[ -e /etc/default/$NAME ] && . /etc/default/$NAME || true
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
30
# Function that starts the daemon/service
35
# 0 if daemon has been started
36
# 1 if daemon was already running
37
# 2 if daemon could not be started
39
[ -e /var/crash ] || mkdir -p /var/crash
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
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
55
echo "|$AGENT %p %s %c" > /proc/sys/kernel/core_pattern
59
# Function that stops the daemon/service
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
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
75
if [ "`dd if=/proc/sys/kernel/core_pattern count=1 bs=1 2>/dev/null`" != "|" ]; then
78
echo "core" > /proc/sys/kernel/core_pattern
84
[ "$enabled" = "1" ] || [ "$force_start" = "1" ] || exit 0
85
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC:" "$NAME"
88
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
89
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
93
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC:" "$NAME"
96
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
97
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
100
restart|force-reload)
105
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2