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 |
get_modules_settings() |
add_module() |
6 |
{ |
{ |
7 |
local i count mod_ids settings arg |
local module="$1" |
8 |
|
local arg="$2" |
9 |
|
|
10 |
# first get all module names |
if [ -n "$(find /lib/modules/$(uname -r) -name ${mod}.[o,k]*)" ] |
11 |
mod_ids=$(mysqldo "select id from cfg_modules where serial='${ALX_SERIAL}'") |
then |
12 |
|
if [[ -z ${arg} ]] |
|
# 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" |
|
|
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]*)" ] |
|
13 |
then |
then |
14 |
# get the args |
addconfig "${module}" |
15 |
arg="$(grep ^${mod}: ${argfile})" |
else |
16 |
|
addconfig "${mod} ${arg}" |
|
# extract the arguments |
|
|
if [[ -n ${arg} ]] |
|
|
then |
|
|
arg="${arg##*:}" |
|
|
echo "${mod} ${arg}" >> ${modfile} |
|
|
else |
|
|
echo "${mod}" >> ${modfile} |
|
|
fi |
|
17 |
fi |
fi |
18 |
done |
done |
19 |
} |
} |
20 |
|
|
21 |
create_argfile() |
config_modules() |
22 |
{ |
{ |
23 |
local argfile="${SETTINGSPATH}/modules-args" |
local all_ids |
|
local count="${#ALX_MODULES[*]}" |
|
24 |
local i |
local i |
25 |
|
local CONFIG |
26 |
|
|
27 |
:> ${argfile} |
# first of all ids |
28 |
|
all_ids=$(mysqldo "select id from cfg_modules where serial='${ALX_SERIAL}'") |
29 |
|
|
30 |
for ((i=0; i<count; i++)) |
# get network module |
31 |
do |
evaluate_table cfg_network |
|
if [[ ! -z ${ALX_MODULES_ARG[${i}]} ]] |
|
|
then |
|
|
echo "${ALX_MODULES[${i}]}:${ALX_MODULES_ARG[${i}]}" >> ${argfile} |
|
|
fi |
|
|
done |
|
|
} |
|
|
|
|
|
config_modules() |
|
|
{ |
|
|
local i |
|
|
local modfile |
|
|
local argfile |
|
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" |
CONFIG="/etc/modules.autoload" |
38 |
|
|
39 |
# clear the old one |
# clear the old one |
40 |
:> ${modfile} |
clearconfig |
41 |
|
|
|
# create a new arg file |
|
|
create_argfile |
|
|
|
|
42 |
# needed for printing: |
# needed for printing: |
43 |
add_modules lp parport parport_pc usblp |
add_module lp |
44 |
|
add_module parport |
45 |
|
add_module parport_pc |
46 |
|
add_module usblp |
47 |
|
|
48 |
if [[ -n ${ALX_NETWORK_MODULE} ]] |
if [[ -n ${cfg_network_module} ]] |
49 |
then |
then |
50 |
add_modules "${ALX_NETWORK_MODULE}" |
add_module "${cfg_network_module}" |
51 |
fi |
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 ]] && add_modules intel-agp |
case ${cfg_graphic_module} in |
55 |
[[ ${ALX_GFX_MODULE} = intel ]] && add_modules intel-agp |
i810) add_module intel-agp ;; |
56 |
|
intel) add_module intel-agp ;; |
57 |
|
esac |
58 |
|
|
59 |
for ((i=0; i <= ALX_COUNT; i++)) |
for i in ${all_ids} |
60 |
do |
do |
61 |
if [[ -n ${ALX_MODULES[${i}]} ]] |
evaluate_table cfg_modules "where serial='${ALX_SERIAL}' and id='${i}'" |
62 |
|
if [[ -n ${cfg_modules_module} ]] |
63 |
then |
then |
64 |
add_modules "${ALX_MODULES[${i}]}" |
add_module "${cfg_modules_module}" "${cfg_modules_arg}" |
65 |
fi |
fi |
66 |
done |
done |
|
|
|
|
unset ALX_COUNT |
|
|
unset ALX_MODULES |
|
|
unset ALX_NETWORK_MODULE |
|
|
unset ALX_GFX_MODULE |
|
67 |
} |
} |