#!/bin/sh
#
# Name:     nFast800 - nCipher nFast800 init script
#           This script is part of nCipher driver for Linux 
#
# August 14, 2001   Modify openssl config file to enable hardware ssl acceleration
#		    on start and undo what was done in start when stopping.
#

# Tags 
# chkconfig: 2345 11 89
# description: load and unload nFast800 driver 

BINNAME=bcm5820


PATH=/sbin:/usr/sbin:/bin:/usr/bin

# Source function library
if [ -f /etc/init.d/functions ]; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
fi

case "$1" in
    start)
	insmod $BINNAME 
	rm -f /dev/cryptonet
	mknod /dev/cryptonet c `grep "cryptonet" /proc/devices | head -1 | awk '{print $1}'` 1
	chmod o+w /dev/cryptonet
	if [ -f /usr/share/ssl/openssl.cnf ]; then
          rm -f /tmp/openssl.cnf.mod
	  sed -n '/default/s/openssl/ubsec/g; w /tmp/openssl.cnf.mod' /usr/share/ssl/openssl.cnf
	  mv -f /tmp/openssl.cnf.mod /usr/share/ssl/openssl.cnf
	fi
        ;;
    stop)
	rmmod $BINNAME
	rm -f /dev/cryptonet
	if [ -f /usr/share/ssl/openssl.cnf ]; then
          rm -f /tmp/openssl.cnf.mod
	  sed -n '/default/s/ubsec/openssl/g; w /tmp/openssl.cnf.mod' /usr/share/ssl/openssl.cnf
	  mv -f /tmp/openssl.cnf.mod /usr/share/ssl/openssl.cnf
	fi
        ;;
    *)
        echo Broadcom $BINNAME init script
        echo Copyright \(c\) 2001 Broadcom Corporation
        echo usage: $BINNAME  \[start\|stop\]
        exit 1
        ;;
esac


