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