xref: /titanic_41/usr/src/cmd/cmd-inet/usr.sadm/scripts/i.ipsecalgs (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1#
2# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3# Use is subject to license terms.
4#
5# CDDL HEADER START
6#
7# The contents of this file are subject to the terms of the
8# Common Development and Distribution License, Version 1.0 only
9# (the "License").  You may not use this file except in compliance
10# with the License.
11#
12# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13# or http://www.opensolaris.org/os/licensing.
14# See the License for the specific language governing permissions
15# and limitations under the License.
16#
17# When distributing Covered Code, include this CDDL HEADER in each
18# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19# If applicable, add the following below this CDDL HEADER, with the
20# fields enclosed by brackets "[]" replaced with your own identifying
21# information: Portions Copyright [yyyy] [name of copyright owner]
22#
23# CDDL HEADER END
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27# Class action script for ipsecalgs class files.
28#
29# This script appends the input file from the package to the
30# /etc/inet/ipsecalgs file.
31#
32
33pkg_start="# Start $PKGINST"
34pkg_end="# End $PKGINST"
35confile=/etc/inet/ipsecalgs
36tmpfile=/tmp/$$ipsecalgs
37error=no
38
39while read src dest
40do
41	[ "$src" = /dev/null ] && continue
42
43	if [ -f "$dest" ]
44	then
45		# If the package has been already installed, remove old entries
46		grep "$pkg_start" $dest > /dev/null
47		if [ $? -eq 0 ]
48		then
49			sed -e "/$pkg_start/,/$pkg_end/d" $dest > $tmpfile \
50			|| error=yes
51		else
52			cp $dest $tmpfile || error=yes
53		fi
54
55		# Append the delimiters and entries of this package
56		echo "$pkg_start" >> $tmpfile || error=yes
57		cat $src >> $tmpfile || error=yes
58		echo "$pkg_end" >> $tmpfile || error=yes
59
60		# Install the updated config file and clean up the tmp file
61                if [ "$error" = no ]
62                then
63			mv $tmpfile $dest || error=yes
64		fi
65		rm -f $tmpfile
66	else
67		echo "$0: ERROR - the $confile file doesn't exist."
68		exit 2
69	fi
70done
71
72if [ "$error" = yes ]
73then
74	echo "$0: ERROR - failed to update the $confile file."
75	exit 2
76fi
77exit 0
78