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 # Postinstall script for SUNWcryptoint.
  28 #
  29 # This script appends a hardware provider section for the dprov
  30 # test driver to /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 # If the package has been already installed, remove old entries
  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 else
  68         cp -p $kcfconf $tmpfile || error=yes
  69 fi
  70 
  71 #
  72 # Append the delimiters for this package
  73 #
  74 echo "$pkg_start driver_names=dprov" >> $tmpfile || error=yes
  75 echo "$pkg_end" >> $tmpfile || error=yes
  76 
  77 #
  78 # Install the updated config file and clean up the tmp file
  79 #
  80 if [ "$error" = no ]
  81 then 
  82         mv $tmpfile $kcfconf || error=yes
  83 fi
  84 rm -f $tmpfile
  85 
  86 #
  87 # All done, if any of the steps above fail, report the error
  88 #
  89 if [ "$error" = yes ]
  90 then
  91         echo "$0: ERROR - failed to update $kcfconf."
  92         exit 2
  93 fi
  94 exit 0