1#!/bin/sh 2# 3# $NetBSD: savecore,v 1.5 2002/03/22 04:34:00 thorpej Exp $ 4# $FreeBSD: src/etc/rc.d/savecore,v 1.3 2002/09/06 16:18:05 gordon Exp $ 5# 6 7# PROVIDE: savecore 8# REQUIRE: dumpon syslogd 9# BEFORE: SERVERS 10 11. /etc/rc.subr 12 13name="savecore" 14start_cmd="savecore_start" 15start_precmd="savecore_prestart" 16stop_cmd=":" 17 18savecore_prestart() 19{ 20 # ${DUMPDIR} should be a directory or a symbolic link 21 # to the crash directory if core dumps are to be saved. 22 # 23 DUMPDIR="${dumpdir:-/var/crash}" 24 25 # Quit if we have no dump device 26 case ${dumpdev} in 27 [Nn][Oo] | '') 28 debug 'No dump device. Quitting.' 29 dumpdev= 30 return 0 31 ;; 32 esac 33 34 # If there is no crash directory set it now 35 case ${dumpdir} in 36 '') 37 dumpdir='/var/crash' 38 ;; 39 [Nn][Oo]) 40 dumpdir='NO' 41 ;; 42 esac 43 44 if [ ! -c "${dumpdev}" -o ! -d "${dumpdir}" ]; then 45 warn "Wrong dump device or directory. Savecore not run." 46 dumpdev= 47 return 0 48 fi 49 50 return 0 51} 52 53savecore_start() 54{ 55 if [ "${dumpdev}" = "" ]; then 56 return 0 57 fi 58 59 if savecore -C "${DUMPDIR}" "${dumpdev}" > /dev/null; then 60 savecore ${savecore_flags} ${DUMPDIR} ${dumpdev} 61 if checkyesno crashinfo_enable; then 62 ${crashinfo_program} -d ${DUMPDIR} 63 fi 64 else 65 echo 'No core dumps found.' 66 fi 67 return ${RC_CONFIGURED} 68} 69 70load_rc_config $name 71run_rc_command "$1" 72