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