Magellan Linux

Diff of /trunk/initscripts/sysvinit/rc/rc

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

trunk/magellan-initscripts/etc/rc.d/init.d/rc revision 318 by niro, Tue Jan 3 18:03:21 2006 UTC trunk/initscripts/sysvinit/rc/rc revision 1774 by niro, Sat Mar 3 16:00:17 2012 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.6 2006-01-03 18:03:21 niro Exp $  # $Id$
3    
4  source /etc/sysconfig/rc  source /etc/conf.d/rc
5  source $rc_functions  source ${rc_functions}
6    
7  # get mage version  # get mage version
8  MAGEVER="$(< /etc/mageversion)"  if [[ -f /etc/os-release ]]
9    then
10     MAGEVER="$(read_os_release version_id)"
11    elif [ -f /etc/mageversion ]
12    then
13     MAGEVER="$(< /etc/mageversion)"
14    else
15     MAGEVER="unkown"
16    fi
17    
18  # source kernel config if exists  # source kernel config if exists
19  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
20    
21  # this works only for 2.6.15 kernels and greater  # override devicemanager helper functions
22  trigger_events()  if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]]
23  {  then
24   local list=""   source ${rc_base}/init.d/udev
  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  
 }  
25    
26  # # some needed functions functions  elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
27  # populate_udev() {  then
28  # /sbin/udevstart   source ${rc_base}/init.d/mdev
29  #  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  
 # 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  
 # }  
30    
31  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
32    
# Line 127  trap "" INT QUIT TSTP Line 34  trap "" INT QUIT TSTP
34    
35  if [[ $runlevel = sysinit ]]  if [[ $runlevel = sysinit ]]
36  then  then
37   echo   rc_echo
38   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
39   echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net"   rc_echo "Copyright 2001-2012 Niels Rogalla; http://magellan-linux.net"
40   echo   rc_echo
41    
42   # mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
43   # no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
44   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
45   then   then
46   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   rc_print "Mounting proc file system ..."
47   mount -n /proc   mount -n /proc
48   evaluate_retval   evaluate_retval
49   fi   fi
# Line 145  then Line 52  then
52   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
53   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
54    
55   # mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev
56   if [[ $(kernel_major_version) = 2.6 ]]   if [ -d /sys ]
57   then   then
58   if [ -d /sys ]   rc_print "Mounting sysfs file system ..."
59   then   mount -n -t sysfs sysfs /sys
60   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   evaluate_retval
61   mount -n -t sysfs sysfs /sys   else
62   evaluate_retval   rc_echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
63   else   rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
64   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   rc_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  
65   fi   fi
66    
67   ## load devfs ##   # start device management
68   # load devfs only with a 2.4 kernel or its really wanted with a 2.6   start_devicemanager
69   if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]]  
70     ## load devpts ##
71     # devfs/udev with 2.6 has no ptys, so devpts is also needed
72     # check if we really have devpts support
73     if kernel_supports_fs devpts
74   then   then
75   # start devfsd daemon, needed for bootsplash;   # /dev/pts maybe not exists.
76   # no use of '/etc/rc.d/init.d/devfs' anymore   # We only create this directory only if devfs was mounted,
77   # check if devfs was mounted by the kernel,   # or it will fail as / is still mounted readonly
78   # if not mount it (mbuild_livecd needs this one)   # udev has this dir already, only a sanity check for devfs
79   if [ ! -e /dev/.devfsd ]   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
80   then   then
81   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."   mkdir -p /dev/pts &> /dev/null || \
82   mount -n -t devfs devfs /dev   rc_echo "Could not create /dev/pts !"
  evaluate_retval  
83   fi   fi
84    
85   if [ -e /dev/.devfsd ]   # now mount devpts
86     if [ -d /dev/pts ]
87   then   then
88   echo -e ${COLOREDSTAR}"Starting devfsd ..."   rc_print "Mounting devpts at /dev/pts ..."
89   ## directory /lib/dev-state !must! exists ##   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
  /sbin/devfsd /dev &> /dev/null  
90   evaluate_retval   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  
91   fi   fi
92     else
93     # devpts is not supported, give a warning
94     rc_echo -e ${COLRED}"No devpts filesystem found ..."
95     rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
96     rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
97     rc_echo -e ${COLYELLOW}"or no pty's are available."
98     rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
99     rc_echo
100     rc_echo -e ${COLYELLOW}"Press any key to continue ..."
101     read
102   fi   fi
103     ## end devpts ##
104    
  #### load udev ####  
  # load udev only with a 2.6 kernel  
  if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]  
  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  
   
  # if a device tarball exists load it and if it is activated  
  echo -e ${COLOREDSTAR}"Configurating system to use udev ..."  
  if [[ ${RC_DEVICE_TARBALL} = yes ]]  
  then  
  echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."  
  tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev  
  evaluate_retval  
  fi  
   
  # other eeded device nodes with udev  
  seed_dev  
   
  if [ -e /proc/sys/kernel/hotplug ]  
  then  
  if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]  
  then  
  echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."  
  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  
  fi  
   
  echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."  
  /sbin/udevd --daemon  
  evaluate_retval  
   
  populate_udev  
   
  # create nodes that udev can't  
  echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."  
  [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null  
  [[ -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  
  fi  
105    
106   ## load devpts ##   ## load usbfs ##
107   # devfs/udev with 2.6 has no ptys, so devpts is also needed   if kernel_supports_fs usbfs
  if [[ $(kernel_major_version) = 2.6 ]]  
108   then   then
109   # check if we really have devpts support   rc_print "Mounting usbfs at /proc/bus/usb ..."
110   if kernel_supports_fs devpts   mount -n -t usbfs usbfs /proc/bus/usb
111   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  
112   fi   fi
113     ## end usbfs ##
114    
115   ### services state dir ###   ## services state dir ##
116   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."   rc_print "Mounting tmpfs at ${svcdir} ..."
117   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
118   evaluate_retval   evaluate_retval
119    
# Line 317  then Line 133  then
133   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
134   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
135   then   then
136   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   rc_print "Saving /dev device nodes ..."
137   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
138   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
139   evaluate_retval   evaluate_retval
140   fi   fi
141    
142     # stop device management
143     stop_devicemanager
144  fi  fi
145    
146    
147  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
148  then  then
149   echo "Usage: $0 <runlevel>" >&2   rc_echo "Usage: $0 <runlevel>" >&2
150   exit 1   exit 1
151  fi  fi
152    
# Line 337  previous=$PREVLEVEL Line 156  previous=$PREVLEVEL
156    
157  if [ ! -d $rc_base/rc$runlevel.d ]  if [ ! -d $rc_base/rc$runlevel.d ]
158  then  then
159   echo "$rc_base/rc$runlevel.d does not exist"   rc_echo "$rc_base/rc$runlevel.d does not exist"
160   exit 1   exit 1
161  fi  fi
162    
# Line 357  then Line 176  then
176   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
177   then   then
178   $WARNING   $WARNING
179   echo "$i can't be executed because it was"   rc_echo "$i can't be executed because it was"
180   echo "not started in the previous runlevel ($previous)"   rc_echo "not started in the previous runlevel ($previous)"
181   $NORMAL   $NORMAL
182   continue   continue
183   fi   fi

Legend:
Removed from v.318  
changed lines
  Added in v.1774