10Sstevel@tonic-gate#! /usr/bin/sh 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*4352Scarlsonj# Common Development and Distribution License (the "License"). 7*4352Scarlsonj# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate# 230Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 240Sstevel@tonic-gate# 25*4352Scarlsonj# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 260Sstevel@tonic-gate# Use is subject to license terms. 270Sstevel@tonic-gate# 280Sstevel@tonic-gate 290Sstevel@tonic-gate# Start by cleaning out obsolete instances. For each one that 300Sstevel@tonic-gate# exists in the repository, remove it. 310Sstevel@tonic-gateinetd_obsolete_instances=" 320Sstevel@tonic-gate network/nfs/rquota:ticlts 330Sstevel@tonic-gate network/nfs/rquota:udp 340Sstevel@tonic-gate network/rexec:tcp 350Sstevel@tonic-gate network/rexec:tcp6 360Sstevel@tonic-gate network/rpc/gss:ticotsord 370Sstevel@tonic-gate network/rpc/mdcomm:tcp 380Sstevel@tonic-gate network/rpc/mdcomm:tcp6 390Sstevel@tonic-gate network/rpc/meta:tcp 400Sstevel@tonic-gate network/rpc/meta:tcp6 410Sstevel@tonic-gate network/rpc/metamed:tcp 420Sstevel@tonic-gate network/rpc/metamed:tcp6 430Sstevel@tonic-gate network/rpc/metamh:tcp 440Sstevel@tonic-gate network/rpc/metamh:tcp6 450Sstevel@tonic-gate network/rpc/rex:tcp 460Sstevel@tonic-gate network/rpc/rstat:ticlts 470Sstevel@tonic-gate network/rpc/rstat:udp 480Sstevel@tonic-gate network/rpc/rstat:udp6 490Sstevel@tonic-gate network/rpc/rusers:udp 500Sstevel@tonic-gate network/rpc/rusers:udp6 510Sstevel@tonic-gate network/rpc/rusers:ticlts 520Sstevel@tonic-gate network/rpc/rusers:tcp 530Sstevel@tonic-gate network/rpc/rusers:tcp6 540Sstevel@tonic-gate network/rpc/rusers:ticotsord 550Sstevel@tonic-gate network/rpc/rusers:ticots 560Sstevel@tonic-gate network/rpc/spray:ticlts 570Sstevel@tonic-gate network/rpc/spray:udp 580Sstevel@tonic-gate network/rpc/spray:udp6 590Sstevel@tonic-gate network/rpc/wall:ticlts 600Sstevel@tonic-gate network/rpc/wall:udp 610Sstevel@tonic-gate network/rpc/wall:udp6 620Sstevel@tonic-gate network/security/krb5_prop:tcp 630Sstevel@tonic-gate network/security/ktkt_warn:ticotsord 640Sstevel@tonic-gate network/shell:tcp 650Sstevel@tonic-gate network/shell:tcp6only 660Sstevel@tonic-gate platform/sun4u/dcs:tcp 670Sstevel@tonic-gate platform/sun4u/dcs:tcp6 680Sstevel@tonic-gate" 690Sstevel@tonic-gate 700Sstevel@tonic-gatefor i in $inetd_obsolete_instances; do 710Sstevel@tonic-gate enable=`svcprop -p general/enabled $i` 720Sstevel@tonic-gate if [ $? = 0 ]; then 730Sstevel@tonic-gate # Instance found, so disable and delete 740Sstevel@tonic-gate svcadm disable $i 750Sstevel@tonic-gate svccfg delete $i 760Sstevel@tonic-gate if [ "$enable" = "true" ]; then 770Sstevel@tonic-gate # Instance was enabled, so enable the replacement. 780Sstevel@tonic-gate # We must do this here because the profile which 790Sstevel@tonic-gate # normally enables these is only applied on first 800Sstevel@tonic-gate # install of smf. 810Sstevel@tonic-gate s=`echo $i | cut -f1 -d:` 820Sstevel@tonic-gate svcadm enable $s:default 830Sstevel@tonic-gate fi 840Sstevel@tonic-gate fi 850Sstevel@tonic-gatedone 860Sstevel@tonic-gate 870Sstevel@tonic-gate 880Sstevel@tonic-gate# The Following blocks of code cause the inetconv generated services to be 890Sstevel@tonic-gate# re-generated, so that the latest inetconv modifications are applied to all 900Sstevel@tonic-gate# services generated by it. 910Sstevel@tonic-gate 920Sstevel@tonic-gateinetdconf_entries_file=/tmp/iconf_entries.$$ 930Sstevel@tonic-gate 940Sstevel@tonic-gate# Create sed script that prints out inetd.conf src line from inetconv generated 950Sstevel@tonic-gate# manifest. 960Sstevel@tonic-gatecat <<EOF > /tmp/inetd-upgrade.$$.sed 970Sstevel@tonic-gate/propval name='source_line'/{ 980Sstevel@tonic-gaten 990Sstevel@tonic-gates/'//g 1000Sstevel@tonic-gatep 1010Sstevel@tonic-gate} 1020Sstevel@tonic-gate/from the inetd.conf(4) format line/{ 1030Sstevel@tonic-gaten 1040Sstevel@tonic-gatep 1050Sstevel@tonic-gate} 1060Sstevel@tonic-gateEOF 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate# get list of inetconv generated manifests 1090Sstevel@tonic-gateinetconv_manifests=`/usr/bin/find /var/svc/manifest -type f -name \*.xml | \ 1100Sstevel@tonic-gate /usr/bin/xargs /usr/bin/grep -l "Generated by inetconv"` 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate# For each inetconv generated manifest determine the instances that should 1130Sstevel@tonic-gate# be disabled when the new manifests are imported, and generate a file with 1140Sstevel@tonic-gate# the inetd.conf entries from all the manifests for consumption by inetconv. 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate> $inetdconf_entries_file 1170Sstevel@tonic-gateinetconv_services="" 1180Sstevel@tonic-gateinstances_to_disable="" 1190Sstevel@tonic-gate 1200Sstevel@tonic-gatefor manifest in $inetconv_manifests; do 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate manifest_instances=`/usr/sbin/svccfg inventory $manifest | \ 1230Sstevel@tonic-gate egrep "svc:/.*:.*"` 1240Sstevel@tonic-gate manifest_service=`/usr/sbin/svccfg inventory $manifest | \ 1250Sstevel@tonic-gate egrep -v "svc:/.*:.*"` 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate instance_disabled="" 1280Sstevel@tonic-gate default_enabled="" 1290Sstevel@tonic-gate enabled="" 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate for instance in $manifest_instances; do 1320Sstevel@tonic-gate # if the instance doesn't exist in the repository skip it 1330Sstevel@tonic-gate svcprop -q $instance 1340Sstevel@tonic-gate if [ $? -ne 0 ]; then 1350Sstevel@tonic-gate continue 1360Sstevel@tonic-gate fi 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate enabled=`svcprop -p general/enabled $instance` 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate default_instance=`echo $instance | grep ":default"` 1410Sstevel@tonic-gate if [ "$default_instance" != "" ]; then 1420Sstevel@tonic-gate default_enabled=$enabled 1430Sstevel@tonic-gate else 1440Sstevel@tonic-gate # add all non-default instances to disable list 1450Sstevel@tonic-gate instances_to_disable="$instances_to_disable \ 1460Sstevel@tonic-gate $instance" 1470Sstevel@tonic-gate if [ "$enabled" != "true" ]; then 1480Sstevel@tonic-gate instance_disabled="true" 1490Sstevel@tonic-gate fi 1500Sstevel@tonic-gate fi 1510Sstevel@tonic-gate done 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate # if none of the manifest's instances existed, skip this manifest 1540Sstevel@tonic-gate if [ "$enabled" = "" ]; then 1550Sstevel@tonic-gate continue 1560Sstevel@tonic-gate fi 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate # If the default instance existed and was disabled, or if didn't 1590Sstevel@tonic-gate # exist and one of the other instances was disabled, add the default 1600Sstevel@tonic-gate # to the list of instances to disable. 1610Sstevel@tonic-gate if [ "$default_enabled" = "false" -o "$default_enabled" = "" -a \ 1620Sstevel@tonic-gate "$instance_disabled" = "true" ]; then 1630Sstevel@tonic-gate instances_to_disable="$instances_to_disable \ 1640Sstevel@tonic-gate $manifest_service:default" 1650Sstevel@tonic-gate fi 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate # add the manifest's inetd.conf src line to file for inetconv 1680Sstevel@tonic-gate sed -n -f /tmp/inetd-upgrade.$$.sed $manifest >> \ 1690Sstevel@tonic-gate $inetdconf_entries_file 1700Sstevel@tonic-gatedone 1710Sstevel@tonic-gate 1720Sstevel@tonic-gaterm /tmp/inetd-upgrade.$$.sed 1730Sstevel@tonic-gate 174*4352Scarlsonj# Check whether we've ever run inetconv before by looking for the 175*4352Scarlsonj# configuration file hash. If we haven't run it before, then we need 176*4352Scarlsonj# to enable services based on inetd.conf. If we have, then the 177*4352Scarlsonj# repository is authoritative. `unimported' will be 0 if the hash exists. 178*4352Scarlsonjsvcprop -qp hash svc:/network/inetd:default 179*4352Scarlsonjunimported=$? 180*4352Scarlsonj 1810Sstevel@tonic-gate# Run inetconv on generated file, overwriting previous manifests and values 1820Sstevel@tonic-gate# in repository. 1830Sstevel@tonic-gate/usr/sbin/inetconv -f -i $inetdconf_entries_file 1840Sstevel@tonic-gate 1850Sstevel@tonic-gate# disable the necessary instances 1860Sstevel@tonic-gatefor inst in $instances_to_disable; do 1870Sstevel@tonic-gate svcadm disable $inst 1880Sstevel@tonic-gatedone 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate 191*4352Scarlsonj# If there is a saved config file from upgrade, use it to enable services, 192*4352Scarlsonj# but only if we're coming from a release that didn't have SMF. 1930Sstevel@tonic-gatesaved_config=/etc/inet/inetd.conf.preupgrade 194*4352Scarlsonjif [ $unimported -ne 0 -a -f $saved_config ]; then 195*4352Scarlsonj /usr/sbin/inetconv -e -i $saved_config 1960Sstevel@tonic-gatefi 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate# Now convert the remaining entries in inetd.conf to service manifests 1990Sstevel@tonic-gate/usr/sbin/inetconv 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate# Now disable myself as the upgrade is done 2020Sstevel@tonic-gatesvcadm disable network/inetd-upgrade 2030Sstevel@tonic-gate 2040Sstevel@tonic-gateexit 0 205