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 428 by niro, Sun Mar 4 13:24:34 2007 UTC revision 782 by niro, Mon Dec 22 22:08:32 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.13 2007-03-04 13:24:34 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.22 2008-12-22 22:08:32 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}"  
 }  
   
 populate_udev()  
 {  
  local opts  
   
  # tell modprobe.sh to be verbose to $CONSOLE  
  echo CONSOLE=${CONSOLE} > /dev/.udev_populate  
   
  # populate /dev with devices already found by the kernel  
  if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]  
  then  
  echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."  
  [[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev"  
  /sbin/udevtrigger ${opts}  
  evaluate_retval  
  else  
  echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."  
  /sbin/udevstart  
  evaluate_retval  
  fi  
   
  # loop until everything is finished  
  echo -e ${COLOREDSTAR}"  Letting udev process events ..."  
  /sbin/udevsettle --timeout=60  
  evaluate_retval  
   
  rm -f /dev/.udev_populate  
  return 0  
 }  
   
 seed_dev()  
 {  
  # seed /dev with some things that we know we need  
  echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."  
  (  
  [ ! -c /dev/console ] && mknod /dev/console c 5 1  
  [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1  
  [ ! -c /dev/null ] && mknod /dev/null c 1 3  
   
  # copy over any persistant things  
  if [[ -d /lib/udev/devices ]]  
  then  
  cp --preserve=all --recursive --update /lib/udev/devices/* /dev  
  fi  
   
  # 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  
 }  
   
16  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
17    
18  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
# Line 91  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-2007 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 107  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 ##
  then  
  # check if /dev/console exists outside tmpfs  
  [ -c /dev/console ] ; need_redirect=$?  
56    
  # create a ramdisk for populating udev  
  echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."  
  # many video drivers needed exec access  
  fstype=ramfs  
  # tmpfs was suggested by Greg Kroah-Hartman  
  kernel_supports_fs tmpfs && fstype=tmpfs  
  mount -n -t ${fstype} 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   then   if kernel_supports_fs devpts
62   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."   then
63   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   # /dev/pts maybe not exists.
64   evaluate_retval   # We only create this directory only if devfs was mounted,
65   fi   # or it will fail as / is still mounted readonly
66     # udev has this dir already, only a sanity check for devfs
67   # other eeded device nodes with udev   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
  seed_dev  
   
  if [ -e /proc/sys/kernel/hotplug ]  
68   then   then
69   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]   mkdir -p /dev/pts &> /dev/null || \
70   then   echo "Could not create /dev/pts !"
  echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."  
  echo "" > /proc/sys/kernel/hotplug  
  evaluate_retval  
  else  
  echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."  
  echo "/sbin/udevsend" > /proc/sys/kernel/hotplug  
  evaluate_retval  
  fi  
  else  
  echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"  
  print_status failure  
71   fi   fi
72    
73   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."   # now mount devpts
74   if [ ${need_redirect} -eq 1 ]   if [ -d /dev/pts ]
75   then   then
76   # we need to open fds 0 1 2   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
77   /sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
78   else   evaluate_retval
  /sbin/udevd --daemon  
79   fi   fi
80   evaluate_retval   else
81     # devpts is not supported, give a warning
82   populate_udev   echo -e ${COLRED}"No devpts filesystem found ..."
83     echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
84   # create nodes that udev can't   echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts,"
85   echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."   echo -e ${COLYELLOW}"or no pty's are available."
86   [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null   echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel."
87   [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null   echo
88   [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null   echo -e ${COLYELLOW}"Press any key to continue ..."
89   print_status success   read
   
  # 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 283  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.428  
changed lines
  Added in v.782