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 319 by niro, Tue Jan 3 18:07:43 2006 UTC revision 428 by niro, Sun Mar 4 13:24:34 2007 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.7 2006-01-03 18:07:43 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.13 2007-03-04 13:24:34 niro Exp $
3    
4  source /etc/sysconfig/rc  source /etc/sysconfig/rc
5  source $rc_functions  source $rc_functions
# Line 26  udev_version() Line 26  udev_version()
26   echo "${version}"   echo "${version}"
27  }  }
28    
 # this works only for 2.6.15 kernels and greater  
 trigger_events()  
 {  
  local list=""  
  local i  
  local first  
  local last  
  local default  
   
  # if you want real hotplug (with all modules being loaded for all  
  # devices in the system), uncomment out the next line.  
  #list="$list $(echo /sys/bus/*/devices/*/uevent)"  
  list="${list} $(echo /sys/class/*/*/uevent)"  
  list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"  
  for i in ${list}  
  do  
  case "${i}" in  
  */device/uevent)  
  # skip followed device symlinks  
  continue  
  ;;  
  */class/mem/*|*/class/tty/*)  
  first="${first} ${i}"  
  ;;  
  */block/md*)  
  last="${last} ${i}"  
  ;;  
  */*)  
  default="${default} ${i}"  
  ;;  
  esac  
  done  
   
  # trigger the sorted events  
  for i in ${first} ${default} ${last}  
  do  
  echo "add" > "${i}"  
  done  
 }  
   
29  populate_udev()  populate_udev()
30  {  {
31   local loop   local opts
32    
33     # tell modprobe.sh to be verbose to $CONSOLE
34     echo CONSOLE=${CONSOLE} > /dev/.udev_populate
35    
36   # populate /dev with devices already found by the kernel   # populate /dev with devices already found by the kernel
37   if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
38   then   then
39   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."
40   trigger_events   [[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev"
41     /sbin/udevtrigger ${opts}
42   evaluate_retval   evaluate_retval
43   else   else
44   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."
# Line 83  populate_udev() Line 47  populate_udev()
47   fi   fi
48    
49   # loop until everything is finished   # loop until everything is finished
  # there's gotta be a better way...  
50   echo -e ${COLOREDSTAR}"  Letting udev process events ..."   echo -e ${COLOREDSTAR}"  Letting udev process events ..."
51   loop=0   /sbin/udevsettle --timeout=60
  while test -d /dev/.udev/queue  
  do  
  sleep 0.1;  
  test "${loop}" -gt 300 && break  
  loop=$((${loop} + 1))  
  done  
52   evaluate_retval   evaluate_retval
53    
54     rm -f /dev/.udev_populate
55   return 0   return 0
56  }  }
57    
# Line 102  seed_dev() Line 60  seed_dev()
60   # seed /dev with some things that we know we need   # seed /dev with some things that we know we need
61   echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."   echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."
62   (   (
63     [ ! -c /dev/console ] && mknod /dev/console c 5 1
64     [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1
65     [ ! -c /dev/null ] && mknod /dev/null c 1 3
66    
67   # copy over any persistant things   # copy over any persistant things
68   cp --preserve=all --recursive --update /lib/udev/devices/* /dev   if [[ -d /lib/udev/devices ]]
69     then
70     cp --preserve=all --recursive --update /lib/udev/devices/* /dev
71     fi
72    
73   # not provided by sysfs but needed   # not provided by sysfs but needed
74   ln -snf /proc/self/fd /dev/fd   ln -snf /proc/self/fd /dev/fd
75   ln -snf fd/0 /dev/stdin   ln -snf fd/0 /dev/stdin
# Line 118  seed_dev() Line 83  seed_dev()
83   evaluate_retval   evaluate_retval
84  }  }
85    
 # # some needed functions functions  
 # populate_udev() {  
 # /sbin/udevstart  
 #  
 # # not provided by sysfs but needed  
 # ln -snf /proc/self/fd /dev/fd  
 # ln -snf fd/0 /dev/stdin  
 # ln -snf fd/1 /dev/stdout  
 # ln -snf fd/2 /dev/stderr  
 # ln -snf /proc/kcore /dev/core  
 # ln -snf /proc/asound/oss/sndstat /dev/sndstat  
 #  
 # # create problematic directories  
 # mkdir -p /dev/{pts,shm}  
 #  
 # # same as /dev/.devfsd  
 # touch /dev/.udev  
 #  
 # return 0  
 # }  
   
86  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
87    
88  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
# Line 147  if [[ $runlevel = sysinit ]] Line 91  if [[ $runlevel = sysinit ]]
91  then  then
92   echo   echo
93   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
94   echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net"   echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net"
95   echo   echo
96    
97   # mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
# Line 215  then Line 159  then
159   # load udev only with a 2.6 kernel   # load udev only with a 2.6 kernel
160   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]
161   then   then
162     # check if /dev/console exists outside tmpfs
163     [ -c /dev/console ] ; need_redirect=$?
164    
165   # create a ramdisk for populating udev   # create a ramdisk for populating udev
166   echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."   echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."
  # tmpfs was suggested by Greg Kroah-Hartman  
167   # many video drivers needed exec access   # many video drivers needed exec access
168   mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755   fstype=ramfs
169     # tmpfs was suggested by Greg Kroah-Hartman
170     kernel_supports_fs tmpfs && fstype=tmpfs
171     mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755
172   evaluate_retval   evaluate_retval
173    
174   # if a device tarball exists load it and if it is activated   # if a device tarball exists load it and if it is activated
# Line 236  then Line 185  then
185    
186   if [ -e /proc/sys/kernel/hotplug ]   if [ -e /proc/sys/kernel/hotplug ]
187   then   then
188   if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
189   then   then
190   echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."   echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."
191   echo "" > /proc/sys/kernel/hotplug   echo "" > /proc/sys/kernel/hotplug
192   evaluate_retval   evaluate_retval
193   elif [[ $(udev_version) -ge "48" ]]   else
  then  
194   echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."   echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."
195   echo "/sbin/udevsend" > /proc/sys/kernel/hotplug   echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
196   evaluate_retval   evaluate_retval
  elif [[ -x /sbin/hotplug ]]  
  then  
  echo -e ${COLOREDSTAR}"  Using /sbin/hotplug as hotplug agent ..."  
  print_status success  
  else  
  echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."  
  echo "/sbin/udev" > /proc/sys/kernel/hotplug  
  evaluate_retval  
197   fi   fi
198   else   else
199   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"
# Line 261  then Line 201  then
201   fi   fi
202    
203   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."
204   /sbin/udevd --daemon   if [ ${need_redirect} -eq 1 ]
205     then
206     # we need to open fds 0 1 2
207     /sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console
208     else
209     /sbin/udevd --daemon
210     fi
211   evaluate_retval   evaluate_retval
212    
213   populate_udev   populate_udev

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