File dazuko.init-script of Package dazuko
#!/bin/sh
#
# System startup script loading dazuko kernel module.
# Copyright (C) 2006 Marius Tomaschewski, SUSE / Novell Inc.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
# USA.
#
# /etc/init.d/boot.dazuko
#
### BEGIN INIT INFO
# Provides: boot.dazuko
# Required-Start: boot.localfs boot.loadmodules
# Required-Stop: boot.localfs boot.loadmodules
# Should-Start: apparmor
# Should-Stop: apparmor
# Default-Start: B
# Default-Stop: B
# Description: Loads dazuko, on-access virus interface.
### END INIT INFO
#--
# Initialize variable with dazuko module name.
DAZUKO_MODULE=""
# For compatibility with old versions.
test -r /etc/sysconfig/antivir && {
. /etc/sysconfig/antivir
}
# Check for existence of needed config file and read it
DAZUKO_CONFIG=/etc/sysconfig/dazuko
test -r "$DAZUKO_CONFIG" && {
. "$DAZUKO_CONFIG"
} || {
echo "$DAZUKO_CONFIG does not exists";
test "$1" = "stop" && exit 0 || exit 6;
}
# For MODULES_LOADED_ON_BOOT variable.
test -r /etc/sysconfig/kernel && {
. /etc/sysconfig/kernel
}
#--
module_loads_on_boot()
{
name=$1
test -n "$name" && \
test -n "$MODULES_LOADED_ON_BOOT" && \
for m in $MODULES_LOADED_ON_BOOT ; do
if test "x$m" == "x$name" ; then
return 0
fi
done
return 1
}
#--
# Source functions from /etc/rc.status:
. /etc/rc.status
# Reset status of this service
rc_reset
case "$1" in
start|restart)
echo -n "Loading dazuko on-access scanner interface"
if test -n "$DAZUKO_MODULE" ; then
MODULE=$(basename $DAZUKO_MODULE)
MODULE=${MODULE%.*o}
if ! module_loads_on_boot $MODULE ; then
modprobe -qs $DAZUKO_MODULE &>/dev/null
rc_status -v
else
# Module loads on boot... skip.
rc_status -u
fi
else
# Module loading disabled...
rc_status -u
fi
;;
stop)
echo -n "Unloading dazuko on-access scanner interface"
if test -n "$DAZUKO_MODULE" ; then
MODULE=$(basename $DAZUKO_MODULE)
MODULE=${MODULE%.*o}
if ! module_loads_on_boot $MODULE ; then
if test -n "$MODULE" && \
lsmod | grep -qse "^${MODULE}" ;
then
rmmod -s $MODULE
fi
rc_status -v
else
# Module loads on boot... skip.
rc_status -u
fi
else
# Module loading disabled...
rc_status -u
fi
;;
# restart)
# ## Stop the service and regardless of whether it was
# ## running or not, start it again.
# $0 stop
# $0 start
#
# # Remember status and be quiet
# rc_status
# ;;
status)
echo -n "Checking for dazuko on-access scanner interface "
if test -n "$DAZUKO_MODULE" ; then
MODULE=$(basename $DAZUKO_MODULE)
MODULE=${MODULE%.*o}
else
MODULE=""
fi
if test -n "$MODULE" ; then
if lsmod | grep -qse "^${MODULE}" ; then
rc_failed 0
else
rc_failed 3
fi
else
# Not configured / unknown
rc_failed 4
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
rc_exit