dumpon revision 179943
198184Sgordon#!/bin/sh 298184Sgordon# 398184Sgordon# $FreeBSD: head/etc/rc.d/dumpon 179943 2008-06-23 04:39:36Z mtm $ 498184Sgordon# 598184Sgordon 698184Sgordon# PROVIDE: dumpon 7144683Sobrien# BEFORE: disks savecore initrandom 8136224Smtm# KEYWORD: nojail 998184Sgordon 1098184Sgordon. /etc/rc.subr 1198184Sgordon 1298184Sgordonname="dumpon" 1398184Sgordonstart_cmd="dumpon_start" 14125341Spjdstop_cmd="dumpon_stop" 1598184Sgordon 16147107Sdesdumpon_try() 17147107Sdes{ 18179943Smtm if /sbin/dumpon "${1}" ; then 19147107Sdes # Make a symlink in devfs for savecore 20147107Sdes ln -fs "${1}" /dev/dumpdev 21147107Sdes return 0 22147107Sdes fi 23179943Smtm warn "unable to specify $1 as a dump device" 24147107Sdes return 1 25147107Sdes} 26147107Sdes 2798184Sgordondumpon_start() 2898184Sgordon{ 2998184Sgordon # Enable dumpdev so that savecore can see it. Enable it 3098184Sgordon # early so a crash early in the boot process can be caught. 3198184Sgordon # 3298184Sgordon case ${dumpdev} in 3398184Sgordon [Nn][Oo] | '') 3498184Sgordon ;; 35135525Sdes [Aa][Uu][Tt][Oo]) 36150103Srwatson dev=$(/bin/kenv -q dumpdev) 37147107Sdes if [ -n "${dev}" ] ; then 38147107Sdes dumpon_try "${dev}" 39147107Sdes return $? 40147107Sdes fi 41135525Sdes while read dev mp type more ; do 42135525Sdes [ "${type}" = "swap" ] || continue 43135525Sdes [ -c "${dev}" ] || continue 44147107Sdes dumpon_try "${dev}" 2>/dev/null && return 0 45135525Sdes done </etc/fstab 46135525Sdes echo "No suitable dump device was found." 1>&2 47135525Sdes return 1 48135525Sdes ;; 4998184Sgordon *) 50147107Sdes dumpon_try "${dumpdev}" 5198184Sgordon ;; 5298184Sgordon esac 5398184Sgordon} 5498184Sgordon 55125341Spjddumpon_stop() 56125341Spjd{ 57125341Spjd case ${dumpdev} in 58125341Spjd [Nn][Oo] | '') 59125341Spjd ;; 60125341Spjd *) 61136684Sthomas rm -f /dev/dumpdev 62125341Spjd /sbin/dumpon -v off 63125341Spjd ;; 64125341Spjd esac 65125341Spjd} 66125341Spjd 6798184Sgordonload_rc_config $name 6898184Sgordonrun_rc_command "$1" 69