i.initd revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 1997-1998, 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
#
# This class action script handles the issue of delivering a new version of
# the package prototype file has been set up so that we have a set of
# entries similar to the following:
#
#
# editable so that this script is invoked during both install and upgrade.
# Since all the files are specified as class 'initd', we know that this
# script will first be invoked for all the 'e' files, and then for the links.
# We are responsible for copying over the 'e' files, and installf creates
# the hard links for us.
#
# Since we know that pkgadd will call installf to add the 'l' links last,
# we are asked to install. In order to locate existing S and K links, we use
# two algorithms: (1) If the destination file exists and has a > 1 link count,
# we scan the /etc directory (relative to the destination file) for files with
# the same inode number whose names begin with [SK][0-9][0-9] and remove them.
# whose names are [SK][0-9][0-9] followed by the basename of the destination
# file. Step (2) is needed because we may have mistakenly delivered the file
# earlier as a symbolic link, or because a system administrator may have
#
# For each file we wish to remove, we need to first ask removef if it's ok
# to remove, and then remove it, and finally call removef -f to update the
# software database. With that complete, we then invoke installf to
# install all of the 'l' links in the 'initd' class specified in the pkgmap
# file. This step is necessary because during upgrade, pkgadd will not
# invoke this script for 'l' links, since it has no concept of an 'editable'
# link which is changing during an upgrade.
#
# Execution of the checkinstall script will have determined, which, if any of
# the scripts were modified by a system administrator. This list of scripts
# was preserved in the MODIFIED_AFTER_INSTALLED variable. We iterate through
# the modified scripts, saving the system administrator's old version and
# internationalized message being written to the upgrade log
# /var/sadm/install_data/upgrade_cleanup. For more on the details of
*) EXT="";;
esac
*)
nfile="${ofile}.old" ;;
esac
if [ -f $ofile ]; then
fi
done
fi
# Now read the standard input to the class-action script (this will be
# install the new version of each init.d script.
# If this item is the link, the additional hard link to the
# need to do anything here.
;;
acct)
# By default (the '*' case below) we're going to remove all
# links to this script; if links are present, the administrator
# has created them in order to enable accounting, and we want
# to leave them enabled.
;;
*)
# If this item is the script, then remove any existing links
# and then copy the contents from $src to $dst
if [ -f $dst ]; then
shift $#
(
find $PKG_INSTALL_ROOT/etc/rc?.d -mount \
fi
echo $PKG_INSTALL_ROOT/etc/rc?.d/[SK][0-9][0-9]$dstname
fi
;;
esac
done
# Complete the removal operations specified in the loop above
# Now find all the hard links for the initd class in the package map
# and make sure they get recreated. In the case of hard links, installf
# takes care of updating the database *and* creating the links. We need
# to tweak the source and destination of the link to be absolute paths.
# Installf will convert these to be relative to $PKG_INSTALL_ROOT, which
# it inherits through the environment.
sed -e 's:^etc/:/etc/:' | \