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