198184Sgordon#!/bin/sh 298184Sgordon# 398184Sgordon# $FreeBSD: releng/11.0/etc/rc.d/dumpon 299839 2016-05-15 04:38:50Z ngie $ 498184Sgordon# 598184Sgordon 698184Sgordon# PROVIDE: dumpon 7208307Sdougb# BEFORE: disks 8136224Smtm# KEYWORD: nojail 998184Sgordon 1098184Sgordon. /etc/rc.subr 1198184Sgordon 1298184Sgordonname="dumpon" 13298514Slmedesc="Dump kernel corefiles from swap to disk" 1498184Sgordonstart_cmd="dumpon_start" 15125341Spjdstop_cmd="dumpon_stop" 1698184Sgordon 17147107Sdesdumpon_try() 18147107Sdes{ 19179943Smtm if /sbin/dumpon "${1}" ; then 20147107Sdes # Make a symlink in devfs for savecore 21147107Sdes ln -fs "${1}" /dev/dumpdev 22147107Sdes return 0 23147107Sdes fi 24179943Smtm warn "unable to specify $1 as a dump device" 25147107Sdes return 1 26147107Sdes} 27147107Sdes 2898184Sgordondumpon_start() 2998184Sgordon{ 3098184Sgordon # Enable dumpdev so that savecore can see it. Enable it 3198184Sgordon # early so a crash early in the boot process can be caught. 3298184Sgordon # 3398184Sgordon case ${dumpdev} in 3498184Sgordon [Nn][Oo] | '') 3598184Sgordon ;; 36135525Sdes [Aa][Uu][Tt][Oo]) 37150103Srwatson dev=$(/bin/kenv -q dumpdev) 38147107Sdes if [ -n "${dev}" ] ; then 39147107Sdes dumpon_try "${dev}" 40147107Sdes return $? 41147107Sdes fi 42135525Sdes while read dev mp type more ; do 43135525Sdes [ "${type}" = "swap" ] || continue 44135525Sdes [ -c "${dev}" ] || continue 45147107Sdes dumpon_try "${dev}" 2>/dev/null && return 0 46135525Sdes done </etc/fstab 47135525Sdes echo "No suitable dump device was found." 1>&2 48135525Sdes return 1 49135525Sdes ;; 5098184Sgordon *) 51147107Sdes dumpon_try "${dumpdev}" 5298184Sgordon ;; 5398184Sgordon esac 5498184Sgordon} 5598184Sgordon 56125341Spjddumpon_stop() 57125341Spjd{ 58125341Spjd case ${dumpdev} in 59125341Spjd [Nn][Oo] | '') 60125341Spjd ;; 61125341Spjd *) 62136684Sthomas rm -f /dev/dumpdev 63125341Spjd /sbin/dumpon -v off 64125341Spjd ;; 65125341Spjd esac 66125341Spjd} 67125341Spjd 6898184Sgordonload_rc_config $name 6998184Sgordonrun_rc_command "$1" 70