Magellan Linux

Contents of /alx-src/branches/alxconf-060/functions/config_modules.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2121 - (show annotations) (download) (as text)
Mon May 16 11:07:22 2011 UTC (12 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2693 byte(s)
-clear argfile in create argfile function
1 # $Id$
2 # configures printing on the host via mysql db settings
3 # Note must be the first configure script which will be startet
4
5 get_modules_settings()
6 {
7 local i count mod_ids settings arg
8
9 # first get all module names
10 mod_ids=$(mysqldo "select id from cfg_modules where serial='${ALX_SERIAL}'")
11
12 # set counter equal to numbers of printers
13 declare -i count=0
14 for i in ${mod_ids}
15 do
16 # now get the other settings und put them in arrays
17 ALX_MODULES[${count}]=$(mysqldo "select module from cfg_modules where id=${i};")
18 # get modules arguments
19 arg=$(mysqldo "select arg from cfg_modules where id=${i};")
20 # handle Nulls
21 [[ ${arg} = NULL ]] && arg=""
22 ALX_MODULES_ARG[${count}]="${arg}"
23 (( count++ ))
24 done
25
26 # get network module
27 ALX_NETWORK_MODULE=$(mysqldo "select module from cfg_network where serial=${ALX_SERIAL};")
28
29 ## fixes needed to satisfy some deps
30 ALX_GFX_MODULE=$(mysqldo "select module from cfg_graphic where serial=${ALX_SERIAL};")
31
32 # export all settings
33 export ALX_COUNT=${count}
34 export ALX_NETWORK_MODULE
35 export ALX_GFX_MODULE
36 export ALX_MODULES
37 export ALX_MODULES_ARG
38 }
39
40 add_modules()
41 {
42 local modules="$@"
43 local modfile="/etc/modules.autoload"
44 local argfile="${SETTINGSPATH}/modules-args"
45 local mod
46 local arg
47 local oldifs
48
49 for mod in ${modules}
50 do
51 if [ -n "$(find /lib/modules/$(uname -r) -name ${mod}.[o,k]*)" ]
52 then
53 # get the args
54 arg="$(grep ^${mod}: ${argfile})"
55
56 # extract the arguments
57 if [[ -n ${arg} ]]
58 then
59 arg="${arg##*:}"
60 echo "${mod} ${arg}" >> ${modfile}
61 else
62 echo "${mod}" >> ${modfile}
63 fi
64 fi
65 done
66 }
67
68 create_argfile()
69 {
70 local argfile="${SETTINGSPATH}/modules-args"
71 local count="${#ALX_MODULES[*]}"
72 local i
73
74 :> ${argfile}
75
76 for ((i=0; i<count; i++))
77 do
78 if [[ ! -z ${ALX_MODULES_ARG[${i}]} ]]
79 then
80 echo "${ALX_MODULES[${i}]}:${ALX_MODULES_ARG[${i}]}" >> ${argfile}
81 fi
82 done
83 }
84
85 config_modules()
86 {
87 local i
88 local modfile
89 local argfile
90
91 # first of all get the vars
92 get_modules_settings
93
94 # location of the modules.autoload file
95 modfile="/etc/modules.autoload"
96
97 # clear the old one
98 :> ${modfile}
99
100 # create a new arg file
101 create_argfile
102
103 # needed for printing:
104 add_modules lp parport parport_pc usblp
105
106 if [[ -n ${ALX_NETWORK_MODULE} ]]
107 then
108 add_modules "${ALX_NETWORK_MODULE}"
109 fi
110
111 # intel i810 needs intel-agp module to work probably
112 [[ ${ALX_GFX_MODULE} = i810 ]] && add_modules intel-agp
113 [[ ${ALX_GFX_MODULE} = intel ]] && add_modules intel-agp
114
115 for ((i=0; i <= ALX_COUNT; i++))
116 do
117 if [[ -n ${ALX_MODULES[${i}]} ]]
118 then
119 add_modules "${ALX_MODULES[${i}]}"
120 fi
121 done
122
123 unset ALX_COUNT
124 unset ALX_MODULES
125 unset ALX_NETWORK_MODULE
126 unset ALX_GFX_MODULE
127 }