Magellan Linux

Diff of /alx-src/branches/alxconf_20060908/functions/config_modules.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/trunk/alxconfig-ng/functions/config_modules.sh revision 322 by niro, Thu Sep 1 23:58:43 2005 UTC alx-src/branches/alxconf_20060908/functions/config_modules.sh revision 1721 by niro, Thu Feb 17 16:23:41 2011 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_modules.sh,v 1.3 2005-09-01 23:58:43 niro Exp $  # $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  # 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()  kernel_major_version()
6  {  {
7   local KV   local KV
8   KV="$(uname -r|cut -d. -f1-2)"   KV="$(uname -r | cut -d. -f1-2)"
9   echo "${KV}"   echo "${KV}"
10  }  }
11    
12  get_modules_settings()  get_modules_settings()
13  {  {
14   local i count mod_ids settings   local i count mod_ids settings arg
15    
16   # first get all module names   # first get all module names
17   mod_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mod_ids=$(mysqldo "select id from cfg_modules where serial='${ALX_SERIAL}'")
  "select id from cfg_modules where serial='${ALX_SERIAL}'")  
18    
19   # set counter equal to numbers of printers   # set counter equal to numbers of printers
20   declare -i count=0   declare -i count=0
21   for i in ${mod_ids}   for i in ${mod_ids}
22   do   do
23   # now get the other settings und put them in arrays   # now get the other settings und put them in arrays
24   ALX_MODULES[${count}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_MODULES[${count}]=$(mysqldo "select module from cfg_modules where id=${i};")
25   "select module from cfg_modules where id=${i};")   # 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   (( count++ ))   (( count++ ))
31   done   done
32    
33   # get network module   # get network module
34   ALX_NETWORK_MODULE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_NETWORK_MODULE=$(mysqldo "select module from cfg_network where serial=${ALX_SERIAL};")
  "select module from cfg_network where serial=${ALX_SERIAL};")  
35    
36   ## fixes needed to satisfy some deps   ## fixes needed to satisfy some deps
37   ALX_GFX_MODULE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_GFX_MODULE=$(mysqldo "select module from cfg_graphic where serial=${ALX_SERIAL};")
  "select module from cfg_graphic where serial=${ALX_SERIAL};")  
38    
39   # export all settings   # export all settings
40   export ALX_COUNT=${count}   export ALX_COUNT=${count}
41   export ALX_NETWORK_MODULE   export ALX_NETWORK_MODULE
42   export ALX_GFX_MODULE   export ALX_GFX_MODULE
43   export ALX_MODULES   export ALX_MODULES
44     export ALX_MODULES_ARG
45    }
46    
47    add_modules()
48    {
49     local modules="$@"
50     local modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)"
51     local argfile="${SETTINGSPATH}/modules-args"
52     local mod
53     local arg
54     local oldifs
55    
56     for mod in ${modules}
57     do
58     if [ -n "$(find /lib/modules/$(uname -r) -name ${mod}.[o,k]*)" ]
59     then
60     # 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     fi
72     done
73    }
74    
75    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  config_modules()  config_modules()
91  {  {
92   local i   local i
93   local modfile   local modfile
94     local argfile
95    
96   #first of all get the vars   # first of all get the vars
97   get_modules_settings   get_modules_settings
98    
99   # location of the modules.autoload file   # location of the modules.autoload file
100   modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)"   modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)"
101     # location of the modules argument file
102     argfile="${SETTINGSPATH}/modules-args"
103    
104   # write default settings:   # clear the old one
105   echo "lp" > ${modfile}   :> ${modfile}
106   [ -n "${ALX_NETWORK_MODULE}" ] && \   :> ${argfile}
107   echo "${ALX_NETWORK_MODULE}" >> ${modfile}  
108     # create a new arg file
109     create_argfile
110    
111     # needed for printing:
112     add_modules lp parport parport_pc usblp
113    
114     if [[ -n ${ALX_NETWORK_MODULE} ]]
115     then
116     add_modules "${ALX_NETWORK_MODULE}"
117     fi
118    
119   # intel i810 needs intel-agp module to work probably   # intel i810 needs intel-agp module to work probably
120   [[ ${ALX_GFX_MODULE} = i810 ]] && \   [[ ${ALX_GFX_MODULE} = i810 ]] && add_modules intel-agp
121   [ -f /lib/modules/$(uname -r)/kernel/drivers/char/agp/intel-agp.ko ] && \   [[ ${ALX_GFX_MODULE} = intel ]] && add_modules intel-agp
  echo "intel-agp" >> ${modfile}  
122    
123   for ((i=0; i <= ALX_COUNT; i++))   for ((i=0; i <= ALX_COUNT; i++))
124   do   do
125   [ -n "${ALX_MODULES[${i}]}" ] && \   if [[ -n ${ALX_MODULES[${i}]} ]]
126   echo "${ALX_MODULES[${i}]}" >> ${modfile}   then
127     add_modules "${ALX_MODULES[${i}]}"
128     fi
129   done   done
130    
131   unset ALX_COUNT   unset ALX_COUNT

Legend:
Removed from v.322  
changed lines
  Added in v.1721