xref: /titanic_41/usr/src/cmd/lvm/util/svc-metainit (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
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#pragma ident	"%Z%%M%	%I%	%E% SMI"
25#
26# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29#	Metadisk initialization.
30
31METAINIT=/sbin/metainit
32METADEV=/dev/md/admin
33
34. /lib/svc/share/smf_include.sh
35
36if [ ! -s /kernel/drv/md.conf ]; then
37	echo "/kernel/drv/md.conf is missing or empty."
38	exit 0
39fi
40
41if [ ! -c $METADEV ]; then
42	echo "$METADEV is missing or not a character device."
43	exit 0
44fi
45
46$METAINIT -r
47error=$?
48case "$error" in
49	0|1)	exit 0
50		;;
51
52	66)
53echo "Insufficient metadevice database replicas located."
54echo
55echo "Use metadb to delete databases which are broken."
56echo "Ignore any "Read-only file system" error messages."
57echo "Reboot the system when finished to reload the metadevice database."
58echo "After reboot, repair any broken database replicas which were deleted."
59
60echo "Insufficient metadevice database replicas located." >/dev/console
61echo >/dev/console
62echo "Use metadb to delete databases which are broken." >/dev/console
63echo "Ignore any "Read-only file system" error messages." >/dev/console
64echo "Reboot the system when finished to reload the metadevice database." \
65>/dev/console
66echo "After reboot, repair any broken database replicas which were deleted." \
67>/dev/console
68
69		exit $SMF_EXIT_ERR_CONFIG
70		;;
71
72	*)	echo "Unknown $METAINIT -r failure $error."
73		exit 1
74		;;
75esac
76