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 319 by niro, Tue Jan 3 18:07:43 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.7 2006-01-03 18:07:43 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')" -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    # # some needed functions functions
122    # populate_udev() {
123    # /sbin/udevstart
124    #
125    # # not provided by sysfs but needed
126    # ln -snf /proc/self/fd /dev/fd
127    # ln -snf fd/0 /dev/stdin
128    # ln -snf fd/1 /dev/stdout
129    # ln -snf fd/2 /dev/stderr
130    # ln -snf /proc/kcore /dev/core
131    # ln -snf /proc/asound/oss/sndstat /dev/sndstat
132    #
133    # # create problematic directories
134    # mkdir -p /dev/{pts,shm}
135    #
136    # # same as /dev/.devfsd
137    # touch /dev/.udev
138    #
139    # return 0
140    # }
141    
142  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
143    
144  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
# Line 118  then Line 226  then
226   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
227   if [[ ${RC_DEVICE_TARBALL} = yes ]]   if [[ ${RC_DEVICE_TARBALL} = yes ]]
228   then   then
229   echo -e ${COLOREDSTAR}"  Populating /dev with with device nodes ..."   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."
230   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
231   evaluate_retval   evaluate_retval
232   fi   fi
233    
234   # now load udev   # other eeded device nodes with udev
235   populate_udev   seed_dev
236    
237   # if hotplug support exists in the kernel use it to manage udev   if [ -e /proc/sys/kernel/hotplug ]
  if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]  
238   then   then
239   echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."   if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]
240     then
241   elif [ -e /proc/sys/kernel/hotplug ]   echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."
242   then   echo "" > /proc/sys/kernel/hotplug
243   echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."   evaluate_retval
244   echo "/sbin/udev" > /proc/sys/kernel/hotplug   elif [[ $(udev_version) -ge "48" ]]
245     then
246     echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."
247     echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
248     evaluate_retval
249     elif [[ -x /sbin/hotplug ]]
250     then
251     echo -e ${COLOREDSTAR}"  Using /sbin/hotplug as hotplug agent ..."
252     print_status success
253     else
254     echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."
255     echo "/sbin/udev" > /proc/sys/kernel/hotplug
256     evaluate_retval
257     fi
258   else   else
259   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"
260     print_status failure
261   fi   fi
262    
263     echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."
264     /sbin/udevd --daemon
265   evaluate_retval   evaluate_retval
266    
267     populate_udev
268    
269     # create nodes that udev can't
270     echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."
271     [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
272     [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
273     [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null
274     print_status success
275    
276     # same thing as /dev/.devfsd
277     touch /dev/.udev
278   fi   fi
279    
280   ## load devpts ##   ## load devpts ##

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