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 431 by niro, Tue Mar 6 00:10:26 2007 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.14 2007-03-06 00:10:26 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  udev_version()
14  populate_udev() {  {
15     local version=0
16    
17     if [[ -x /sbin/udev ]]
18     then
19     version=$(/sbin/udev -V)
20     # We need it without a leading '0', else bash do the wrong thing
21     version=${version##0}
22     # Older udev's will print nothing
23     [[ -z ${version} ]] && version=0
24     elif [[ -x /sbin/udevd ]]
25     then
26     version=$(/sbin/udevd --version)
27     version=${version##0}
28     [[ -z ${version} ]] && version=0
29     fi
30    
31     echo "${version}"
32    }
33    
34    populate_udev()
35    {
36     local opts
37    
38     # tell modprobe.sh to be verbose to $CONSOLE
39     echo CONSOLE=${CONSOLE} > /dev/.udev_populate
40    
41     # populate /dev with devices already found by the kernel
42     if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
43     then
44     echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."
45     [[ $(udev_version) -ge "96" ]] && [[ ${RC_COLDPLUG} != yes ]] && opts="--attr-match=dev"
46     /sbin/udevtrigger ${opts}
47     evaluate_retval
48     else
49     echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."
50   /sbin/udevstart   /sbin/udevstart
51     evaluate_retval
52     fi
53    
54     # loop until everything is finished
55     echo -e ${COLOREDSTAR}"  Letting udev process events ..."
56     /sbin/udevsettle --timeout=60
57     evaluate_retval
58    
59   #not provided by sysfs but needed   rm -f /dev/.udev_populate
60     return 0
61    }
62    
63    seed_dev()
64    {
65     # seed /dev with some things that we know we need
66     echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."
67     (
68     [ ! -c /dev/console ] && mknod /dev/console c 5 1
69     [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1
70     [ ! -c /dev/null ] && mknod /dev/null c 1 3
71    
72     # copy over any persistant things
73     if [[ -d /lib/udev/devices ]]
74     then
75     cp --preserve=all --recursive --update /lib/udev/devices/* /dev
76     fi
77    
78     # not provided by sysfs but needed
79   ln -snf /proc/self/fd /dev/fd   ln -snf /proc/self/fd /dev/fd
80   ln -snf fd/0 /dev/stdin   ln -snf fd/0 /dev/stdin
81   ln -snf fd/1 /dev/stdout   ln -snf fd/1 /dev/stdout
82   ln -snf fd/2 /dev/stderr   ln -snf fd/2 /dev/stderr
83   ln -snf /proc/kcore /dev/core   [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
84   ln -snf /proc/asound/oss/sndstat /dev/sndstat  
85     # create problematic directories
  #create problematic directories  
86   mkdir -p /dev/{pts,shm}   mkdir -p /dev/{pts,shm}
87     )
88   #same as /dev/.devfsd   evaluate_retval
  touch /dev/.udev  
   
  return 0  
89  }  }
90    
91  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
92    
93  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
94    
95  if [ "$runlevel" = "sysinit" ]  if [[ $runlevel = sysinit ]]
96  then  then
97   echo   echo
98   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
99   echo -e "\"I'm not a Gentoo-System, I'm a pure LFS\""   echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net"
100   echo   echo
101    
102   #mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
103   #no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
104   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
105   then   then
106   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   echo -e ${COLOREDSTAR}"Mounting proc file system ..."
# Line 51  then Line 108  then
108   evaluate_retval   evaluate_retval
109   fi   fi
110    
111   #set default verbose level for kernel messages   # set default verbose level for kernel messages
112   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
113   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
114    
115   #mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev or devfs (kernel-2.6)
116   if [ "$(kernel_major_version)" == "2.6" ]   if [[ $(kernel_major_version) = 2.6 ]]
117   then   then
118   if [ -d /sys ]   if [ -d /sys ]
119   then   then
120   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."
121   mount -t sysfs none /sys   mount -n -t sysfs sysfs /sys
122   evaluate_retval   evaluate_retval
123   else   else
124   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
# Line 71  then Line 128  then
128   fi   fi
129    
130   ## load devfs ##   ## load devfs ##
131   #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
132   if [ "$(kernel_major_version)" == "2.4" -o "${RC_USED_DEV}" == "devfs" ]   if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]]
133   then   then
134   # start devfsd daemon, needed for bootsplash;   # start devfsd daemon, needed for bootsplash;
135   # no use of '/etc/rc.d/init.d/devfs' anymore   # no use of '/etc/rc.d/init.d/devfs' anymore
# Line 81  then Line 138  then
138   if [ ! -e /dev/.devfsd ]   if [ ! -e /dev/.devfsd ]
139   then   then
140   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."
141   mount -t devfs devfs /dev   mount -n -t devfs devfs /dev
142   evaluate_retval   evaluate_retval
143   fi   fi
144    
   
145   if [ -e /dev/.devfsd ]   if [ -e /dev/.devfsd ]
146   then   then
147   echo -e ${COLOREDSTAR}"Starting devfsd ..."   echo -e ${COLOREDSTAR}"Starting devfsd ..."
# Line 102  then Line 158  then
158   read   read
159   $rc_base/init.d/halt   $rc_base/init.d/halt
160   fi   fi
   
161   fi   fi
162    
163   #### load udev ####   #### load udev ####
164   #load udev only with a 2.6 kernel   # load udev only with a 2.6 kernel
165   if [ "$(kernel_major_version)" == "2.6" -a "${RC_USED_DEV}" == "udev" ]   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]
166   then   then
167  # #first at all unmount devfs if this was loaded by the kernel   # check if /dev/console exists outside tmpfs
168  # DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"   [ -c /dev/console ] ; need_redirect=$?
169  # if [ "${DEVFS_MOUNTED}" == "devfs" ]  
170  # then   # create a ramdisk for populating udev
171  # umount -n /dev \   echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."
172  # && echo "debug: unmounted devfs successfully" \   # many video drivers needed exec access
173  # || echo "debug: unmounting devfs failed"   fstype=ramfs
174  # fi   # tmpfs was suggested by Greg Kroah-Hartman
175     kernel_supports_fs tmpfs && fstype=tmpfs
176   #create a ramdisk for populating udev   mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755
  echo -e ${COLOREDSTAR}"Mounting ramfs at /dev ..."  
  mount -n -t ramfs none /dev  
177   evaluate_retval   evaluate_retval
178    
179   #if a device tarball exists load it and if it is activated   # if a device tarball exists load it and if it is activated
180   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
181   if [ "${RC_DEVICE_TARBALL}" = "yes" ]   if [[ ${RC_DEVICE_TARBALL} = yes ]]
182   then   then
183   echo -e ${COLOREDSTAR}"  Populating /dev with with device nodes ..."   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."
184   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
185   evaluate_retval   evaluate_retval
186   fi   fi
187    
188   #now load udev   # other eeded device nodes with udev
189   populate_udev   seed_dev
190    
191   #if hotplug support exists in the kernel use it to manage udev   if [ -e /proc/sys/kernel/hotplug ]
  if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]  
192   then   then
193   echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
194     then
195     echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."
196     echo "" > /proc/sys/kernel/hotplug
197     evaluate_retval
198     else
199     echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."
200     echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
201     evaluate_retval
202     fi
203     else
204     echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"
205     print_status failure
206     fi
207    
208   elif [ -e /proc/sys/kernel/hotplug ]   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."
209     if [ ${need_redirect} -eq 1 ]
210   then   then
211   echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."   # we need to open fds 0 1 2
212   echo "/sbin/udev" > /proc/sys/kernel/hotplug   /sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console
213   else   else
214   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"   /sbin/udevd --daemon
215   fi   fi
216   evaluate_retval   evaluate_retval
217    
218     populate_udev
219    
220     # create nodes that udev can't
221     echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."
222     [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
223     [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
224     [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null
225     print_status success
226    
227     # same thing as /dev/.devfsd
228     touch /dev/.udev
229   fi   fi
230    
   
231   ## load devpts ##   ## load devpts ##
232   # 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
233   if [ $(kernel_major_version) == 2.6 ]   if [[ $(kernel_major_version) = 2.6 ]]
234   then   then
235   # check if we really have devpts support   # check if we really have devpts support
236   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 ]  
237   then   then
238   # /dev/pts maybe not exists.   # /dev/pts maybe not exists.
239   # We only create this directory only if devfs was mounted,   # We only create this directory only if devfs was mounted,
240   # or it will fail as / is still mounted readonly   # or it will fail as / is still mounted readonly
241   if [ ! -d "/dev/pts" \   # udev has this dir already, only a sanity check for devfs
242   -a -e "/dev/.devfsd" \   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
  -a  "${DEVFS_MOUNTED}" == "devfs" ]  
243   then   then
244   mkdir -p /dev/pts &> /dev/null || \   mkdir -p /dev/pts &> /dev/null || \
245   echo "Could not create /dev/pts !"   echo "Could not create /dev/pts !"
246   fi   fi
247    
248   #now mount devpts   # now mount devpts
249   if [ -d /dev/pts ]   if [ -d /dev/pts ]
250   then   then
251   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
252   mount -n -t devpts -o gid=4,mode=0620 none /dev/pts   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
253   evaluate_retval   evaluate_retval
254   fi   fi
255   else   else
# Line 196  then Line 270  then
270   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
271   evaluate_retval   evaluate_retval
272    
273   #load bootsplash   # load bootsplash
274   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
275  fi  fi
276    
277    
278    if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
 if [ "$runlevel" == "0" ]  
279  then  then
280     # load bootsplash
  #load bootsplash  
281   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
282    
   
283   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
284   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
285   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
286   if [ "${RC_DEVICE_TARBALL}" = "yes" \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
287   -a -e /dev/.udev \   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
  -a ! -e /dev/.devfsd \  
  -a ! -e /.bootdev ]  
288   then   then
289   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
290   cd /dev   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
  tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null  
291   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2
292   evaluate_retval   evaluate_retval
293   fi   fi
294  fi  fi
295    
 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  
296    
297  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
298  then  then
# Line 254  then Line 300  then
300   exit 1   exit 1
301  fi  fi
302    
303    
304  previous=$PREVLEVEL  previous=$PREVLEVEL
305  [ "$previous" = "" ] && previous=N  [ "$previous" = "" ] && previous=N
306    

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