Magellan Linux

Diff of /trunk/installer/hwdetection.sh

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

revision 572 by niro, Thu Sep 6 10:35:46 2007 UTC revision 596 by niro, Mon Oct 15 20:49:40 2007 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Header: /home/cvsd/magellan-cvs/magellan-src/installer/hwdetection.sh,v 1.7 2007-10-15 20:49:40 niro Exp $
3    
4  ## hwdetection, needs >= sys-apps/hwinfo  ## hwdetection, needs >= sys-apps/hwinfo
5    
6    # hwinfo wrapper to use hwinfo with sudo if requested
7    hwinfo()
8    {
9     local use_sudo=""
10     case ${SUDO} in
11     yes|y|true|1) use_sudo=sudo ;;
12     esac
13    
14     ${use_sudo} /usr/sbin/hwinfo $@
15    }
16    
17  # get_hwinfo $hw_item  # get_hwinfo $hw_item
18  get_hwinfo()  get_hwinfo()
19  {  {
20     local enable_desc="0"
21    
22     if [[ $1 = --with-description ]] || [[ $1 = -d ]]
23     then
24     enable_desc=1
25     shift
26     fi
27    
28   local item="$1"   local item="$1"
29   local all   local all
30   local i   local i
31    
32     # handle special items
33     case ${item} in
34     memory) get_hwinfo_memory; return ;;
35     smp) get_hwinfo_smp; return ;;
36     esac
37    
38   all=$(hwinfo --short --"${item}")   all=$(hwinfo --short --"${item}")
39    
40   declare -i i=0   declare -i i=0
# Line 17  get_hwinfo() Line 44  get_hwinfo()
44   (( i++ ))   (( i++ ))
45   [ ${i} -eq 1 ] && continue   [ ${i} -eq 1 ] && continue
46    
47   echo "${device};${description}"   if [[ ${enable_desc} = 1 ]]
48     then
49     echo "${device};${description}"
50     else
51     echo "${device}"
52     fi
53   done <<< "${all}"   done <<< "${all}"
54  }  }
55    
56    
57    # special memory case
58    get_hwinfo_memory()
59    {
60     local memory=$(hwinfo --memory  | grep "Memory Size" | cut -d: -f2 | sed "s:\ ::")
61     echo "${memory}"
62    }
63    
64    
65    # special smp case
66    get_hwinfo_smp()
67    {
68     local smp=$(hwinfo --smp  | grep "SMP support:" | cut -d: -f2 | sed "s:\ ::")
69     echo "${smp}"
70    }
71    
72    
73  # get_driver_modules $hw_item  # get_driver_modules $hw_item
74  get_driver_modules()  get_driver_modules()
75  {  {
# Line 44  get_driver_modules() Line 93  get_driver_modules()
93   local i   local i
94   for i in $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 )   for i in $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 )
95   do   do
96   eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:\",\ \":\ :")   eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :")
97   done   done
98   echo "${modules}"   echo "${modules}"
99  }  }
# Line 65  remove_duplicates() Line 114  remove_duplicates()
114   done   done
115    
116   # remove all ':' and show the cleaned list   # remove all ':' and show the cleaned list
117   echo "${fixed_list}" | sed "s|:| |g"   # this way fixes double spaces also
118     for i in $(echo ${fixed_list} | sed "s|:| |g")
119     do
120     echo "${i}"
121     done
122  }  }
123    
124  get_x11_driver_modules()  get_x11_driver_modules()
# Line 147  create_initrd() Line 200  create_initrd()
200  #get_driver_modules all  #get_driver_modules all
201    
202  # network  # network
203  #get_hwinfo netcard  #get_hwinfo --with-description netcard
204  #get_driver_modules netcard  #get_driver_modules netcard
205    
206  #get_hwinfo disk  #get_hwinfo disk

Legend:
Removed from v.572  
changed lines
  Added in v.596