10696600cSBjoern A. Zeeb#!/bin/sh 20696600cSBjoern A. Zeeb# 30696600cSBjoern A. Zeeb# 40696600cSBjoern A. Zeeb 50696600cSBjoern A. Zeeb# PROVIDE: savecore 60696600cSBjoern A. Zeeb# REQUIRE: dumpon ddb syslogd 70696600cSBjoern A. Zeeb# KEYWORD: nojail 80696600cSBjoern A. Zeeb 90696600cSBjoern A. Zeeb. /etc/rc.subr 100696600cSBjoern A. Zeeb 110696600cSBjoern A. Zeebname="savecore" 120696600cSBjoern A. Zeebrcvar="savecore_enable" 130696600cSBjoern A. Zeebdesc="Save a core dump of the operating system" 140696600cSBjoern A. Zeebstart_cmd="savecore_start" 150696600cSBjoern A. Zeebstart_precmd="savecore_prestart" 160696600cSBjoern A. Zeebstop_cmd=":" 170696600cSBjoern A. Zeeb 180696600cSBjoern A. Zeebsavecore_prestart() 190696600cSBjoern A. Zeeb{ 200696600cSBjoern A. Zeeb # Quit if we have no dump device 210696600cSBjoern A. Zeeb case ${dumpdev} in 22ccc806a0SEugene Grosbein [Nn][Oo]) 230696600cSBjoern A. Zeeb debug 'No dump device. Quitting.' 240696600cSBjoern A. Zeeb return 1 250696600cSBjoern A. Zeeb ;; 26ccc806a0SEugene Grosbein [Aa][Uu][Tt][Oo] | '') 270696600cSBjoern A. Zeeb if [ ! -L /dev/dumpdev ]; then 280696600cSBjoern A. Zeeb return 1 290696600cSBjoern A. Zeeb fi 300696600cSBjoern A. Zeeb dumpdev=`/bin/realpath /dev/dumpdev` 310696600cSBjoern A. Zeeb ;; 320696600cSBjoern A. Zeeb esac 330696600cSBjoern A. Zeeb 340696600cSBjoern A. Zeeb # If there is no crash directory set it now 350696600cSBjoern A. Zeeb case ${dumpdir} in 360696600cSBjoern A. Zeeb '') 370696600cSBjoern A. Zeeb dumpdir='/var/crash' 380696600cSBjoern A. Zeeb ;; 390696600cSBjoern A. Zeeb [Nn][Oo]) 400696600cSBjoern A. Zeeb dumpdir='NO' 410696600cSBjoern A. Zeeb ;; 420696600cSBjoern A. Zeeb esac 430696600cSBjoern A. Zeeb 440696600cSBjoern A. Zeeb if [ ! -c "${dumpdev}" ]; then 450696600cSBjoern A. Zeeb warn "Dump device does not exist. Savecore not run." 460696600cSBjoern A. Zeeb return 1 470696600cSBjoern A. Zeeb fi 480696600cSBjoern A. Zeeb 490696600cSBjoern A. Zeeb if [ ! -d "${dumpdir}" ]; then 500696600cSBjoern A. Zeeb warn "Dump directory does not exist. Savecore not run." 510696600cSBjoern A. Zeeb return 1 520696600cSBjoern A. Zeeb fi 530696600cSBjoern A. Zeeb return 0 540696600cSBjoern A. Zeeb} 550696600cSBjoern A. Zeeb 560696600cSBjoern A. Zeebsavecore_start() 570696600cSBjoern A. Zeeb{ 580696600cSBjoern A. Zeeb local dev 590696600cSBjoern A. Zeeb 600696600cSBjoern A. Zeeb case "${dumpdev}" in 610696600cSBjoern A. Zeeb [Aa][Uu][Tt][Oo]) 620696600cSBjoern A. Zeeb dev= 630696600cSBjoern A. Zeeb ;; 640696600cSBjoern A. Zeeb *) 650696600cSBjoern A. Zeeb dev="${dumpdev}" 660696600cSBjoern A. Zeeb ;; 670696600cSBjoern A. Zeeb esac 680696600cSBjoern A. Zeeb 690696600cSBjoern A. Zeeb if savecore -C "${dev}" >/dev/null; then 700696600cSBjoern A. Zeeb savecore ${savecore_flags} ${dumpdir} ${dumpdev} 710696600cSBjoern A. Zeeb if checkyesno crashinfo_enable; then 720696600cSBjoern A. Zeeb ${crashinfo_program} -b -d ${dumpdir} 730696600cSBjoern A. Zeeb fi 740696600cSBjoern A. Zeeb sync 750696600cSBjoern A. Zeeb else 76325ebf37SJose Luis Duran startmsg 'No core dumps found.' 770696600cSBjoern A. Zeeb fi 780696600cSBjoern A. Zeeb} 790696600cSBjoern A. Zeeb 800696600cSBjoern A. Zeebload_rc_config $name 81*f99f0ee1SAlexander Leidinger 82*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj 83*f99f0ee1SAlexander Leidingersavecore_svcj="NO" 84*f99f0ee1SAlexander Leidinger 850696600cSBjoern A. Zeebrun_rc_command "$1" 86