Print this page
4360 Fix SMF methods and other scripts which rely on the system shell to use /sbin/sh
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/lvm/util/svc-metasync
+++ new/usr/src/cmd/lvm/util/svc-metasync
1 -#!/bin/sh
1 +#!/sbin/sh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 #
23 23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 -# ident "%Z%%M% %I% %E% SMI"
27 26 #
28 27 # Start mirror resync threads.
29 28
30 29 DEVFSADM=/usr/sbin/devfsadm
31 30 METADEVADM=/usr/sbin/metadevadm
32 31 METASYNC=/usr/sbin/metasync
33 32 METADEV=/dev/md/admin
34 33 METASET=/usr/sbin/metaset
35 34 TMPFILE=/var/run/metaset.$$
36 35
37 36 . /lib/svc/share/smf_include.sh
38 37
39 38 print_verbose()
40 39 {
41 40 echo "Unable to resolve unnamed devices for volume management."
42 41 echo "Please refer to the Solaris Volume Manager documentation,"
43 42 echo "Troubleshooting section, at http://docs.sun.com or from"
44 43 echo "your local copy."
45 44 }
46 45
47 46 resolve_auto_take_sets()
48 47 {
49 48 if [ -x $METASET ]; then
50 49 # Fixing up of the ctd names for devices in auto take
51 50 # sets relies heavily on the output of the metaset
52 51 # command. Any change to the output of the metaset command
53 52 # should modify this script as well in order ensure nothing
54 53 # breaks
55 54 #
56 55 # The following command saves all of the auto-take set names
57 56 # into the TMPFILE
58 57 name_str=`gettext "Set name"`
59 58 mn_str=`gettext "Multi-owner"`
60 59 $METASET | /bin/nawk -F ' |\t|,' -v snm="$name_str" \
61 60 -v mstr="$mn_str" '$0 ~ snm { \
62 61 if (index($0, mstr) == 0) print $4 \
63 62 }' > $TMPFILE 2>&1
64 63
65 64 if [ -s "$TMPFILE" ]; then
66 65 localised_string=`gettext "Yes (auto)"`
67 66 for i in `cat $TMPFILE`; do
68 67 $METASET -s $i | grep "$localised_string" \
69 68 > /dev/null 2>&1
70 69 if [ $? -eq 0 ]; then
71 70 $METADEVADM -l -r -s $i
72 71 error=$?
73 72 case $error in
74 73 0|2) ;;
75 74 3) print_verbose
76 75 ;;
77 76 *) echo "$METADEVADM \
78 77 -r failure $error."
79 78 ;;
80 79 esac
81 80 fi
82 81 done
83 82 fi
84 83 if [ -f "$TMPFILE" ]; then
85 84 /usr/bin/rm -f $TMPFILE
86 85 fi
87 86 fi
88 87 }
89 88
90 89 if [ ! -s /kernel/drv/md.conf ]; then
91 90 echo "/kernel/drv/md.conf is missing."
92 91 exit 0
93 92 fi
94 93
95 94 if grep '^mddb_bootlist' /kernel/drv/md.conf >/dev/null 2>&1; then :; else
96 95 echo "No 'mddb_bootlist' entry in /kernel/drv/md.conf."
97 96 exit 0
98 97 fi
99 98
100 99 if [ ! -x $METADEVADM ]; then
101 100 echo "$METADEVADM is missing or not executable."
102 101 exit $SMF_EXIT_ERR_CONFIG
103 102 fi
104 103
105 104 if [ ! -x $METASYNC ]; then
106 105 echo "$METASYNC is missing or not executable."
107 106 exit $SMF_EXIT_ERR_CONFIG
108 107 fi
109 108
110 109 if [ ! -c $METADEV ]; then
111 110 echo "$METADEV is missing or not a character device."
112 111 exit 0
113 112 fi
114 113
115 114 $METADEVADM -l -r
116 115 error=$?
117 116 case $error in
118 117 0|2) ;;
119 118
120 119 3) echo "Executing devfsadm"
121 120 $DEVFSADM
122 121 devfsadmerror=$?
123 122 if [ $devfsadmerror = 0 ]; then
124 123 echo "Executing metadevadm -r"
125 124 $METADEVADM -l -r
126 125 error=$?
127 126 fi
128 127 if [ $devfsadmerror != 0 -o $error = 3 ]; then
129 128 print_verbose
130 129 elif [ $error != 0 -a $error != 2 ]; then
131 130 echo "$METADEVADM -r failure $error."
132 131 fi
133 132 ;;
134 133
135 134 *) echo "$METADEVADM -r failure $error."
136 135 exit 1
137 136 ;;
138 137 esac
139 138
140 139 resolve_auto_take_sets
141 140
142 141 $METASYNC -r
143 142 error=$?
144 143 case $error in
145 144 0) ;;
146 145
147 146 *) echo "Unknown $METASYNC -r failure $error."
148 147 exit 1
149 148 ;;
150 149 esac
151 150
↓ open down ↓ |
115 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX