File rc.apport of Package apport
#!/bin/sh
### BEGIN INIT INFO
# Provides: apport
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Apport crash handling
# Description: Starts and stops apport crash handling
### END INIT INFO
# Source LSB init functions
. /lib/lsb/init-functions
DESC="apport crash handling"
# The location of the apport binary
AGENT=/usr/share/apport/apport
# The location of the core pattern file
PATFILE=/proc/sys/kernel/core_pattern
# Location to save the old core_pattern
OLDPAT=/var/run/apport.old-core_pattern
set -o noclobber
# Return success if apport is already enabled
apport_is_enabled() {
grep -q "^|.*apport" $PATFILE
}
#
# Function that starts the daemon/service
#
start_apport()
{
if ! apport_is_enabled; then
cat $PATFILE > $OLDPAT
echo "|$AGENT %p %s %c" >| /proc/sys/kernel/core_pattern
fi
}
#
# Function that stops the daemon/service
#
stop_apport()
{
if apport_is_enabled; then
cat $OLDPAT >| $PATFILE
rm -f $OLDPAT
fi
}
case "$1" in
start)
start_apport
log_success_msg "Starting $DESC"
;;
stop)
stop_apport
log_success_msg "Stopping $DESC"
;;
restart|reload)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
status)
# Return value is slightly different for the status command:
# 0 - service up and running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running (unused)
# 4 - service status unknown :-(
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
echo -n "Checking for $DESC ..."
if apport_is_enabled; then
rc_failed 0
else
rc_failed 3
fi
rc_status -v
;;
try-restart|condrestart)
if apport_is_enabled; then
stop_apport
start_apport
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|try-restart}"
exit 1
;;
esac
exit 0