1#!/bin/sh 2# 3# $FreeBSD$ 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 local flags 20 21 flags=${dumpon_flags} 22 if [ -n "${dumppubkey}" ]; then 23 warn "The dumppubkey variable is deprecated. Use dumpon_flags." 24 flags="${flags} -k ${dumppubkey}" 25 fi 26 /sbin/dumpon ${flags} "${1}" 27 if [ $? -eq 0 ]; then 28 # Make a symlink in devfs for savecore 29 ln -fs "${1}" /dev/dumpdev 30 return 0 31 fi 32 warn "unable to specify $1 as a dump device" 33 return 1 34} 35 36dumpon_start() 37{ 38 # Enable dumpdev so that savecore can see it. Enable it 39 # early so a crash early in the boot process can be caught. 40 # 41 case ${dumpdev} in 42 [Nn][Oo] | '') 43 ;; 44 [Aa][Uu][Tt][Oo]) 45 dev=$(/bin/kenv -q dumpdev) 46 if [ -n "${dev}" ] ; then 47 dumpon_try "${dev}" 48 return $? 49 fi 50 while read dev mp type more ; do 51 [ "${type}" = "swap" ] || continue 52 [ -c "${dev}" ] || continue 53 dumpon_try "${dev}" 2>/dev/null && return 0 54 done </etc/fstab 55 echo "No suitable dump device was found." 1>&2 56 return 1 57 ;; 58 *) 59 dumpon_try "${dumpdev}" 60 ;; 61 esac 62} 63 64dumpon_stop() 65{ 66 case ${dumpdev} in 67 [Nn][Oo] | '') 68 ;; 69 *) 70 rm -f /dev/dumpdev 71 /sbin/dumpon -v off 72 ;; 73 esac 74} 75 76load_rc_config $name 77run_rc_command "$1" 78