Magellan Linux

Diff of /trunk/magellan-initscripts/etc/rc.d/init.d/rc

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

revision 150 by niro, Sun Jul 3 21:34:35 2005 UTC revision 376 by niro, Mon May 29 21:25:45 2006 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.5 2005-07-03 21:34:35 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.9 2006-05-29 21:25:45 niro Exp $
3    
4  source /etc/sysconfig/rc  source /etc/sysconfig/rc
5  source $rc_functions  source $rc_functions
# Line 10  MAGEVER="$(< /etc/mageversion)" Line 10  MAGEVER="$(< /etc/mageversion)"
10  # source kernel config if exists  # source kernel config if exists
11  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
12    
13  # some needed functions functions  udev_version()
14  populate_udev() {  {
15     local version=0
16    
17     if [[ -x /sbin/udev ]]
18     then
19     version=$(/sbin/udev -V)
20     # We need it without a leading '0', else bash do the wrong thing
21     version=${version##0}
22     # Older udev's will print nothing
23     [[ -z ${version} ]] && version=0
24     fi
25    
26     echo "${version}"
27    }
28    
29    # this works only for 2.6.15 kernels and greater
30    trigger_events()
31    {
32     local list=""
33     local i
34     local first
35     local last
36     local default
37    
38     # if you want real hotplug (with all modules being loaded for all
39     # devices in the system), uncomment out the next line.
40     #list="$list $(echo /sys/bus/*/devices/*/uevent)"
41     list="${list} $(echo /sys/class/*/*/uevent)"
42     list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
43     for i in ${list}
44     do
45     case "${i}" in
46     */device/uevent)
47     # skip followed device symlinks
48     continue
49     ;;
50     */class/mem/*|*/class/tty/*)
51     first="${first} ${i}"
52     ;;
53     */block/md*)
54     last="${last} ${i}"
55     ;;
56     */*)
57     default="${default} ${i}"
58     ;;
59     esac
60     done
61    
62     # trigger the sorted events
63     for i in ${first} ${default} ${last}
64     do
65     echo "add" > "${i}"
66     done
67    }
68    
69    populate_udev()
70    {
71     local loop
72    
73     # populate /dev with devices already found by the kernel
74     if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
75     then
76     echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."
77     trigger_events
78     evaluate_retval
79     else
80     echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."
81   /sbin/udevstart   /sbin/udevstart
82     evaluate_retval
83     fi
84    
85     # loop until everything is finished
86     # there's gotta be a better way...
87     echo -e ${COLOREDSTAR}"  Letting udev process events ..."
88     loop=0
89     while test -d /dev/.udev/queue
90     do
91     sleep 0.1;
92     test "${loop}" -gt 300 && break
93     loop=$((${loop} + 1))
94     done
95     evaluate_retval
96    
97     return 0
98    }
99    
100    seed_dev()
101    {
102     # seed /dev with some things that we know we need
103     echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."
104     (
105     # copy over any persistant things
106     cp --preserve=all --recursive --update /lib/udev/devices/* /dev
107    
108   # not provided by sysfs but needed   # not provided by sysfs but needed
109   ln -snf /proc/self/fd /dev/fd   ln -snf /proc/self/fd /dev/fd
110   ln -snf fd/0 /dev/stdin   ln -snf fd/0 /dev/stdin
111   ln -snf fd/1 /dev/stdout   ln -snf fd/1 /dev/stdout
112   ln -snf fd/2 /dev/stderr   ln -snf fd/2 /dev/stderr
113   ln -snf /proc/kcore /dev/core   [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
114   ln -snf /proc/asound/oss/sndstat /dev/sndstat  
   
115   # create problematic directories   # create problematic directories
116   mkdir -p /dev/{pts,shm}   mkdir -p /dev/{pts,shm}
117     )
118   # same as /dev/.devfsd   evaluate_retval
  touch /dev/.udev  
   
  return 0  
119  }  }
120    
121  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
# Line 39  if [[ $runlevel = sysinit ]] Line 126  if [[ $runlevel = sysinit ]]
126  then  then
127   echo   echo
128   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
129   echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net"   echo -e "Copyright 2001-2006 Niels Rogalla; http://magellan-linux.net"
130   echo   echo
131    
132   # mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
# Line 118  then Line 205  then
205   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
206   if [[ ${RC_DEVICE_TARBALL} = yes ]]   if [[ ${RC_DEVICE_TARBALL} = yes ]]
207   then   then
208   echo -e ${COLOREDSTAR}"  Populating /dev with with device nodes ..."   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."
209   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
210   evaluate_retval   evaluate_retval
211   fi   fi
212    
213   # now load udev   # other eeded device nodes with udev
214   populate_udev   seed_dev
   
  # if hotplug support exists in the kernel use it to manage udev  
  if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]  
  then  
  echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."  
215    
216   elif [ -e /proc/sys/kernel/hotplug ]   if [ -e /proc/sys/kernel/hotplug ]
217   then   then
218   echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
219   echo "/sbin/udev" > /proc/sys/kernel/hotplug   then
220     echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."
221     echo "" > /proc/sys/kernel/hotplug
222     evaluate_retval
223     elif [[ $(udev_version) -ge "48" ]]
224     then
225     echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."
226     echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
227     evaluate_retval
228     elif [[ -x /sbin/hotplug ]]
229     then
230     echo -e ${COLOREDSTAR}"  Using /sbin/hotplug as hotplug agent ..."
231     print_status success
232     else
233     echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."
234     echo "/sbin/udev" > /proc/sys/kernel/hotplug
235     evaluate_retval
236     fi
237   else   else
238   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"
239     print_status failure
240   fi   fi
241    
242     echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."
243     /sbin/udevd --daemon
244   evaluate_retval   evaluate_retval
245    
246     populate_udev
247    
248     # create nodes that udev can't
249     echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."
250     [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
251     [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
252     [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null
253     print_status success
254    
255     # same thing as /dev/.devfsd
256     touch /dev/.udev
257   fi   fi
258    
259   ## load devpts ##   ## load devpts ##

Legend:
Removed from v.150  
changed lines
  Added in v.376