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 149 by niro, Tue Mar 15 19:07:56 2005 UTC revision 150 by niro, Sun Jul 3 21:34:35 2005 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 $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.5 2005-07-03 21:34:35 niro Exp $
3    
4  source /etc/sysconfig/rc  source /etc/sysconfig/rc
5  source $rc_functions  source $rc_functions
# Line 7  source $rc_functions Line 7  source $rc_functions
7  # get mage version  # get mage version
8  MAGEVER="$(< /etc/mageversion)"  MAGEVER="$(< /etc/mageversion)"
9    
10  #source kernel config if exists  # source kernel config if exists
11  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
12    
13  #some needed functions functions  # some needed functions functions
14  populate_udev() {  populate_udev() {
15   /sbin/udevstart   /sbin/udevstart
16    
17   #not provided by sysfs but needed   # not provided by sysfs but needed
18   ln -snf /proc/self/fd /dev/fd   ln -snf /proc/self/fd /dev/fd
19   ln -snf fd/0 /dev/stdin   ln -snf fd/0 /dev/stdin
20   ln -snf fd/1 /dev/stdout   ln -snf fd/1 /dev/stdout
# Line 22  populate_udev() { Line 22  populate_udev() {
22   ln -snf /proc/kcore /dev/core   ln -snf /proc/kcore /dev/core
23   ln -snf /proc/asound/oss/sndstat /dev/sndstat   ln -snf /proc/asound/oss/sndstat /dev/sndstat
24    
25   #create problematic directories   # create problematic directories
26   mkdir -p /dev/{pts,shm}   mkdir -p /dev/{pts,shm}
27    
28   #same as /dev/.devfsd   # same as /dev/.devfsd
29   touch /dev/.udev   touch /dev/.udev
30    
31   return 0   return 0
# Line 35  trap "" INT QUIT TSTP Line 35  trap "" INT QUIT TSTP
35    
36  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
37    
38  if [ "$runlevel" = "sysinit" ]  if [[ $runlevel = sysinit ]]
39  then  then
40   echo   echo
41   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
42   echo -e "\"I'm not a Gentoo-System, I'm a pure LFS\""   echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net"
43   echo   echo
44    
45   #mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
46   #no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
47   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
48   then   then
49   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   echo -e ${COLOREDSTAR}"Mounting proc file system ..."
# Line 51  then Line 51  then
51   evaluate_retval   evaluate_retval
52   fi   fi
53    
54   #set default verbose level for kernel messages   # set default verbose level for kernel messages
55   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
56   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
57    
58   #mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev or devfs (kernel-2.6)
59   if [ "$(kernel_major_version)" == "2.6" ]   if [[ $(kernel_major_version) = 2.6 ]]
60   then   then
61   if [ -d /sys ]   if [ -d /sys ]
62   then   then
63   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."
64   mount -t sysfs none /sys   mount -n -t sysfs sysfs /sys
65   evaluate_retval   evaluate_retval
66   else   else
67   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
# Line 71  then Line 71  then
71   fi   fi
72    
73   ## load devfs ##   ## load devfs ##
74   #load devfs only with a 2.4 kernel or its really wanted with a 2.6   # load devfs only with a 2.4 kernel or its really wanted with a 2.6
75   if [ "$(kernel_major_version)" == "2.4" -o "${RC_USED_DEV}" == "devfs" ]   if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]]
76   then   then
77   # start devfsd daemon, needed for bootsplash;   # start devfsd daemon, needed for bootsplash;
78   # no use of '/etc/rc.d/init.d/devfs' anymore   # no use of '/etc/rc.d/init.d/devfs' anymore
# Line 81  then Line 81  then
81   if [ ! -e /dev/.devfsd ]   if [ ! -e /dev/.devfsd ]
82   then   then
83   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."
84   mount -t devfs devfs /dev   mount -n -t devfs devfs /dev
85   evaluate_retval   evaluate_retval
86   fi   fi
87    
   
88   if [ -e /dev/.devfsd ]   if [ -e /dev/.devfsd ]
89   then   then
90   echo -e ${COLOREDSTAR}"Starting devfsd ..."   echo -e ${COLOREDSTAR}"Starting devfsd ..."
# Line 102  then Line 101  then
101   read   read
102   $rc_base/init.d/halt   $rc_base/init.d/halt
103   fi   fi
   
