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/cmd-inet/usr.lib/inetd/inetd-upgrade.sh
+++ new/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd-upgrade.sh
1 -#! /usr/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.
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 2010 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 26
27 27 # Start by cleaning out obsolete instances. For each one that
28 28 # exists in the repository, remove it.
29 29 inetd_obsolete_instances="
30 30 network/nfs/rquota:ticlts
31 31 network/nfs/rquota:udp
32 32 network/rexec:tcp
33 33 network/rexec:tcp6
34 34 network/rpc/gss:ticotsord
35 35 network/rpc/mdcomm:tcp
36 36 network/rpc/mdcomm:tcp6
37 37 network/rpc/meta:tcp
38 38 network/rpc/meta:tcp6
39 39 network/rpc/metamed:tcp
40 40 network/rpc/metamed:tcp6
41 41 network/rpc/metamh:tcp
42 42 network/rpc/metamh:tcp6
43 43 network/rpc/rex:tcp
44 44 network/rpc/rstat:ticlts
45 45 network/rpc/rstat:udp
46 46 network/rpc/rstat:udp6
47 47 network/rpc/rusers:udp
48 48 network/rpc/rusers:udp6
49 49 network/rpc/rusers:ticlts
50 50 network/rpc/rusers:tcp
51 51 network/rpc/rusers:tcp6
52 52 network/rpc/rusers:ticotsord
53 53 network/rpc/rusers:ticots
54 54 network/rpc/spray:ticlts
55 55 network/rpc/spray:udp
56 56 network/rpc/spray:udp6
57 57 network/rpc/wall:ticlts
58 58 network/rpc/wall:udp
59 59 network/rpc/wall:udp6
60 60 network/security/krb5_prop:tcp
61 61 network/security/ktkt_warn:ticotsord
62 62 network/shell:tcp
63 63 network/shell:tcp6only
64 64 platform/sun4u/dcs:tcp
65 65 platform/sun4u/dcs:tcp6
66 66 "
67 67
68 68 for i in $inetd_obsolete_instances; do
69 69 enable=`svcprop -p general/enabled $i`
70 70 if [ $? = 0 ]; then
71 71 # Instance found, so disable and delete
72 72 svcadm disable $i
73 73 svccfg delete $i
74 74 if [ "$enable" = "true" ]; then
75 75 # Instance was enabled, so enable the replacement.
76 76 # We must do this here because the profile which
77 77 # normally enables these is only applied on first
78 78 # install of smf.
79 79 s=`echo $i | cut -f1 -d:`
80 80 svcadm enable $s:default
81 81 fi
82 82 fi
83 83 done
84 84
85 85
86 86 # The Following blocks of code cause the inetconv generated services to be
87 87 # re-generated, so that the latest inetconv modifications are applied to all
88 88 # services generated by it.
89 89
90 90 inetdconf_entries_file=/tmp/iconf_entries.$$
91 91
92 92 # Create sed script that prints out inetd.conf src line from inetconv generated
93 93 # manifest.
94 94 cat <<EOF > /tmp/inetd-upgrade.$$.sed
95 95 /propval name='source_line'/{
96 96 n
97 97 s/'//g
98 98 p
99 99 }
100 100 /from the inetd.conf(4) format line/{
101 101 n
102 102 p
103 103 }
104 104 EOF
105 105
106 106 # get list of inetconv generated manifests
107 107 inetconv_manifests=`/usr/bin/find /lib/svc/manifest -type f -name \*.xml | \
108 108 /usr/bin/xargs /usr/bin/grep -l "Generated by inetconv"`
109 109
110 110 # For each inetconv generated manifest determine the instances that should
111 111 # be disabled when the new manifests are imported, and generate a file with
112 112 # the inetd.conf entries from all the manifests for consumption by inetconv.
113 113
114 114 > $inetdconf_entries_file
115 115 inetconv_services=""
116 116 instances_to_disable=""
117 117
118 118 for manifest in $inetconv_manifests; do
119 119
120 120 manifest_instances=`/usr/sbin/svccfg inventory $manifest | \
121 121 egrep "svc:/.*:.*"`
122 122 manifest_service=`/usr/sbin/svccfg inventory $manifest | \
123 123 egrep -v "svc:/.*:.*"`
124 124
125 125 instance_disabled=""
126 126 default_enabled=""
127 127 enabled=""
128 128
129 129 for instance in $manifest_instances; do
130 130 # if the instance doesn't exist in the repository skip it
131 131 svcprop -q $instance
132 132 if [ $? -ne 0 ]; then
133 133 continue
134 134 fi
135 135
136 136 enabled=`svcprop -p general/enabled $instance`
137 137
138 138 default_instance=`echo $instance | grep ":default"`
139 139 if [ "$default_instance" != "" ]; then
140 140 default_enabled=$enabled
141 141 else
142 142 # add all non-default instances to disable list
143 143 instances_to_disable="$instances_to_disable \
144 144 $instance"
145 145 if [ "$enabled" != "true" ]; then
146 146 instance_disabled="true"
147 147 fi
148 148 fi
149 149 done
150 150
151 151 # if none of the manifest's instances existed, skip this manifest
152 152 if [ "$enabled" = "" ]; then
153 153 continue
154 154 fi
155 155
156 156 # If the default instance existed and was disabled, or if didn't
157 157 # exist and one of the other instances was disabled, add the default
158 158 # to the list of instances to disable.
159 159 if [ "$default_enabled" = "false" -o "$default_enabled" = "" -a \
160 160 "$instance_disabled" = "true" ]; then
161 161 instances_to_disable="$instances_to_disable \
162 162 $manifest_service:default"
163 163 fi
164 164
165 165 # add the manifest's inetd.conf src line to file for inetconv
166 166 sed -n -f /tmp/inetd-upgrade.$$.sed $manifest >> \
167 167 $inetdconf_entries_file
168 168 done
169 169
170 170 rm /tmp/inetd-upgrade.$$.sed
171 171
172 172 # Check whether we've ever run inetconv before by looking for the
173 173 # configuration file hash. If we haven't run it before, then we need
174 174 # to enable services based on inetd.conf. If we have, then the
175 175 # repository is authoritative. `unimported' will be 0 if the hash exists.
176 176 svcprop -qp hash svc:/network/inetd:default
177 177 unimported=$?
178 178
179 179 # Run inetconv on generated file, overwriting previous manifests and values
180 180 # in repository.
181 181 /usr/sbin/inetconv -f -i $inetdconf_entries_file
182 182
183 183 # disable the necessary instances
184 184 for inst in $instances_to_disable; do
185 185 svcadm disable $inst
186 186 done
187 187
188 188
189 189 # If there is a saved config file from upgrade, use it to enable services,
190 190 # but only if we're coming from a release that didn't have SMF.
191 191 saved_config=/etc/inet/inetd.conf.preupgrade
192 192 if [ $unimported -ne 0 -a -f $saved_config ]; then
193 193 /usr/sbin/inetconv -e -i $saved_config
194 194 fi
195 195
196 196 # Now convert the remaining entries in inetd.conf to service manifests
197 197 /usr/sbin/inetconv
198 198
199 199 # Now disable myself as the upgrade is done
200 200 svcadm disable network/inetd-upgrade
201 201
202 202 exit 0
↓ open down ↓ |
191 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX