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 10 by niro, Mon Dec 13 23:24:11 2004 UTC revision 394 by niro, Tue Oct 31 09:10:45 2006 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.10 2006-10-31 09:10:45 niro Exp $
3    
4  source /etc/sysconfig/rc  source /etc/sysconfig/rc
5  source $rc_functions  source $rc_functions
 source /etc/mageversion  
6    
7    # get mage version
8    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     fi
25    
26     echo "${version}"
27    }
28    
29    populate_udev()
30    {
31     local opts
32    
33     # populate /dev with devices already found by the kernel
34     if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
35     then
36     echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."
37     [[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev"
38     /sbin/udevtrigger ${opts}
39     evaluate_retval
40     else
41     echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."
42   /sbin/udevstart   /sbin/udevstart
43     evaluate_retval
44     fi
45    
46     # loop until everything is finished
47     echo -e ${COLOREDSTAR}"  Letting udev process events ..."
48     /sbin/udevsettle --timeout=60
49     evaluate_retval
50    
51     return 0
52    }
53    
54   #not provided by sysfs but needed  seed_dev()
55    {
56     # seed /dev with some things that we know we need
57     echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."
58     (
59     # copy over any persistant things
60     if [[ -d /lib/udev/devices ]]
61     then
62     cp --preserve=all --recursive --update /lib/udev/devices/* /dev
63     fi
64    
65     # not provided by sysfs but needed
66   ln -snf /proc/self/fd /dev/fd   ln -snf /proc/self/fd /dev/fd
67   ln -snf fd/0 /dev/stdin   ln -snf fd/0 /dev/stdin
68   ln -snf fd/1 /dev/stdout   ln -snf fd/1 /dev/stdout
69   ln -snf fd/2 /dev/stderr   ln -snf fd/2 /dev/stderr
70   ln -snf /proc/kcore /dev/core   [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
71   ln -snf /proc/asound/oss/sndstat /dev/sndstat  
72     # create problematic directories
  #create problematic directories  
73   mkdir -p /dev/{pts,shm}   mkdir -p /dev/{pts,shm}
74     )
75   #same as /dev/.devfsd   evaluate_retval
  touch /dev/.udev  
   
  return 0  
76  }  }
77    
78  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
79    
80  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
81    
82  if [ "$runlevel" = "sysinit" ]  if [[ $runlevel = sysinit ]]
83  then  then
84   echo   echo
85   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
86   echo -e "\"I'm not a Gentoo-System, I'm a pure LFS\""   echo -e "Copyright 2001-2006 Niels Rogalla; http://magellan-linux.net"
87   echo   echo
88    
89   #mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
90   #no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
91   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
92   then   then
93   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   echo -e ${COLOREDSTAR}"Mounting proc file system ..."
# Line 49  then Line 95  then
95   evaluate_retval   evaluate_retval
96   fi   fi
97    
98   #set default verbose level for kernel messages   # set default verbose level for kernel messages
99   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
100   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
101    
102   #mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev or devfs (kernel-2.6)
103   if [ "$(kernel_major_version)" == "2.6" ]   if [[ $(kernel_major_version) = 2.6 ]]
104   then   then
105   if [ -d /sys ]   if [ -d /sys ]
106   then   then
107   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."
108   mount -t sysfs none /sys   mount -n -t sysfs sysfs /sys
109   evaluate_retval   evaluate_retval
110   else   else
111   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
# Line 69  then Line 115  then
115   fi   fi
116    
117   ## load devfs ##   ## load devfs ##
118   #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
119   if [ "$(kernel_major_version)" == "2.4" -o "${RC_USED_DEV}" == "devfs" ]   if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]]
120   then   then
121   # start devfsd daemon, needed for bootsplash;   # start devfsd daemon, needed for bootsplash;
122   # no use of '/etc/rc.d/init.d/devfs' anymore   # no use of '/etc/rc.d/init.d/devfs' anymore
# Line 79  then Line 125  then
125   if [ ! -e /dev/.devfsd ]   if [ ! -e /dev/.devfsd ]
126   then   then
127   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."
128   mount -t devfs devfs /dev   mount -n -t devfs devfs /dev
129   evaluate_retval   evaluate_retval
130   fi   fi
131    
   
132   if [ -e /dev/.devfsd ]   if [ -e /dev/.devfsd ]
133   then   then
134   echo -e ${COLOREDSTAR}"Starting devfsd ..."   echo -e ${COLOREDSTAR}"Starting devfsd ..."
# Line 100  then Line 145  then
145   read   read
146   $rc_base/init.d/halt   $rc_base/init.d/halt
147   fi   fi
   
148   fi   fi
149    
150   #### load udev ####   #### load udev ####
151   #load udev only with a 2.6 kernel   # load udev only with a 2.6 kernel
152   if [ "$(kernel_major_version)" == "2.6" -a "${RC_USED_DEV}" == "udev" ]   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]
153   then   then
154  # #first at all unmount devfs if this was loaded by the kernel   # create a ramdisk for populating udev
155  # DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"   echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."
156  # if [ "${DEVFS_MOUNTED}" == "devfs" ]   # many video drivers needed exec access
157  # then   fstype=ramfs
158  # umount -n /dev \   # tmpfs was suggested by Greg Kroah-Hartman
159  # && echo "debug: unmounted devfs successfully" \   [[ kernel_supports_fs tmpfs ]] && fstype=tmpfs
160  # || echo "debug: unmounting devfs failed"   mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755
 # fi  
   
  #create a ramdisk for populating udev  
  echo -e ${COLOREDSTAR}"Mounting ramfs at /dev ..."  
  mount -n -t ramfs none /dev  
161   evaluate_retval   evaluate_retval
162    
163   #if a device tarball exists load it and if it is activated   # if a device tarball exists load it and if it is activated
164   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
165   if [ "${RC_DEVICE_TARBALL}" = "yes" ]   if [[ ${RC_DEVICE_TARBALL} = yes ]]
166   then   then
167   echo -e ${COLOREDSTAR}"  Populating /dev with with device nodes ..."   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."
168   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
169   evaluate_retval   evaluate_retval
170   fi   fi
171    
172   #now load udev   # other eeded device nodes with udev
173   populate_udev   seed_dev
174    
175   #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 ]  
176   then   then
177   echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]
178     then
179   elif [ -e /proc/sys/kernel/hotplug ]   echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."
180   then   echo "" > /proc/sys/kernel/hotplug
181   echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."   evaluate_retval
182   echo "/sbin/udev" > /proc/sys/kernel/hotplug   else
183     echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."
184     echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
185     evaluate_retval
186     fi
187   else   else
188   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"   echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"
189     print_status failure
190   fi   fi
191    
192     echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."
193     /sbin/udevd --daemon
194   evaluate_retval   evaluate_retval
195    
196     populate_udev
197    
198     # create nodes that udev can't
199     echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."
200     [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
201     [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
202     [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null
203     print_status success
204    
205     # same thing as /dev/.devfsd
206     touch /dev/.udev
207   fi   fi
208    
   
209   ## load devpts ##   ## load devpts ##
210   # 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
211   if [ $(kernel_major_version) == 2.6 ]   if [[ $(kernel_major_version) = 2.6 ]]
212   then   then
213   # check if we really have devpts support   # check if we really have devpts support
214   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 ]  
215   then   then
216   # /dev/pts maybe not exists.   # /dev/pts maybe not exists.
217   # We only create this directory only if devfs was mounted,   # We only create this directory only if devfs was mounted,
218   # or it will fail as / is still mounted readonly   # or it will fail as / is still mounted readonly
219   if [ ! -d "/dev/pts" \   # udev has this dir already, only a sanity check for devfs
220   -a -e "/dev/.devfsd" \   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
  -a  "${DEVFS_MOUNTED}" == "devfs" ]  
221   then   then
222   mkdir -p /dev/pts &> /dev/null || \   mkdir -p /dev/pts &> /dev/null || \
223   echo "Could not create /dev/pts !"   echo "Could not create /dev/pts !"
224   fi   fi
225    
226   #now mount devpts   # now mount devpts
227   if [ -d /dev/pts ]   if [ -d /dev/pts ]
228   then   then
229   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
230   mount -n -t devpts -o gid=4,mode=0620 none /dev/pts   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
231   evaluate_retval   evaluate_retval
232   fi   fi
233   else   else
# Line 194  then Line 248  then
248   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
249   evaluate_retval   evaluate_retval
250    
251   #load bootsplash   # load bootsplash
252   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
253  fi  fi
254    
255    
256    if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
 if [ "$runlevel" == "0" ]  
257  then  then
258     # load bootsplash
  #load bootsplash  
259   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
260    
   
261   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
262   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
263   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
264   if [ "${RC_DEVICE_TARBALL}" = "yes" \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
265   -a -e /dev/.udev \   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
  -a ! -e /dev/.devfsd \  
  -a ! -e /.bootdev ]  
266   then   then
267   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
268   cd /dev   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
  tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null  
269   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2
270   evaluate_retval   evaluate_retval
271   fi   fi
272  fi  fi
273    
 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  
274    
275  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
276  then  then
# Line 252  then Line 278  then
278   exit 1   exit 1
279  fi  fi
280    
281    
282  previous=$PREVLEVEL  previous=$PREVLEVEL
283  [ "$previous" = "" ] && previous=N  [ "$previous" = "" ] && previous=N
284    

Legend:
Removed from v.10  
changed lines
  Added in v.394