Magellan Linux

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

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

revision 71 by niro, Tue Mar 15 19:07:56 2005 UTC revision 935 by niro, Thu Nov 5 12:58:38 2009 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.4 2005-03-15 19:07:56 niro Exp $  # $Id$
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)"
12    
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    
 #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
19    
20  if [ "$runlevel" = "sysinit" ]  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 "\"I'm not a Gentoo-System, I'm a pure LFS\""   echo -e "Copyright 2001-2009 Niels Rogalla; http://magellan-linux.net"
25   echo   echo
26    
27   #mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
28   #no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
29   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
30   then   then
31   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   echo -e ${COLOREDSTAR}"Mounting proc file system ..."
# Line 51  then Line 33  then
33   evaluate_retval   evaluate_retval
34   fi   fi
35    
36   #set default verbose level for kernel messages   # set default verbose level for kernel messages
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 -t sysfs none /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" -o "${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 -t devfs devfs /dev  
  evaluate_retval  
  fi  
52    
53     #### load udev ####
54   if [ -e /dev/.devfsd ]   start_udev
55   then   ## end udev ##
  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  
56    
  fi  
57    
58   #### load udev ####   ## load devpts ##
59   #load udev only with a 2.6 kernel   # devfs/udev with 2.6 has no ptys, so devpts is also needed
60   if [ "$(kernel_major_version)" == "2.6" -a "${RC_USED_DEV}" == "udev" ]   # check if we really have devpts support
61     if kernel_supports_fs devpts
62   then   then
63  # #first at all unmount devfs if this was loaded by the kernel   # /dev/pts maybe not exists.
64  # DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"   # We only create this directory only if devfs was mounted,
65  # if [ "${DEVFS_MOUNTED}" == "devfs" ]   # or it will fail as / is still mounted readonly
66  # then   # udev has this dir already, only a sanity check for devfs
67  # umount -n /dev \   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
 # && echo "debug: unmounted devfs successfully" \  
 # || echo "debug: unmounting devfs failed"  
 # fi  
   
  #create a ramdisk for populating udev  
  echo -e ${COLOREDSTAR}"Mounting ramfs at /dev ..."  
  mount -n -t ramfs none /dev  
  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" ]  
68   then   then
69   echo -e ${COLOREDSTAR}"  Populating /dev with with 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   #now load udev   # now mount devpts
74   populate_udev   if [ -d /dev/pts ]
   
  #if hotplug support exists in the kernel use it to manage udev  
  if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]  
75   then   then
76   echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
77     mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
78   elif [ -e /proc/sys/kernel/hotplug ]   evaluate_retval
  then  
  echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."  
  echo "/sbin/udev" > /proc/sys/kernel/hotplug  
  else  
  echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"  
79   fi   fi
80   evaluate_retval   else
81     # devpts is not supported, give a warning
82     echo -e ${COLRED}"No devpts filesystem found ..."
83     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     echo -e ${COLYELLOW}"or no pty's are available."
86     echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
87     echo
88     echo -e ${COLYELLOW}"Press any key to continue ..."
89     read
90   fi   fi
91     ## end devpts ##
92    
93    
94   ## load devpts ##   ## load usbfs ##
95   # devfs/udev with 2.6 has no ptys, so devpts is also needed   if kernel_supports_fs usbfs
  if [ $(kernel_major_version) == 2.6 ]  
96   then   then
97   # check if we really have devpts support   echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..."
98   DEVPTS_CHECK="$(cat /proc/filesystems | grep devpts | cut -d $'\t' -f2)"   mount -n -t usbfs usbfs /proc/bus/usb
99   DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"   evaluate_retval
  if [ "${DEVPTS_CHECK}" == devpts ]  
  then  
  # /dev/pts maybe not exists.  
  # We only create this directory only if devfs was mounted,  
  # or it will fail as / is still mounted readonly  
  if [ ! -d "/dev/pts" \  
  -a -e "/dev/.devfsd" \  
  -a  "${DEVFS_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 none /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
107    
108   #load bootsplash   # load bootsplash
109   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
110  fi  fi
111    
112    
113    if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
 if [ "$runlevel" == "0" ]  
114  then  then
115     # load bootsplash
  #load bootsplash  
116   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
117    
   
118   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
119   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
120   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
121   if [ "${RC_DEVICE_TARBALL}" = "yes" \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
122   -a -e /dev/.udev \   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
  -a ! -e /dev/.devfsd \  
  -a ! -e /.bootdev ]  
123   then   then
124   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
125   cd /dev   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
126   tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null   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
130    
 if [ "$runlevel" == "6" ]  
 then  
   
  #load bootsplash  
  splash "rc_init" "${runlevel}"  
   
  # if requested save devices to a device tarball before halt  
  # only for kernels >=2.6 *and* udev  
  # make shure that udev is mounted but *not* devfs --> /dev/.devfsd  
  if [ "${RC_DEVICE_TARBALL}" = "yes" \  
  -a -e /dev/.udev \  
  -a ! -e /dev/.devfsd \  
  -a ! -e /.bootdev ]  
  then  
  echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."  
  cd /dev  
  tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null  
  mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2  
  cd ..  
  evaluate_retval  
  fi  
 fi  
131    
132  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
133  then  then
# Line 254  then Line 135  then
135   exit 1   exit 1
136  fi  fi
137    
138    
139  previous=$PREVLEVEL  previous=$PREVLEVEL
140  [ "$previous" = "" ] && previous=N  [ "$previous" = "" ] && previous=N
141    

Legend:
Removed from v.71  
changed lines
  Added in v.935