104   fi   fi
105    
106   #### load udev ####   #### load udev ####
107   #load udev only with a 2.6 kernel   # load udev only with a 2.6 kernel
108   if [ "$(kernel_major_version)" == "2.6" -a "${RC_USED_DEV}" == "udev" ]   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]
109   then   then
110  # #first at all unmount devfs if this was loaded by the kernel   # create a ramdisk for populating udev
111  # DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"   echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."
112  # if [ "${DEVFS_MOUNTED}" == "devfs" ]   # tmpfs was suggested by Greg Kroah-Hartman
113  # then   # many video drivers needed exec access
114  # umount -n /dev \   mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755
 # && 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  
115   evaluate_retval   evaluate_retval
116    
117   #if a device tarball exists load it and if it is activated   # if a device tarball exists load it and if it is activated
118   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
119   if [ "${RC_DEVICE_TARBALL}" = "yes" ]   if [[ ${RC_DEVICE_TARBALL} = yes ]]
120   then   then
121   echo -e ${COLOREDSTAR}"  Populating /dev with with device nodes ..."   echo -e ${COLOREDSTAR}"  Populating /dev with with device nodes ..."
122   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
123   evaluate_retval   evaluate_retval
124   fi   fi
125    
126   #now load udev   # now load udev
127   populate_udev   populate_udev
128    
129   #if hotplug support exists in the kernel use it to manage udev   # if hotplug support exists in the kernel use it to manage udev
130   if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]   if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]
131   then   then
132   echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."   echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."
# Line 150  then Line 141  then
141   evaluate_retval   evaluate_retval
142   fi   fi
143    
   
144   ## load devpts ##   ## load devpts ##
145   # devfs/udev with 2.6 has no ptys, so devpts is also needed   # devfs/udev with 2.6 has no ptys, so devpts is also needed
146   if [ $(kernel_major_version) == 2.6 ]   if [[ $(kernel_major_version) = 2.6 ]]
147   then   then
148   # check if we really have devpts support   # check if we really have devpts support
149   DEVPTS_CHECK="$(cat /proc/filesystems | grep devpts | cut -d $'\t' -f2)"   if kernel_supports_fs devpts
  DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"  
  if [ "${DEVPTS_CHECK}" == devpts ]  
150   then   then
151   # /dev/pts maybe not exists.   # /dev/pts maybe not exists.
152   # We only create this directory only if devfs was mounted,   # We only create this directory only if devfs was mounted,
153   # or it will fail as / is still mounted readonly   # or it will fail as / is still mounted readonly
154   if [ ! -d "/dev/pts" \   # udev has this dir already, only a sanity check for devfs
155   -a -e "/dev/.devfsd" \   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
  -a  "${DEVFS_MOUNTED}" == "devfs" ]  
156   then   then
157   mkdir -p /dev/pts &> /dev/null || \   mkdir -p /dev/pts &> /dev/null || \
158   echo "Could not create /dev/pts !"   echo "Could not create /dev/pts !"
159   fi   fi
160    
161   #now mount devpts   # now mount devpts
162   if [ -d /dev/pts ]   if [ -d /dev/pts ]
163   then   then
164   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
165   mount -n -t devpts -o gid=4,mode=0620 none /dev/pts   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
166   evaluate_retval   evaluate_retval
167   fi   fi
168   else   else
# Line 196  then Line 183  then
183   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
184   evaluate_retval   evaluate_retval
185    
186   #load bootsplash   # load bootsplash
187   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
188  fi  fi
189    
190    
191    if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
 if [ "$runlevel" == "0" ]  
192  then  then
193     # load bootsplash
  #load bootsplash  
194   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
195    
   
196   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
197   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
198   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
199   if [ "${RC_DEVICE_TARBALL}" = "yes" \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
200   -a -e /dev/.udev \   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
  -a ! -e /dev/.devfsd \  
  -a ! -e /.bootdev ]  
201   then   then
202   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
203   cd /dev   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
  tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null  
204   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2
205   evaluate_retval   evaluate_retval
206   fi   fi
207  fi  fi
208    
 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  
209    
210  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
211  then  then
# Line 254  then Line 213  then
213   exit 1   exit 1
214  fi  fi
215    
216    
217  previous=$PREVLEVEL  previous=$PREVLEVEL
218  [ "$previous" = "" ] && previous=N  [ "$previous" = "" ] && previous=N
219    

Legend:
Removed from v.149  
changed lines
  Added in v.150