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