File init.z90crypt of Package libica-2_3_0
#! /bin/sh
# Copyright (c) 2002-2004 SUSE AG, Nuernberg, Germany.
#
# Author: Bernd Kaindl <feedback@suse.de>
# Hannes Reinecke <feedback@suse.de>
#
# /etc/init.d/z90crypt
#
# and symbolic its link
#
# /usr/sbin/rcz90crypt
#
### BEGIN INIT INFO
# Provides: z90crypt
# Required-Start:
# Required-Stop:
# Default-Start: B
# Default-Stop:
# Description: Load the z90crypt module
### END INIT INFO
Z90CRYPT_CONFIG_FILE=/etc/sysconfig/z90crypt
. /etc/rc.status
if [ -s "$Z90CRYPT_CONFIG_FILE" ]; then
source $Z90CRYPT_CONFIG_FILE
else
Z90CRYPT_DOMAIN="-1"
fi
if [ "$Z90CRYPT_DOMAIN" = "-1" ]; then
parm=
else
parm="domain=$Z90CRYPT_DOMAIN"
fi
module="ap"
device="z90crypt"
# Recursive function to unload all holding modules before unloading
# the requested module.
function unload_module_and_holding {
for holder in $(ls /sys/module/$1/holders/); do
if [ -e /sys/module/$1/holders/$holder ]; then
unload_module_and_holding $holder
fi
done
echo -n "Unloading $1 module:"
# invoke rmmod with no args
/sbin/rmmod $1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
rc_failed
rc_status -v
rc_exit
fi
# Remember status and be verbose
rc_status -v
}
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# First reset status of this service
rc_reset
case "$1" in
start)
echo -n "Loading $module module"
#/sbin/modprobe $module > /dev/null 2>&1 || {
/sbin/modprobe $module $parm || {
rc_failed
rc_status -v
rc_exit
}
rc_status -v
# The z90crypt device node is created by the zcrypt_api module.
# Simply loading the ap bus module does not immediately make
# the z90crypt device node. Explicitly loading zcrypt_api will
# cause the z90crypt device node to be created in a timely
# manner.
echo -n "Loading zcrypt_api module"
/sbin/modprobe zcrypt_api
if [ ! -d /sys/class/misc/$device ]; then
echo -n " - no device, maybe HW not found (see dmesg)"
rc_failed
rc_status -v
rc_exit
fi
# Remember status and be verbose
rc_status -v
;;
stop)
# Modules associated with the ap bus module have nested
# dependencies. This function recurses into the holding
# modules and unloads them first.
unload_module_and_holding $module
# Remove stale nodes
rm -f /dev/${device}
;;
try-restart)
## Unload the module and if this succeeds (i.e. the
## module was loaded before), start it again.
$0 status >/dev/null && $0 restart
# Remember status and be quiet
rc_status
;;
restart)
## Unload the module and regardless of whether it was
## loaded or not, load it again.
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
## If it does not support it, restart.
echo "Reload module $module"
## if it supports it:
#killproc -p /var/run/z90crypt.pid -HUP /usr/sbin/z90crypt
#touch /var/run/ssh.pid
$0 restart
;;
reload)
## Like force-reload, but if daemon does not support
## signalling, do nothing (!)
# If it supports signalling:
echo "Reload module $module"
#killproc -p /var/run/z90crypt.pid -HUP /usr/sbin/z90crypt
#touch /var/run/z90crypt.pid
$0 restart
;;
status)
echo -n "Checking for module $module: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
lsmod | grep -q $module
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit