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 783 by niro, Mon Dec 22 22:09:33 2008 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.23 2008-12-22 22:09:33 niro Exp $
3    
4  source /etc/sysconfig/rc  source /etc/conf.d/rc
5  source $rc_functions  source ${rc_functions}
6    
7    # load udev helper functions
8    source ${rc_base}/init.d/udev
9    
10  # get mage version  # get mage version
11  MAGEVER="$(< /etc/mageversion)"  MAGEVER="$(< /etc/mageversion)"
# Line 10  MAGEVER="$(< /etc/mageversion)" Line 13  MAGEVER="$(< /etc/mageversion)"
13  # source kernel config if exists  # source kernel config if exists
14  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
15    
 udev_version()  
 {  
  local version=0  
   
  if [[ -x /sbin/udev ]]  
  then  
  version=$(/sbin/udev -V)  
  # We need it without a leading '0', else bash do the wrong thing  
  version=${version##0}  
  # Older udev's will print nothing  
  [[ -z ${version} ]] && version=0  
  fi  
   
  echo "${version}"  
 }  
   
 # 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  
 }  
   
 populate_udev()  
 {  
  local loop  
   
  # populate /dev with devices already found by the kernel  
  if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]  
  then  
  echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."  
  trigger_events  
  evaluate_retval  
  else  
  echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."  
  /sbin/udevstart  
  evaluate_retval  
  fi  
   
  # loop until everything is finished  
  # there's gotta be a better way...  
  echo -e ${COLOREDSTAR}"  Letting udev process events ..."  
  loop=0  
  while test -d /dev/.udev/queue  
  do  
  sleep 0.1;  
  test "${loop}" -gt 300 && break  
  loop=$((${loop} + 1))  
  done  
  evaluate_retval  
   
  return 0  
 }  
   
 seed_dev()  
 {  
  # seed /dev with some things that we know we need  
  echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."  
  (  
  # copy over any persistant things  
  cp --preserve=all --recursive --update /lib/udev/devices/* /dev  
   
  # 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  
  [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core  
   
  # create problematic directories  
  mkdir -p /dev/{pts,shm}  
  )  
  evaluate_retval  
 }  
   
 # # 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  
 # }  
   
16  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
17    
18  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
# Line 147  if [[ $runlevel = sysinit ]] Line 21  if [[ $runlevel = sysinit ]]
21  then  then
22   echo   echo
23   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
24   echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net"   echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net"
25   echo   echo
26    
27   # mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
# Line 163  then Line 37  then
37   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
38   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
39    
40   # mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev
41   if [[ $(kernel_major_version) = 2.6 ]]   if [ -d /sys ]
42   then   then
43   if [ -d /sys ]   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."
44   then   mount -n -t sysfs sysfs /sys
45   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   evaluate_retval
46   mount -n -t sysfs sysfs /sys   else
47   evaluate_retval   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
48   else   echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
49   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."
  echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."  
  echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."  
  fi  
50   fi   fi
51    
  ## load devfs ##  
  # load devfs only with a 2.4 kernel or its really wanted with a 2.6  
  if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]]  
  then  
  # start devfsd daemon, needed for bootsplash;  
  # no use of '/etc/rc.d/init.d/devfs' anymore  
  # check if devfs was mounted by the kernel,  
  # if not mount it (mbuild_livecd needs this one)  
  if [ ! -e /dev/.devfsd ]  
  then  
  echo -e ${COLOREDSTAR}"Mounting devfs file system ..."  
  mount -n -t devfs devfs /dev  
  evaluate_retval  
  fi  
   
  if [ -e /dev/.devfsd ]  
  then  
  echo -e ${COLOREDSTAR}"Starting devfsd ..."  
  ## directory /lib/dev-state !must! exists ##  
  /sbin/devfsd /dev &> /dev/null  
  evaluate_retval  
  else  
  echo -e ${COLRED}"No devfs filesystem found ..."  
  echo -e ${COLYELLOW}"Your Kernel doesn't support the devfs filesystem."  
  echo -e ${COLYELLOW}"Devfs is necessary to run Magellan-Linux."  
  echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel."  
  echo  
  echo -e ${COLYELLOW}"Press any key to shutdown the system safely ..."  
  read  
  $rc_base/init.d/halt  
  fi  
  fi  
52    
53   #### load udev ####   #### load udev ####
54   # load udev only with a 2.6 kernel   start_udev
55   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]   ## end udev ##
56   then  
  # create a ramdisk for populating udev  
  echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."  
  # tmpfs was suggested by Greg Kroah-Hartman  
  # many video drivers needed exec access  
  mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755  
  evaluate_retval  
57    
58   # if a device tarball exists load it and if it is activated   ## load devpts ##
59   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   # devfs/udev with 2.6 has no ptys, so devpts is also needed
60   if [[ ${RC_DEVICE_TARBALL} = yes ]]   # check if we really have devpts support
61     if kernel_supports_fs devpts
62     then
63     # /dev/pts maybe not exists.
64     # We only create this directory only if devfs was mounted,
65     # or it will fail as / is still mounted readonly
66     # udev has this dir already, only a sanity check for devfs
67     if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
68   then   then
69   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."   mkdir -p /dev/pts &> /dev/null || \
70   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   echo "Could not create /dev/pts !"
  evaluate_retval  
71   fi   fi
72    
73   # other eeded device nodes with udev   # now mount devpts
74   seed_dev   if [ -d /dev/pts ]
   
  if [ -e /proc/sys/kernel/hotplug ]  
75   then   then
76   if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
77   then   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
78   echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."   evaluate_retval
  echo "" > /proc/sys/kernel/hotplug  
  evaluate_retval  
  elif [[ $(udev_version) -ge "48" ]]  
  then  
  echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."  
  echo "/sbin/udevsend" > /proc/sys/kernel/hotplug  
  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  
  fi  
  else  
  echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"  
  print_status failure  
79   fi   fi
80     else
81   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."   # devpts is not supported, give a warning
82   /sbin/udevd --daemon   echo -e ${COLRED}"No devpts filesystem found ..."
83   evaluate_retval   echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
84     echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
85   populate_udev   echo -e ${COLYELLOW}"or no pty's are available."
86     echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
87   # create nodes that udev can't   echo
88   echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."   echo -e ${COLYELLOW}"Press any key to continue ..."
89   [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null   read
  [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null  
  [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null  
  print_status success  
   
  # same thing as /dev/.devfsd  
  touch /dev/.udev  
90   fi   fi
91     ## end devpts ##
92    
93   ## load devpts ##  
94   # devfs/udev with 2.6 has no ptys, so devpts is also needed   ## load usbfs ##
95   if [[ $(kernel_major_version) = 2.6 ]]   if kernel_supports_fs usbfs
96   then   then
97   # check if we really have devpts support   echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..."
98   if kernel_supports_fs devpts   mount -n -t usbfs usbfs /proc/bus/usb
99   then   evaluate_retval
  # /dev/pts maybe not exists.  
  # We only create this directory only if devfs was mounted,  
  # or it will fail as / is still mounted readonly  
  # udev has this dir already, only a sanity check for devfs  
  if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs  
  then  
  mkdir -p /dev/pts &> /dev/null || \  
  echo "Could not create /dev/pts !"  
  fi  
   
  # now mount devpts  
  if [ -d /dev/pts ]  
  then  
  echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."  
  mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts  
  evaluate_retval  
  fi  
  else  
  # devpts is not supported, give a warning  
  echo -e ${COLRED}"No devpts filesystem found ..."  
  echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."  
  echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts,"  
  echo -e ${COLYELLOW}"or no pty's are available."  
  echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel."  
  echo  
  echo -e ${COLYELLOW}"Press any key to continue ..."  
  read  
  fi  
100   fi   fi
101     ## end usbfs ##
102    
103   ### services state dir ###   ## services state dir ##
104   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."
105   mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k   mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k
106   evaluate_retval   evaluate_retval
# Line 337  then Line 123  then
123   then   then
124   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
125   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
126   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
127   evaluate_retval   evaluate_retval
128   fi   fi
129  fi  fi

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