# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_modules.sh,v 1.6 2005-10-09 21:28:46 niro Exp $ # configures printing on the host via mysql db settings # Note must be the first configure script which will be startet kernel_major_version() { local KV KV="$(uname -r | cut -d. -f1-2)" echo "${KV}" } get_modules_settings() { local i count mod_ids settings arg # first get all module names mod_ids=$(mysqldo "select id from cfg_modules where serial='${ALX_SERIAL}'") # set counter equal to numbers of printers declare -i count=0 for i in ${mod_ids} do # now get the other settings und put them in arrays ALX_MODULES[${count}]=$(mysqldo "select module from cfg_modules where id=${i};") # get modules arguments arg=$(mysqldo "select arg from cfg_modules where id=${i};") # handle Nulls [[ ${arg} = NULL ]] && arg="" ALX_MODULES_ARG[${count}]="${arg}" (( count++ )) done # get network module ALX_NETWORK_MODULE=$(mysqldo "select module from cfg_network where serial=${ALX_SERIAL};") ## fixes needed to satisfy some deps ALX_GFX_MODULE=$(mysqldo "select module from cfg_graphic where serial=${ALX_SERIAL};") # export all settings export ALX_COUNT=${count} export ALX_NETWORK_MODULE export ALX_GFX_MODULE export ALX_MODULES export ALX_MODULES_ARG } add_modules() { local modules="$@" local modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)" local argfile="${SETTINGSPATH}/modules-args" local mod local arg local oldifs for mod in ${modules} do if [ -n "$(find /lib/modules/$(uname -r) -name ${mod}.[o,k]*)" ] then # get the args arg="$(grep ^${mod}: ${argfile})" # extract the arguments if [[ -n ${arg} ]] then arg="${arg##*:}" echo "${mod} ${arg}" >> ${modfile} else echo "${mod}" >> ${modfile} fi fi done } create_argfile() { local argfile="${SETTINGSPATH}/modules-args" local count="${#ALX_MODULES[*]}" local i for ((i=0; i> ${argfile} fi done } config_modules() { local i local modfile local argfile # first of all get the vars get_modules_settings # location of the modules.autoload file modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)" # location of the modules argument file argfile="${SETTINGSPATH}/modules-args" # clear the old one :> ${modfile} :> ${argfile} # create a new arg file create_argfile # needed for printing: add_modules lp parport parport_pc usblp if [[ -n ${ALX_NETWORK_MODULE} ]] then add_modules "${ALX_NETWORK_MODULE}" fi # intel i810 needs intel-agp module to work probably [[ ${ALX_GFX_MODULE} = i810 ]] && add_modules intel-agp [[ ${ALX_GFX_MODULE} = intel ]] && add_modules intel-agp for ((i=0; i <= ALX_COUNT; i++)) do if [[ -n ${ALX_MODULES[${i}]} ]] then add_modules "${ALX_MODULES[${i}]}" fi done unset ALX_COUNT unset ALX_MODULES unset ALX_NETWORK_MODULE unset ALX_GFX_MODULE }