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