1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21 #
22 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
24 #
25 # ident "%Z%%M% %I% %E% SMI"
26 #
27 # Preremove script for SUNWcryptoint.
28 #
29 # This script removes the hardware provider section for the dprov
30 # test driver from /etc/crypto/kcf.conf
31 #
32
33 pkg_start="# Start $PKGINST"
34 pkg_end="# End $PKGINST"
35 kcfconf=${BASEDIR}/etc/crypto/kcf.conf
36 tmpfile=/tmp/$$kcfconf
37 error=no
38
39 #
40 # If /etc/crypto/kcf.conf doesn't exist, bail immediately
41 #
42 if [ ! -f "$kcfconf" ]
43 then
44 echo "$0: ERROR - $kcfconf doesn't exist"
45 exit 2
46 fi
47
48 #
49 # Strip all entries belonging to this package
50 #
51 start=0
52 end=0
53 egrep -s "$pkg_start" $kcfconf && start=1
54 egrep -s "$pkg_end" $kcfconf && end=1
55
56 if [ $start -ne $end ] ; then
57 echo "$0: missing Start or End delimiters for $PKGINST in $kcfconf."
58 echo "$0: $kcfconf may be corrupted and was not updated."
59 error=yes
60 exit 2
61 fi
62
63 if [ $start -eq 1 ]
64 then
65 cp -p $kcfconf $tmpfile || error=yes
66 sed -e "/$pkg_start/,/$pkg_end/d" $kcfconf > $tmpfile || error=yes
67 if [ "$error" = no ]
68 then
69 mv $tmpfile $kcfconf || error=yes
70 fi
71 rm -f $tmpfile
72 else
73 echo "$0: WARNING - no entries to be removed from $kcfconf"
74 exit 0
75 fi
76
77 if [ "$error" = yes ]
78 then
79 echo "$0: ERROR - failed to update $kcfconf."
80 exit 2
81 fi
82 exit 0