dumpon revision 298514
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/dumpon 298514 2016-04-23 16:10:54Z lme $ 4# 5 6# PROVIDE: dumpon 7# REQUIRE: zvol 8# BEFORE: disks 9# KEYWORD: nojail 10 11. /etc/rc.subr 12 13name="dumpon" 14desc="Dump kernel corefiles from swap to disk" 15start_cmd="dumpon_start" 16stop_cmd="dumpon_stop" 17 18dumpon_try() 19{ 20 if /sbin/dumpon "${1}" ; then 21 # Make a symlink in devfs for savecore 22 ln -fs "${1}" /dev/dumpdev 23 return 0 24 fi 25 warn "unable to specify $1 as a dump device" 26 return 1 27} 28 29dumpon_start() 30{ 31 # Enable dumpdev so that savecore can see it. Enable it 32 # early so a crash early in the boot process can be caught. 33 # 34 case ${dumpdev} in 35 [Nn][Oo] | '') 36 ;; 37 [Aa][Uu][Tt][Oo]) 38 dev=$(/bin/kenv -q dumpdev) 39 if [ -n "${dev}" ] ; then 40 dumpon_try "${dev}" 41 return $? 42 fi 43 while read dev mp type more ; do 44 [ "${type}" = "swap" ] || continue 45 [ -c "${dev}" ] || continue 46 dumpon_try "${dev}" 2>/dev/null && return 0 47 done </etc/fstab 48 echo "No suitable dump device was found." 1>&2 49 return 1 50 ;; 51 *) 52 dumpon_try "${dumpdev}" 53 ;; 54 esac 55} 56 57dumpon_stop() 58{ 59 case ${dumpdev} in 60 [Nn][Oo] | '') 61 ;; 62 *) 63 rm -f /dev/dumpdev 64 /sbin/dumpon -v off 65 ;; 66 esac 67} 68 69load_rc_config $name 70run_rc_command "$1" 71