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