inetd-upgrade.sh revision 9444c26f4faabda140242c3986089704c4073ced
2N/A#! /usr/bin/sh
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A#
2N/A# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
2N/A# Use is subject to license terms.
2N/A#
2N/A
2N/A# Start by cleaning out obsolete instances. For each one that
2N/A# exists in the repository, remove it.
2N/Ainetd_obsolete_instances="
2N/A network/nfs/rquota:ticlts
2N/A network/nfs/rquota:udp
2N/A network/rexec:tcp
2N/A network/rexec:tcp6
2N/A network/rpc/gss:ticotsord
2N/A network/rpc/mdcomm:tcp
2N/A network/rpc/mdcomm:tcp6
2N/A network/rpc/meta:tcp
2N/A network/rpc/meta:tcp6
2N/A network/rpc/metamed:tcp
2N/A network/rpc/metamed:tcp6
2N/A network/rpc/metamh:tcp
2N/A network/rpc/metamh:tcp6
2N/A network/rpc/rex:tcp
2N/A network/rpc/rstat:ticlts
2N/A network/rpc/rstat:udp
2N/A network/rpc/rstat:udp6
2N/A network/rpc/rusers:udp
2N/A network/rpc/rusers:udp6
2N/A network/rpc/rusers:ticlts
2N/A network/rpc/rusers:tcp
2N/A network/rpc/rusers:tcp6
2N/A network/rpc/rusers:ticotsord
2N/A network/rpc/rusers:ticots
2N/A network/rpc/spray:ticlts
2N/A network/rpc/spray:udp
2N/A network/rpc/spray:udp6
2N/A network/rpc/wall:ticlts
2N/A network/rpc/wall:udp
2N/A network/rpc/wall:udp6
2N/A network/security/krb5_prop:tcp
2N/A network/security/ktkt_warn:ticotsord
2N/A network/shell:tcp
2N/A network/shell:tcp6only
2N/A platform/sun4u/dcs:tcp
2N/A platform/sun4u/dcs:tcp6
2N/A"
2N/A
2N/Afor i in $inetd_obsolete_instances; do
2N/A enable=`svcprop -p general/enabled $i`
2N/A if [ $? = 0 ]; then
2N/A # Instance found, so disable and delete
2N/A svcadm disable $i
2N/A svccfg delete $i
2N/A if [ "$enable" = "true" ]; then
2N/A # Instance was enabled, so enable the replacement.
2N/A # We must do this here because the profile which
2N/A # normally enables these is only applied on first
2N/A # install of smf.
2N/A s=`echo $i | cut -f1 -d:`
2N/A svcadm enable $s:default
2N/A fi
2N/A fi
2N/Adone
2N/A
2N/A
2N/A# The Following blocks of code cause the inetconv generated services to be
2N/A# re-generated, so that the latest inetconv modifications are applied to all
2N/A# services generated by it.
2N/A
2N/Ainetdconf_entries_file=/tmp/iconf_entries.$$
2N/A
2N/A# Create sed script that prints out inetd.conf src line from inetconv generated
2N/A# manifest.
2N/Acat <<EOF > /tmp/inetd-upgrade.$$.sed
2N/A/propval name='source_line'/{
2N/An
2N/As/'//g
2N/Ap
2N/A}
2N/A/from the inetd.conf(4) format line/{
2N/An
2N/Ap
2N/A}
2N/AEOF
2N/A
2N/A# get list of inetconv generated manifests
2N/Ainetconv_manifests=`/usr/bin/find /lib/svc/manifest -type f -name \*.xml | \
2N/A /usr/bin/xargs /usr/bin/grep -l "Generated by inetconv"`
2N/A
2N/A# For each inetconv generated manifest determine the instances that should
2N/A# be disabled when the new manifests are imported, and generate a file with
2N/A# the inetd.conf entries from all the manifests for consumption by inetconv.
2N/A
2N/A> $inetdconf_entries_file
2N/Ainetconv_services=""
2N/Ainstances_to_disable=""
2N/A
2N/Afor manifest in $inetconv_manifests; do
2N/A
2N/A manifest_instances=`/usr/sbin/svccfg inventory $manifest | \
2N/A egrep "svc:/.*:.*"`
2N/A manifest_service=`/usr/sbin/svccfg inventory $manifest | \
2N/A egrep -v "svc:/.*:.*"`
2N/A
2N/A instance_disabled=""
2N/A default_enabled=""
2N/A enabled=""
2N/A
2N/A for instance in $manifest_instances; do
2N/A # if the instance doesn't exist in the repository skip it
2N/A svcprop -q $instance
2N/A if [ $? -ne 0 ]; then
2N/A continue
2N/A fi
2N/A
2N/A enabled=`svcprop -p general/enabled $instance`
2N/A
2N/A default_instance=`echo $instance | grep ":default"`
2N/A if [ "$default_instance" != "" ]; then
2N/A default_enabled=$enabled
2N/A else
2N/A # add all non-default instances to disable list
2N/A instances_to_disable="$instances_to_disable \
2N/A $instance"
2N/A if [ "$enabled" != "true" ]; then
2N/A instance_disabled="true"
2N/A fi
2N/A fi
2N/A done
2N/A
2N/A # if none of the manifest's instances existed, skip this manifest
2N/A if [ "$enabled" = "" ]; then
2N/A continue
2N/A fi
2N/A
2N/A # If the default instance existed and was disabled, or if didn't
2N/A # exist and one of the other instances was disabled, add the default
2N/A # to the list of instances to disable.
2N/A if [ "$default_enabled" = "false" -o "$default_enabled" = "" -a \
2N/A "$instance_disabled" = "true" ]; then
2N/A instances_to_disable="$instances_to_disable \
2N/A $manifest_service:default"
2N/A fi
2N/A
2N/A # add the manifest's inetd.conf src line to file for inetconv
2N/A sed -n -f /tmp/inetd-upgrade.$$.sed $manifest >> \
2N/A $inetdconf_entries_file
2N/Adone
2N/A
2N/Arm /tmp/inetd-upgrade.$$.sed
2N/A
2N/A# Check whether we've ever run inetconv before by looking for the
2N/A# configuration file hash. If we haven't run it before, then we need
2N/A# to enable services based on inetd.conf. If we have, then the
2N/A# repository is authoritative. `unimported' will be 0 if the hash exists.
2N/Asvcprop -qp hash svc:/network/inetd:default
2N/Aunimported=$?
2N/A
2N/A# Run inetconv on generated file, overwriting previous manifests and values
2N/A# in repository.
2N/A/usr/sbin/inetconv -f -i $inetdconf_entries_file
2N/A
2N/A# disable the necessary instances
2N/Afor inst in $instances_to_disable; do
2N/A svcadm disable $inst
2N/Adone
2N/A
2N/A
2N/A# If there is a saved config file from upgrade, use it to enable services,
2N/A# but only if we're coming from a release that didn't have SMF.
2N/Asaved_config=/etc/inet/inetd.conf.preupgrade
2N/Aif [ $unimported -ne 0 -a -f $saved_config ]; then
2N/A /usr/sbin/inetconv -e -i $saved_config
2N/Afi
2N/A
2N/A# Now convert the remaining entries in inetd.conf to service manifests
2N/A/usr/sbin/inetconv
2N/A
2N/A# Now disable myself as the upgrade is done
2N/Asvcadm disable network/inetd-upgrade
2N/A
2N/Aexit 0
2N/A