1 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_modules.sh,v 1.2 2005-09-01 18:29:56 niro Exp $ |
# $Id$ |
2 |
# configures printing on the host via mysql db settings |
# configures printing on the host via mysql db settings |
3 |
# Note must be the first configure script which will be startet |
# Note must be the first configure script which will be startet |
4 |
|
|
5 |
kernel_major_version() |
add_module() |
6 |
{ |
{ |
7 |
local KV |
local module="$1" |
8 |
KV="$(uname -r|cut -d. -f1-2)" |
local arg="$2" |
|
echo "${KV}" |
|
|
} |
|
|
|
|
|
get_modules_settings() |
|
|
{ |
|
|
local i count mod_ids settings |
|
|
|
|
|
# first get all module names |
|
|
mod_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"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}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select module from cfg_modules where id=${i};") |
|
|
|
|
|
(( count++ )) |
|
|
done |
|
|
|
|
|
# get network module |
|
|
ALX_NETWORK_MODULE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select module from cfg_network where serial=${ALX_SERIAL};") |
|
9 |
|
|
10 |
## fixes needed to satisfy some deps |
if [ -n "$(find /lib/modules/$(uname -r) -name ${mod}.[o,k]*)" ] |
11 |
ALX_GFX_MODULE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
then |
12 |
"select module from cfg_grafic where serial=${ALX_SERIAL};") |
if [[ -z ${arg} ]] |
13 |
|
then |
14 |
# export all settings |
addconfig "${module}" |
15 |
export ALX_COUNT=${count} |
else |
16 |
export ALX_NETWORK_MODULE |
addconfig "${mod} ${arg}" |
17 |
export ALX_GFX_MODULE |
fi |
18 |
export ALX_MODULES |
fi |
19 |
} |
} |
20 |
|
|
21 |
config_modules() |
config_modules() |
22 |
{ |
{ |
23 |
|
local all_ids |
24 |
local i |
local i |
25 |
local modfile |
local CONFIG |
26 |
|
|
27 |
|
# first of all ids |
28 |
|
all_ids=$(mysqldo "select id from cfg_modules where serial='${ALX_SERIAL}'") |
29 |
|
|
30 |
|
# get network module |
31 |
|
evaluate_table cfg_network |
32 |
|
|
33 |
#first of all get the vars |
# get graphic module |
34 |
get_modules_settings |
evaluate_table cfg_graphic |
35 |
|
|
36 |
# location of the modules.autoload file |
# location of the modules.autoload file |
37 |
modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)" |
CONFIG="/etc/modules.autoload" |
38 |
|
|
39 |
# write default settings: |
# clear the old one |
40 |
echo "lp" > ${modfile} |
clearconfig |
41 |
[ -n "${ALX_NETWORK_MODULE}" ] && \ |
|
42 |
echo "${ALX_NETWORK_MODULE}" >> ${modfile} |
# needed for printing: |
43 |
|
add_module lp |
44 |
|
add_module parport |
45 |
|
add_module parport_pc |
46 |
|
add_module usblp |
47 |
|
|
48 |
|
if [[ -n ${cfg_network_module} ]] |
49 |
|
then |
50 |
|
add_module "${cfg_network_module}" |
51 |
|
fi |
52 |
|
|
53 |
# intel i810 needs intel-agp module to work probably |
# intel i810 needs intel-agp module to work probably |
54 |
[[ ${ALX_GFX_MODULE} = i810 ]] && \ |
case ${cfg_graphic_module} in |
55 |
[ -f /lib/modules/$(uname -r)/kernel/drivers/char/agp/intel-agp.ko ] && \ |
i810) add_module intel-agp ;; |
56 |
echo "intel-agp" >> ${modfile} |
intel) add_module intel-agp ;; |
57 |
|
esac |
|
for ((i=0; i <= ALX_COUNT; i++)) |
|
|
do |
|
|
[ -n "${ALX_MODULES[${i}]}" ] && \ |
|
|
echo "${ALX_MODULES[${i}]}" >> ${modfile} |
|
|
done |
|
58 |
|
|
59 |
unset ALX_COUNT |
for i in ${all_ids} |
60 |
unset ALX_MODULES |
do |
61 |
unset ALX_NETWORK_MODULE |
evaluate_table cfg_modules "where serial='${ALX_SERIAL}' and id='${i}'" |
62 |
unset ALX_GFX_MODULE |
if [[ -n ${cfg_modules_module} ]] |
63 |
|
then |
64 |
|
add_module "${cfg_modules_module}" "${cfg_modules_arg}" |
65 |
|
fi |
66 |
|
done |
67 |
} |
} |