dumpon revision 180563
178344Sobrien#!/bin/sh 278344Sobrien# 398184Sgordon# $FreeBSD: head/etc/rc.d/dumpon 180563 2008-07-16 19:22:48Z dougb $ 478344Sobrien# 578344Sobrien 678344Sobrien# PROVIDE: dumpon 7223852Srmacklem# BEFORE: disks savecore initrandom 8180564Sdougb# KEYWORD: nojail 978344Sobrien 1078344Sobrien. /etc/rc.subr 1178344Sobrien 1278344Sobrienname="dumpon" 13101851Sgordonstart_cmd="dumpon_start" 1499550Sgordonstop_cmd="dumpon_stop" 15168681Smtm 1678344Sobriendumpon_try() 1778344Sobrien{ 1878344Sobrien if /sbin/dumpon "${1}" ; then 1978344Sobrien # Make a symlink in devfs for savecore 2078344Sobrien ln -fs "${1}" /dev/dumpdev 2178344Sobrien return 0 22124627Smtm fi 23124627Smtm warn "unable to specify $1 as a dump device" 24124627Smtm return 1 25124627Smtm} 26124627Smtm 27124627Smtmdumpon_start() 28124627Smtm{ 29124627Smtm # Enable dumpdev so that savecore can see it. Enable it 30124628Smtm # early so a crash early in the boot process can be caught. 31124627Smtm # 32150294Srodrigc case ${dumpdev} in 3398184Sgordon [Nn][Oo] | '') 34124628Smtm ;; 35124627Smtm [Aa][Uu][Tt][Oo]) 36150294Srodrigc dev=$(/bin/kenv -q dumpdev) 37124627Smtm if [ -n "${dev}" ] ; then 38124628Smtm dumpon_try "${dev}" 39168410Spjd return $? 40221046Srmacklem fi 41193354Srmacklem while read dev mp type more ; do 42221046Srmacklem [ "${type}" = "swap" ] || continue 43221046Srmacklem [ -c "${dev}" ] || continue 44193354Srmacklem dumpon_try "${dev}" 2>/dev/null && return 0 45193354Srmacklem done </etc/fstab 46168685Spjd echo "No suitable dump device was found." 1>&2 47168410Spjd return 1 48168410Spjd ;; 49168410Spjd *) 5078344Sobrien dumpon_try "${dumpdev}" 5198184Sgordon ;; 5278344Sobrien esac 5378344Sobrien} 5478344Sobrien 5578344Sobriendumpon_stop() 5678344Sobrien{ 57 case ${dumpdev} in 58 [Nn][Oo] | '') 59 ;; 60 *) 61 rm -f /dev/dumpdev 62 /sbin/dumpon -v off 63 ;; 64 esac 65} 66 67load_rc_config $name 68run_rc_command "$1" 69