i.services revision 3875
3875N/A#!/bin/sh
3875N/A#
3875N/A#ident "@(#)i.services 1.6 03/04/02 SMI"
3875N/A#
3875N/A# Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
3875N/A# Use is subject to license terms.
3875N/A#
3875N/A
3875N/Awrite_comment() {
3875N/Acat > /tmp/services.cmt.$$ << EOF
3875N/A#
3875N/A# The following customer-specific entries were found in the ${filename} file
3875N/A# prior to an upgrade. Note that ${thing} names and their corresponding
3875N/A# ${number} numbers must be registered with ${registrar}, ${regurl}, and
3875N/A# entries not registered as such may not be preserved automatically by
3875N/A# future upgrades.
3875N/A#
3875N/AEOF
3875N/A}
3875N/A
3875N/Awhile read src dest
3875N/Ado
3875N/A if [ ! -f $dest ] ; then
3875N/A cp $src $dest
3875N/A else
3875N/A
3875N/A # Adjust message as appropriate to target file.
3875N/A
3875N/A d=`basename $dest`
3875N/A
3875N/A # Assume english plural of word not ending in s.
3875N/A # no need for heroic natural language processing, we can
3875N/A # tweak things in the case statement below.
3875N/A
3875N/A t=`basename $d s`
3875N/A filename=${d}
3875N/A thing=${t}
3875N/A number=${t}
3875N/A registrar=IANA
3875N/A regurl=http://www.iana.org
3875N/A
3875N/A # Override cases we know about.
3875N/A case ${d} in
3875N/A services)
3875N/A number="port"
3875N/A ;;
3875N/A esac
3875N/A
3875N/A grep -v "^#" $dest | \
3875N/A while read service port rest_of_line; do
3875N/A grep "^$service[ ]*$port[ ]*" \
3875N/A $src > /dev/null 2>&1
3875N/A if [ $? != 0 ]; then
3875N/A # not in the new source
3875N/A grep "^$service[ ]*$port[ ]*" \
3875N/A /tmp/services.$$ > /dev/null 2>&1
3875N/A if [ $? != 0 ]; then
3875N/A # also not a duplicate, get ONE line here
3875N/A grep "^$service[ ]*$port[ ]*" \
3875N/A $dest | line >> /tmp/services.$$
3875N/A fi
3875N/A fi
3875N/A done
3875N/A
3875N/A cat $src > /tmp/d.$$
3875N/A if [ -f /tmp/services.$$ ]; then
3875N/A write_comment
3875N/A cat /tmp/services.cmt.$$ >> /tmp/d.$$
3875N/A cat /tmp/services.$$ >> /tmp/d.$$
3875N/A rm -f /tmp/services.$$ /tmp/services.cmt.$$
3875N/A fi
3875N/A cp /tmp/d.$$ $dest
3875N/A rm -f /tmp/d.$$
3875N/A fi
3875N/Adone
3875N/A
3875N/Aexit 0