Magellan Linux

Diff of /alx-src/tags/alxconf-0_6_4_5/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 318 by niro, Thu Sep 1 18:29:56 2005 UTC alx-src/branches/alxconf-060/functions/config_modules.sh revision 2013 by niro, Mon May 9 15:57:20 2011 UTC
# Line 1  Line 1 
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    
 kernel_major_version()  
 {  
  local KV  
  KV="$(uname -r|cut -d. -f1-2)"  
  echo "${KV}"  
 }  
   
5  get_modules_settings()  get_modules_settings()
6  {  {
7   local i count mod_ids settings   local i count mod_ids settings arg
8    
9   # first get all module names   # first get all module names
10   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}'")  
11    
12   # set counter equal to numbers of printers   # set counter equal to numbers of printers
13   declare -i count=0   declare -i count=0
14   for i in ${mod_ids}   for i in ${mod_ids}
15   do   do
16   # now get the other settings und put them in arrays   # now get the other settings und put them in arrays
17   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};")
18   "select module from cfg_modules where id=${i};")   # 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++ ))   (( count++ ))
24   done   done
25    
26   # get network module   # get network module
27   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};")  
28    
29   ## fixes needed to satisfy some deps   ## fixes needed to satisfy some deps
30   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_grafic where serial=${ALX_SERIAL};")  
31    
32   # export all settings   # export all settings
33   export ALX_COUNT=${count}   export ALX_COUNT=${count}
34   export ALX_NETWORK_MODULE   export ALX_NETWORK_MODULE
35   export ALX_GFX_MODULE   export ALX_GFX_MODULE
36   export ALX_MODULES   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     for ((i=0; i<count; i++))
75     do
76     if [[ ! -z ${ALX_MODULES_ARG[${i}]} ]]
77     then
78     echo "${ALX_MODULES[${i}]}:${ALX_MODULES_ARG[${i}]}" >> ${argfile}
79     fi
80     done
81  }  }
82    
83  config_modules()  config_modules()
84  {  {
85   local i   local i
86   local modfile   local modfile
87     local argfile
88    
89   #first of all get the vars   # first of all get the vars
90   get_modules_settings   get_modules_settings
91    
92   # location of the modules.autoload file   # location of the modules.autoload file
93   modfile="/etc/modules.autoload.d/kernel-$(kernel_major_version)"   modfile="/etc/modules.autoload"
94     # location of the modules argument file
95   # write default settings:   argfile="${SETTINGSPATH}/modules-args"
96   echo "lp" > ${modfile}  
97   [ -n "${ALX_NETWORK_MODULE}" ] && \   # clear the old one
98   echo "${ALX_NETWORK_MODULE}" >> ${modfile}   :> ${modfile}
99     :> ${argfile}
100    
101     # create a new arg file
102     create_argfile
103    
104     # needed for printing:
105     add_modules lp parport parport_pc usblp
106    
107     if [[ -n ${ALX_NETWORK_MODULE} ]]
108     then
109     add_modules "${ALX_NETWORK_MODULE}"
110     fi
111    
112   # intel i810 needs intel-agp module to work probably   # intel i810 needs intel-agp module to work probably
113   [[ ${ALX_GFX_MODULE} = i810 ]] && \   [[ ${ALX_GFX_MODULE} = i810 ]] && add_modules intel-agp
114   [ -f /lib/modules/$(uname -r)/kernel/drivers/char/agp/intel-agp.ko ] && \   [[ ${ALX_GFX_MODULE} = intel ]] && add_modules intel-agp
  echo "intel-agp" >> ${modfile}  
115    
116   for ((i=0; i <= ALX_COUNT; i++))   for ((i=0; i <= ALX_COUNT; i++))
117   do   do
118   [ -n "${ALX_MODULES[${i}]}" ] && \   if [[ -n ${ALX_MODULES[${i}]} ]]
119   echo "${ALX_MODULES[${i}]}" >> ${modfile}   then
120     add_modules "${ALX_MODULES[${i}]}"
121     fi
122   done   done
123    
124   unset ALX_COUNT   unset ALX_COUNT

Legend:
Removed from v.318  
changed lines
  Added in v.2013