summaryrefslogtreecommitdiff
path: root/debian/kdump-tools.upstart
blob: fd3ba733f77457af122a33748113a02dbca7d4f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# kdump-tools

description	"kdump-tools"
author	 "Louis Bouchard <louis.bouchard@ubuntu.com>"

start on starting rc-sysinit
stop on runlevel [!2345]

console output

task

script
    PATH=/bin:/usr/bin:/sbin:/usr/sbin

    . /lib/lsb/init-functions
    . /lib/init/vars.sh

    VMCORE_FILE=/proc/vmcore
    KDUMP_SCRIPT=/usr/sbin/kdump-config
    KDUMP_DEFAULTS=/etc/default/kdump-tools
    [ -r $KDUMP_DEFAULTS ] && . $KDUMP_DEFAULTS

    [ ${USE_KDUMP:-0} -ne 0 ] || exit 0;

    #
    # If we have a /proc/vmcore, then we just panic'd
    #
    if [ -e $VMCORE_FILE -a -s $VMCORE_FILE ]; then
        $KDUMP_SCRIPT savecore
        if [ $? -ne 0 -a -n "$KDUMP_FAIL_CMD" ] ; then
            $KDUMP_FAIL_CMD ;
        else
	    #
	    # Since we panic'd, reboot to a normal system
	    #
            date -R ;
            reboot -f ;
        fi
    #
    # Else, we've just booted and need to load the kdump kernel
    #
    else
        $KDUMP_SCRIPT load
    fi
end script