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