dumpon revision 298514
198184Sgordon#!/bin/sh 298184Sgordon# 398184Sgordon# $FreeBSD: head/etc/rc.d/dumpon 298514 2016-04-23 16:10:54Z lme $ 498184Sgordon# 598184Sgordon 698184Sgordon# PROVIDE: dumpon 7208307Sdougb# REQUIRE: zvol 8208307Sdougb# BEFORE: disks 9136224Smtm# KEYWORD: nojail 1098184Sgordon 1198184Sgordon. /etc/rc.subr 1298184Sgordon 1398184Sgordonname="dumpon" 14298514Slmedesc="Dump kernel corefiles from swap to disk" 1598184Sgordonstart_cmd="dumpon_start" 16125341Spjdstop_cmd="dumpon_stop" 1798184Sgordon 18147107Sdesdumpon_try() 19147107Sdes{ 20179943Smtm if /sbin/dumpon "${1}" ; then 21147107Sdes # Make a symlink in devfs for savecore 22147107Sdes ln -fs "${1}" /dev/dumpdev 23147107Sdes return 0 24147107Sdes fi 25179943Smtm warn "unable to specify $1 as a dump device" 26147107Sdes return 1 27147107Sdes} 28147107Sdes 2998184Sgordondumpon_start() 3098184Sgordon{ 3198184Sgordon # Enable dumpdev so that savecore can see it. Enable it 3298184Sgordon # early so a crash early in the boot process can be caught. 3398184Sgordon # 3498184Sgordon case ${dumpdev} in 3598184Sgordon [Nn][Oo] | '') 3698184Sgordon ;; 37135525Sdes [Aa][Uu][Tt][Oo]) 38150103Srwatson dev=$(/bin/kenv -q dumpdev) 39147107Sdes if [ -n "${dev}" ] ; then 40147107Sdes dumpon_try "${dev}" 41147107Sdes return $? 42147107Sdes fi 43135525Sdes while read dev mp type more ; do 44135525Sdes [ "${type}" = "swap" ] || continue 45135525Sdes [ -c "${dev}" ] || continue 46147107Sdes dumpon_try "${dev}" 2>/dev/null && return 0 47135525Sdes done </etc/fstab 48135525Sdes echo "No suitable dump device was found." 1>&2 49135525Sdes return 1 50135525Sdes ;; 5198184Sgordon *) 52147107Sdes dumpon_try "${dumpdev}" 5398184Sgordon ;; 5498184Sgordon esac 5598184Sgordon} 5698184Sgordon 57125341Spjddumpon_stop() 58125341Spjd{ 59125341Spjd case ${dumpdev} in 60125341Spjd [Nn][Oo] | '') 61125341Spjd ;; 62125341Spjd *) 63136684Sthomas rm -f /dev/dumpdev 64125341Spjd /sbin/dumpon -v off 65125341Spjd ;; 66125341Spjd esac 67125341Spjd} 68125341Spjd 6998184Sgordonload_rc_config $name 7098184Sgordonrun_rc_command "$1" 71