dumpon revision 147107
198184Sgordon#!/bin/sh 298184Sgordon# 398184Sgordon# $FreeBSD: head/etc/rc.d/dumpon 147107 2005-06-07 15:20:10Z des $ 498184Sgordon# 598184Sgordon 698184Sgordon# PROVIDE: dumpon 7144683Sobrien# REQUIRE: rcconf 8144683Sobrien# BEFORE: disks savecore initrandom 9136224Smtm# KEYWORD: nojail 1098184Sgordon 1198184Sgordon. /etc/rc.subr 1298184Sgordon 1398184Sgordonname="dumpon" 1498184Sgordonstart_cmd="dumpon_start" 15125341Spjdstop_cmd="dumpon_stop" 1698184Sgordon 17147107Sdesdumpon_try() 18147107Sdes{ 19147107Sdes if /sbin/dumpon -v "${1}" ; then 20147107Sdes # Make a symlink in devfs for savecore 21147107Sdes ln -fs "${1}" /dev/dumpdev 22147107Sdes return 0 23147107Sdes fi 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]) 36147107Sdes dev=$(/bin/kenv 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