#!/bin/bash # # apport Script to control apport handling of core dumps # # Author: Will Woods # # chkconfig: - 90 10 # description: Starts and stops apport crash handling # Source function library. . /etc/init.d/functions # The location of the core pattern file PATFILE=/proc/sys/kernel/core_pattern # The location of the apport binary APPORT='/usr/share/apport/apport %p %s %c' # Location to save the old core_pattern OLDPAT=/var/run/core_pattern # Return success if apport is already enabled apport_is_enabled() { # XXX check the lock here too? grep -q "^|.*apport" $PATFILE } enable_apport() { if ! apport_is_enabled; then cat $PATFILE > $OLDPAT echo "|$APPORT" > $PATFILE fi } disable_apport() { if apport_is_enabled; then cat $OLDPAT > $PATFILE rm -f $OLDPAT fi } start() { show "Enabling apport crash handling" busy enable_apport touch /var/lock/subsys/apport ok } stop() { show "Disabling apport crash handling" busy disable_apport rm -f /var/lock/subsys/apport ok } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; status) # FIXME are these the right return values? if grep -q 'apport' $PATFILE; then echo "Apport is enabled." exit 0 else echo "Apport is disabled." exit 1 fi ;; restart|reload) stop start ;; *) msg_usage "$0 {start|stop|status|restart|reload}" exit 3 esac exit $RETVAL