1#!/sbin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License, Version 1.0 only 7# (the "License"). You may not use this file except in compliance 8# with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or http://www.opensolaris.org/os/licensing. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23# 24# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27#ident "%Z%%M% %I% %E% SMI" 28 29. /lib/svc/share/smf_include.sh 30 31# 32# mksavedir 33# Make sure that $DUMPADM_SAVDIR is set and exists. 34# 35mksavedir () 36{ 37 [ -z "$DUMPADM_SAVDIR" ] && DUMPADM_SAVDIR=/var/crash/`uname -n` 38 [ -d "$DUMPADM_SAVDIR" ] || /usr/bin/mkdir -m 0700 -p $DUMPADM_SAVDIR 39} 40 41# 42# We haven't run savecore on a dump device yet 43# 44savedev=none 45 46# 47# If we previously crashed early in boot before dumpadm was used to configure 48# an alternate dump device, then the dump is in the primary swap partition, 49# which was configured as the dump device by the first swapadd early in boot. 50# Thus before we run dumpadm to configure the dump device, we first run 51# savecore to check the swap partition for a dump. 52# 53if [ -x /usr/bin/savecore ]; then 54 [ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf 55 56 if [ "x$DUMPADM_ENABLE" != xno ] && mksavedir; then 57 /usr/bin/savecore $DUMPADM_SAVDIR 58 shift $# 59 set -- `/usr/sbin/dumpadm 2>/dev/null | /usr/bin/grep 'device:'` 60 savedev=${3:-none} 61 fi 62else 63 echo "WARNING: /usr/bin/savecore is missing or not executable" >& 2 64fi 65 66# 67# Now run dumpadm to configure the dump device based on the settings 68# previously saved by dumpadm. See dumpadm(1m) for instructions on 69# how to modify the dump settings. 70# 71if [ -x /usr/sbin/dumpadm ]; then 72 /usr/sbin/dumpadm -u || $SMF_EXIT_ERR_CONFIG 73else 74 echo "WARNING: /usr/sbin/dumpadm is missing or not executable" >& 2 75 exit $SMF_EXIT_ERR_CONFIG 76fi 77 78if [ -r /etc/dumpadm.conf ]; then 79 . /etc/dumpadm.conf 80else 81 echo "WARNING: /etc/dumpadm.conf is missing or unreadable" >& 2 82 exit $SMF_EXIT_ERR_CONFIG 83fi 84 85# 86# Now that dumpadm has reconfigured /dev/dump, we need to run savecore again 87# because the dump device may have changed. If the earlier savecore had 88# saved the dump, savecore will just exit immediately. 89# 90if [ "x$DUMPADM_ENABLE" != xno ]; then 91 if /usr/sbin/swap -l | grep "^${DUMPADM_DEVICE} " >/dev/null 2>&1; then 92 # 93 # If the dump device is part of swap, we only need to run 94 # savecore a second time if the device is different from the 95 # swap device on which we initially ran savecore. 96 # 97 [ "x$savedev" != "x$DUMPADM_DEVICE" ] && \ 98 mksavedir && /usr/bin/savecore $DUMPADM_SAVDIR & 99 else 100 # 101 # The dump device couldn't have been dedicated before we 102 # ran dumpadm, so we must execute savecore again. 103 # 104 mksavedir && /usr/bin/savecore $DUMPADM_SAVDIR & 105 fi 106fi 107 108exit $SMF_EXIT_OK 109