17c478bd9Sstevel@tonic-gate#!/sbin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*7950274eSeschrock# Common Development and Distribution License (the "License"). 7*7950274eSeschrock# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 227c478bd9Sstevel@tonic-gate# 23*7950274eSeschrock# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate# 317c478bd9Sstevel@tonic-gate# mksavedir 327c478bd9Sstevel@tonic-gate# Make sure that $DUMPADM_SAVDIR is set and exists. 337c478bd9Sstevel@tonic-gate# 347c478bd9Sstevel@tonic-gatemksavedir () 357c478bd9Sstevel@tonic-gate{ 367c478bd9Sstevel@tonic-gate [ -z "$DUMPADM_SAVDIR" ] && DUMPADM_SAVDIR=/var/crash/`uname -n` 377c478bd9Sstevel@tonic-gate [ -d "$DUMPADM_SAVDIR" ] || /usr/bin/mkdir -m 0700 -p $DUMPADM_SAVDIR 387c478bd9Sstevel@tonic-gate} 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate# 417c478bd9Sstevel@tonic-gate# We haven't run savecore on a dump device yet 427c478bd9Sstevel@tonic-gate# 437c478bd9Sstevel@tonic-gatesavedev=none 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate# 467c478bd9Sstevel@tonic-gate# If we previously crashed early in boot before dumpadm was used to configure 477c478bd9Sstevel@tonic-gate# an alternate dump device, then the dump is in the primary swap partition, 487c478bd9Sstevel@tonic-gate# which was configured as the dump device by the first swapadd early in boot. 497c478bd9Sstevel@tonic-gate# Thus before we run dumpadm to configure the dump device, we first run 507c478bd9Sstevel@tonic-gate# savecore to check the swap partition for a dump. 517c478bd9Sstevel@tonic-gate# 527c478bd9Sstevel@tonic-gateif [ -x /usr/bin/savecore ]; then 537c478bd9Sstevel@tonic-gate [ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate if [ "x$DUMPADM_ENABLE" != xno ] && mksavedir; then 567c478bd9Sstevel@tonic-gate /usr/bin/savecore $DUMPADM_SAVDIR 577c478bd9Sstevel@tonic-gate shift $# 587c478bd9Sstevel@tonic-gate set -- `/usr/sbin/dumpadm 2>/dev/null | /usr/bin/grep 'device:'` 597c478bd9Sstevel@tonic-gate savedev=${3:-none} 607c478bd9Sstevel@tonic-gate fi 617c478bd9Sstevel@tonic-gateelse 627c478bd9Sstevel@tonic-gate echo "WARNING: /usr/bin/savecore is missing or not executable" >& 2 637c478bd9Sstevel@tonic-gatefi 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate# 667c478bd9Sstevel@tonic-gate# Now run dumpadm to configure the dump device based on the settings 677c478bd9Sstevel@tonic-gate# previously saved by dumpadm. See dumpadm(1m) for instructions on 687c478bd9Sstevel@tonic-gate# how to modify the dump settings. 697c478bd9Sstevel@tonic-gate# 707c478bd9Sstevel@tonic-gateif [ -x /usr/sbin/dumpadm ]; then 717c478bd9Sstevel@tonic-gate /usr/sbin/dumpadm -u || $SMF_EXIT_ERR_CONFIG 727c478bd9Sstevel@tonic-gateelse 737c478bd9Sstevel@tonic-gate echo "WARNING: /usr/sbin/dumpadm is missing or not executable" >& 2 747c478bd9Sstevel@tonic-gate exit $SMF_EXIT_ERR_CONFIG 757c478bd9Sstevel@tonic-gatefi 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gateif [ -r /etc/dumpadm.conf ]; then 787c478bd9Sstevel@tonic-gate . /etc/dumpadm.conf 797c478bd9Sstevel@tonic-gateelse 807c478bd9Sstevel@tonic-gate echo "WARNING: /etc/dumpadm.conf is missing or unreadable" >& 2 817c478bd9Sstevel@tonic-gate exit $SMF_EXIT_ERR_CONFIG 827c478bd9Sstevel@tonic-gatefi 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate# 857c478bd9Sstevel@tonic-gate# Now that dumpadm has reconfigured /dev/dump, we need to run savecore again 867c478bd9Sstevel@tonic-gate# because the dump device may have changed. If the earlier savecore had 877c478bd9Sstevel@tonic-gate# saved the dump, savecore will just exit immediately. 887c478bd9Sstevel@tonic-gate# 897c478bd9Sstevel@tonic-gateif [ "x$DUMPADM_ENABLE" != xno ]; then 90*7950274eSeschrock if /usr/sbin/swap -l 2>/dev/null | grep "^${DUMPADM_DEVICE} " \ 91*7950274eSeschrock >/dev/null 2>&1; then 927c478bd9Sstevel@tonic-gate # 937c478bd9Sstevel@tonic-gate # If the dump device is part of swap, we only need to run 947c478bd9Sstevel@tonic-gate # savecore a second time if the device is different from the 957c478bd9Sstevel@tonic-gate # swap device on which we initially ran savecore. 967c478bd9Sstevel@tonic-gate # 977c478bd9Sstevel@tonic-gate [ "x$savedev" != "x$DUMPADM_DEVICE" ] && \ 987c478bd9Sstevel@tonic-gate mksavedir && /usr/bin/savecore $DUMPADM_SAVDIR & 997c478bd9Sstevel@tonic-gate else 1007c478bd9Sstevel@tonic-gate # 1017c478bd9Sstevel@tonic-gate # The dump device couldn't have been dedicated before we 1027c478bd9Sstevel@tonic-gate # ran dumpadm, so we must execute savecore again. 1037c478bd9Sstevel@tonic-gate # 1047c478bd9Sstevel@tonic-gate mksavedir && /usr/bin/savecore $DUMPADM_SAVDIR & 1057c478bd9Sstevel@tonic-gate fi 1067c478bd9Sstevel@tonic-gatefi 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK 109