10696600cSBjoern A. Zeeb#!/bin/sh 20696600cSBjoern A. Zeeb# 30696600cSBjoern A. Zeeb# 40696600cSBjoern A. Zeeb 50696600cSBjoern A. Zeeb# PROVIDE: dumpon 60696600cSBjoern A. Zeeb# BEFORE: disks 70696600cSBjoern A. Zeeb# KEYWORD: nojail 80696600cSBjoern A. Zeeb 90696600cSBjoern A. Zeeb. /etc/rc.subr 100696600cSBjoern A. Zeeb 110696600cSBjoern A. Zeebname="dumpon" 120696600cSBjoern A. Zeebdesc="Dump kernel corefiles from swap to disk" 130696600cSBjoern A. Zeebstart_cmd="dumpon_start" 140696600cSBjoern A. Zeebstop_cmd="dumpon_stop" 150696600cSBjoern A. Zeeb 160696600cSBjoern A. Zeebdumpon_try() 170696600cSBjoern A. Zeeb{ 180696600cSBjoern A. Zeeb local flags 190696600cSBjoern A. Zeeb 200696600cSBjoern A. Zeeb flags=${dumpon_flags} 210696600cSBjoern A. Zeeb if [ -n "${dumppubkey}" ]; then 220696600cSBjoern A. Zeeb warn "The dumppubkey variable is deprecated. Use dumpon_flags." 230696600cSBjoern A. Zeeb flags="${flags} -k ${dumppubkey}" 240696600cSBjoern A. Zeeb fi 250696600cSBjoern A. Zeeb /sbin/dumpon ${flags} "${1}" 260696600cSBjoern A. Zeeb if [ $? -eq 0 ]; then 270696600cSBjoern A. Zeeb # Make a symlink in devfs for savecore 280696600cSBjoern A. Zeeb ln -fs "${1}" /dev/dumpdev 290696600cSBjoern A. Zeeb return 0 300696600cSBjoern A. Zeeb fi 310696600cSBjoern A. Zeeb warn "unable to specify $1 as a dump device" 320696600cSBjoern A. Zeeb return 1 330696600cSBjoern A. Zeeb} 340696600cSBjoern A. Zeeb 3567e751f1SEd Mastedumpon_warn_unencrypted() 3667e751f1SEd Maste{ 3767e751f1SEd Maste if [ -n "${dumppubkey}" ]; then 3867e751f1SEd Maste return 3967e751f1SEd Maste fi 4067e751f1SEd Maste for flag in ${dumpon_flags}; do 4167e751f1SEd Maste if [ $flag = -k ]; then 4267e751f1SEd Maste return 4367e751f1SEd Maste fi 4467e751f1SEd Maste done 4567e751f1SEd Maste warn "Kernel dumps will be written to the swap partition without encryption." 4667e751f1SEd Maste} 4767e751f1SEd Maste 480696600cSBjoern A. Zeebdumpon_start() 490696600cSBjoern A. Zeeb{ 500696600cSBjoern A. Zeeb # Enable dumpdev so that savecore can see it. Enable it 510696600cSBjoern A. Zeeb # early so a crash early in the boot process can be caught. 520696600cSBjoern A. Zeeb # 530696600cSBjoern A. Zeeb case ${dumpdev} in 54ccc806a0SEugene Grosbein [Nn][Oo]) 550696600cSBjoern A. Zeeb ;; 56ccc806a0SEugene Grosbein [Aa][Uu][Tt][Oo] | '') 57f30f11f8SChuck Tuffli root_hold_wait 580696600cSBjoern A. Zeeb dev=$(/bin/kenv -q dumpdev) 590696600cSBjoern A. Zeeb if [ -n "${dev}" ] ; then 600696600cSBjoern A. Zeeb dumpon_try "${dev}" 610696600cSBjoern A. Zeeb return $? 620696600cSBjoern A. Zeeb fi 63ccc806a0SEugene Grosbein if [ -z ${dumpdev} ] ; then 64ccc806a0SEugene Grosbein return 65ccc806a0SEugene Grosbein fi 660696600cSBjoern A. Zeeb while read dev mp type more ; do 670696600cSBjoern A. Zeeb [ "${type}" = "swap" ] || continue 6867e751f1SEd Maste case ${dev} in 6967e751f1SEd Maste *.bde|*.eli) 7067e751f1SEd Maste dumpon_warn_unencrypted 7167e751f1SEd Maste dev=${dev%.*} 7267e751f1SEd Maste ;; 7367e751f1SEd Maste esac 740696600cSBjoern A. Zeeb [ -c "${dev}" ] || continue 750696600cSBjoern A. Zeeb dumpon_try "${dev}" 2>/dev/null && return 0 760696600cSBjoern A. Zeeb done </etc/fstab 770696600cSBjoern A. Zeeb echo "No suitable dump device was found." 1>&2 780696600cSBjoern A. Zeeb return 1 790696600cSBjoern A. Zeeb ;; 800696600cSBjoern A. Zeeb *) 81f30f11f8SChuck Tuffli root_hold_wait 820696600cSBjoern A. Zeeb dumpon_try "${dumpdev}" 830696600cSBjoern A. Zeeb ;; 840696600cSBjoern A. Zeeb esac 850696600cSBjoern A. Zeeb} 860696600cSBjoern A. Zeeb 870696600cSBjoern A. Zeebdumpon_stop() 880696600cSBjoern A. Zeeb{ 890696600cSBjoern A. Zeeb case ${dumpdev} in 90ccc806a0SEugene Grosbein [Nn][Oo]) 910696600cSBjoern A. Zeeb ;; 920696600cSBjoern A. Zeeb *) 930696600cSBjoern A. Zeeb rm -f /dev/dumpdev 940696600cSBjoern A. Zeeb /sbin/dumpon -v off 950696600cSBjoern A. Zeeb ;; 960696600cSBjoern A. Zeeb esac 970696600cSBjoern A. Zeeb} 980696600cSBjoern A. Zeeb 990696600cSBjoern A. Zeebload_rc_config $name 100*f99f0ee1SAlexander Leidinger 101*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj: config setting 102*f99f0ee1SAlexander Leidingerdumpon_svcj="NO" 103*f99f0ee1SAlexander Leidinger 1040696600cSBjoern A. Zeebrun_rc_command "$1" 105