i.services revision 3361618b69459cc57ec852687200c4c3550ca822
8b666e1fb772b6fe45de3604b224f3e1f2cfd620rbb#!/bin/sh
8b666e1fb772b6fe45de3604b224f3e1f2cfd620rbb#
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe# CDDL HEADER START
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe#
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe# The contents of this file are subject to the terms of the
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe# Common Development and Distribution License (the "License").
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe# You may not use this file except in compliance with the License.
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe#
a310497ca9c5112d759871e1b7d9f6a40fb78bcfwrowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8bda0627eb2aca9e678c1303a0423d33069388dfwrowe# or http://www.opensolaris.org/os/licensing.
f00bc25ff5027f3a40e9cd0ade782641bd0bf1d0wrowe# See the License for the specific language governing permissions
f00bc25ff5027f3a40e9cd0ade782641bd0bf1d0wrowe# and limitations under the License.
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb#
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# When distributing Covered Code, include this CDDL HEADER in each
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# If applicable, add the following below this CDDL HEADER, with the
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# fields enclosed by brackets "[]" replaced with your own identifying
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# information: Portions Copyright [yyyy] [name of copyright owner]
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb#
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# CDDL HEADER END
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb#
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
e36ef0d081aa59867688bcbb3da65952ec16fae3rbb# Use is subject to license terms.
52df98b165194a0ad68885f49f81fdaf56ece568wrowe#
52df98b165194a0ad68885f49f81fdaf56ece568wrowe
52df98b165194a0ad68885f49f81fdaf56ece568wrowewrite_comment() {
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbbcat > /tmp/services.cmt.$$ << EOF
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb#
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb# The following customer-specific entries were found in the ${filename} file
2c294c31addd5c957bafe6e78c4a30d423ad6e80rbb# prior to an upgrade. Note that ${thing} names and their corresponding
7e44dd5082cd865068285e8f915bb5f045e0bb80lars# ${number} numbers must be registered with ${registrar}, ${regurl}, and
7e44dd5082cd865068285e8f915bb5f045e0bb80lars# entries not registered as such may not be preserved automatically by
7e44dd5082cd865068285e8f915bb5f045e0bb80lars# future upgrades.
7e44dd5082cd865068285e8f915bb5f045e0bb80lars#
44a4ee1140769173da7bc2b42d1a686e3260ad84wroweEOF
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowe}
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowe
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowewhile read src dest
44a4ee1140769173da7bc2b42d1a686e3260ad84wrowedo
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz if [ ! -f $dest ] ; then
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz cp $src $dest
e379fc6d7f79163700290d92ce75deb4f3005301jerenkrantz else
978faa9e29e0f0c42e66c07240e562325a4717b0jerenkrantz
978faa9e29e0f0c42e66c07240e562325a4717b0jerenkrantz # Adjust message as appropriate to target file.
978faa9e29e0f0c42e66c07240e562325a4717b0jerenkrantz
978faa9e29e0f0c42e66c07240e562325a4717b0jerenkrantz d=`basename $dest`
976501adbc040220270f7d1d77c4b8373033be69wrowe
976501adbc040220270f7d1d77c4b8373033be69wrowe # Assume english plural of word not ending in s.
976501adbc040220270f7d1d77c4b8373033be69wrowe # no need for heroic natural language processing, we can
976501adbc040220270f7d1d77c4b8373033be69wrowe # tweak things in the case statement below.
976501adbc040220270f7d1d77c4b8373033be69wrowe
976501adbc040220270f7d1d77c4b8373033be69wrowe t=`basename $d s`
10a00688adcf1df367b1243810beedaabe6b1abeminfrin filename=${d}
10a00688adcf1df367b1243810beedaabe6b1abeminfrin thing=${t}
10a00688adcf1df367b1243810beedaabe6b1abeminfrin number=${t}
8a3a703eae0e35f674b189181609545c6fc77a09rbb registrar=IANA
8a3a703eae0e35f674b189181609545c6fc77a09rbb regurl=http://www.iana.org
8a3a703eae0e35f674b189181609545c6fc77a09rbb
8a3a703eae0e35f674b189181609545c6fc77a09rbb # Override cases we know about.
9af1ccb223d0669b3c3a43eed070d815afde9084mjc case ${d} in
9af1ccb223d0669b3c3a43eed070d815afde9084mjc services)
9af1ccb223d0669b3c3a43eed070d815afde9084mjc number="port"
9d41fafe32b324c197f25224207fc6ce34f085bfrbb ;;
9d41fafe32b324c197f25224207fc6ce34f085bfrbb esac
9d41fafe32b324c197f25224207fc6ce34f085bfrbb
9d41fafe32b324c197f25224207fc6ce34f085bfrbb grep -v "^#" $dest | \
9d41fafe32b324c197f25224207fc6ce34f085bfrbb while read service port rest_of_line; do
889d9c84f8b1ad850f977a6d8e548696994f8f86jerenkrantz grep "^$service[ ]*$port[ ]*" \
889d9c84f8b1ad850f977a6d8e548696994f8f86jerenkrantz $src > /dev/null 2>&1
889d9c84f8b1ad850f977a6d8e548696994f8f86jerenkrantz if [ $? != 0 ]; then
8c83461e53ca7d204e1d634f0c78199d60320d7bjerenkrantz # not in the new source
8c83461e53ca7d204e1d634f0c78199d60320d7bjerenkrantz grep "^$service[ ]*$port[ ]*" \
8c83461e53ca7d204e1d634f0c78199d60320d7bjerenkrantz /tmp/services.$$ > /dev/null 2>&1
8e5842bc05146bb5c171e53b00b24063d17c666cjerenkrantz if [ $? != 0 ]; then
8e5842bc05146bb5c171e53b00b24063d17c666cjerenkrantz # also not a duplicate, get ONE line here
8e5842bc05146bb5c171e53b00b24063d17c666cjerenkrantz grep "^$service[ ]*$port[ ]*" \
cdb15137887e284797e9510029098dc725b4dacfjerenkrantz $dest | line >> /tmp/services.$$
cdb15137887e284797e9510029098dc725b4dacfjerenkrantz fi
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz fi
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz done
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz
798c7c11dc2fe3b08e591e9c76fc1a84857f2cd4jerenkrantz cat $src > /tmp/d.$$
abaaa634d7cee882b7c4bf078ded749ebf11997erbb if [ -f /tmp/services.$$ ]; then
abaaa634d7cee882b7c4bf078ded749ebf11997erbb write_comment
abaaa634d7cee882b7c4bf078ded749ebf11997erbb cat /tmp/services.cmt.$$ >> /tmp/d.$$
abaaa634d7cee882b7c4bf078ded749ebf11997erbb cat /tmp/services.$$ >> /tmp/d.$$
0aa8e8fd5a242948518655f2296b3c76386754e5jerenkrantz rm -f /tmp/services.$$ /tmp/services.cmt.$$
0aa8e8fd5a242948518655f2296b3c76386754e5jerenkrantz fi
0aa8e8fd5a242948518655f2296b3c76386754e5jerenkrantz cp /tmp/d.$$ $dest
de3abad1fe263e577bb11e99b358836bd901397crbb rm -f /tmp/d.$$
de3abad1fe263e577bb11e99b358836bd901397crbb
de3abad1fe263e577bb11e99b358836bd901397crbb # Set correct permissions on services file
de3abad1fe263e577bb11e99b358836bd901397crbb chmod 0644 $dest
de3abad1fe263e577bb11e99b358836bd901397crbb fi
de3abad1fe263e577bb11e99b358836bd901397crbbdone
de3abad1fe263e577bb11e99b358836bd901397crbb
de3abad1fe263e577bb11e99b358836bd901397crbbexit 0
de3abad1fe263e577bb11e99b358836bd901397crbb