Streamline module processing

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4545 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2006-09-07 21:55:46 +00:00
parent 2f1fcbb558
commit 090f19f02a

View File

@ -172,54 +172,31 @@ deleteallchains() {
}
#
# Load a Kernel Module
# Reload the Modules
#
loadmodule() # $1 = module name, $2 - * arguments
{
local modulename=$1
local modulefile
local suffix
moduleloader=modprobe
reload_kernel_modules() {
local save_modules_dir=$MODULESDIR
local directory
local moduledirectories=
local moduleloader=modprobe
if ! qt mywhich modprobe; then
moduleloader=insmod
fi
if ! list_search $modulename $MODULES ; then
shift
for suffix in $MODULE_SUFFIX ; do
modulefile=$MODULESDIR/${modulename}.${suffix}
if [ -f $modulefile ]; then
case $moduleloader in
insmod)
insmod $modulefile $*
;;
*)
modprobe $modulename $*
;;
esac
[ -z "$MODULESDIR" ] && MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter:/lib/modules/$(uname -r)/kernel/net/netfilter
MODULES=$(lsmod | cut -d ' ' -f1)
break
fi
for directory in $(split $MODULESDIR); do
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
done
fi
}
#
# Reload the Modules
#
reload_kernel_modules() {
[ -z "$MODULESDIR" ] && MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
MODULES=$(lsmod | cut -d ' ' -f1)
while read command; do
eval $command
done
MODULESDIR=$save_modules_dir
}
#
@ -227,14 +204,25 @@ reload_kernel_modules() {
#
load_kernel_modules()
{
save_modules_dir=$MODULESDIR
local save_modules_dir=$MODULESDIR
local directory
local moduledirectories=
local moduleloader=modprobe
if ! qt mywhich modprobe; then
moduleloader=insmod
fi
[ -z "$MODULESDIR" ] && \
MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter:/lib/modules/$(uname -r)/kernel/net/netfilter
for directory in $(split $MODULESDIR); do
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
done
modules=$(find_file modules)
if [ -f $modules -a -d $MODULESDIR ]; then
if [ -f $modules -a -n "$moduledirectories" ]; then
MODULES=$(lsmod | cut -d ' ' -f1)
progress_message "Loading Modules..."
. $modules