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 394 by niro, Tue Oct 31 09:10:45 2006 UTC revision 692 by niro, Sat Mar 22 17:55:21 2008 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 $  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.19 2008-03-22 17:55:21 niro Exp $
3    
4  source /etc/sysconfig/rc  source /etc/sysconfig/rc
5  source $rc_functions  source $rc_functions
# Line 21  udev_version() Line 21  udev_version()
21   version=${version##0}   version=${version##0}
22   # Older udev's will print nothing   # Older udev's will print nothing
23   [[ -z ${version} ]] && version=0   [[ -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   fi
30    
31   echo "${version}"   echo "${version}"
# Line 30  populate_udev() Line 35  populate_udev()
35  {  {
36   local opts   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   # populate /dev with devices already found by the kernel
42   if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."
43     if [[ ${RC_COLDPLUG} = yes ]]
44   then   then
45   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."   /sbin/udevtrigger
  [[ $(udev_version) -ge "96" ]] && opts="--attr-match=dev"  
  /sbin/udevtrigger ${opts}  
  evaluate_retval  
46   else   else
47   echo -e ${COLOREDSTAR}"  Populating /dev with existing devices with udevstart ..."   # do not run any init-scripts
48   /sbin/udevstart   /sbin/udevadm control --env do_not_run_plug_service=1
49   evaluate_retval  
50     # only create device nodes
51     /sbin/udevtrigger --attr-match=dev
52    
53     # run persistent-net stuff
54     /sbin/udevtrigger --subsystem-match=net
55   fi   fi
56     evaluate_retval
57    
58   # loop until everything is finished   # loop until everything is finished
59   echo -e ${COLOREDSTAR}"  Letting udev process events ..."   echo -e ${COLOREDSTAR}"  Letting udev process events ..."
60   /sbin/udevsettle --timeout=60   /sbin/udevsettle --timeout=60
61   evaluate_retval   evaluate_retval
62    
63     # unset this variable
64     udevadm control --env do_not_run_plug_service=
65    
66     rm -f /dev/.udev_populate
67   return 0   return 0
68  }  }
69    
# Line 56  seed_dev() Line 72  seed_dev()
72   # seed /dev with some things that we know we need   # seed /dev with some things that we know we need
73   echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."   echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."
74   (   (
75     [ ! -c /dev/console ] && mknod /dev/console c 5 1
76     [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1
77     [ ! -c /dev/null ] && mknod /dev/null c 1 3
78    
79   # copy over any persistant things   # copy over any persistant things
80   if [[ -d /lib/udev/devices ]]   if [[ -d /lib/udev/devices ]]
81   then   then
82   cp --preserve=all --recursive --update /lib/udev/devices/* /dev   cp -RPp /lib/udev/devices/* /dev 2>/dev/null
83   fi   fi
84    
85   # not provided by sysfs but needed   # not provided by sysfs but needed
86   ln -snf /proc/self/fd /dev/fd   ln -snf /proc/self/fd /dev/fd
87   ln -snf fd/0 /dev/stdin   ln -snf fd/0 /dev/stdin
88   ln -snf fd/1 /dev/stdout   ln -snf fd/1 /dev/stdout
89   ln -snf fd/2 /dev/stderr   ln -snf fd/2 /dev/stderr
90   [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core   [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
91    
92   # create problematic directories   # create problematic directories
93   mkdir -p /dev/{pts,shm}   mkdir -p /dev/pts /dev/shm
94   )   )
95   evaluate_retval   evaluate_retval
96  }  }
# Line 83  if [[ $runlevel = sysinit ]] Line 103  if [[ $runlevel = sysinit ]]
103  then  then
104   echo   echo
105   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
106   echo -e "Copyright 2001-2006 Niels Rogalla; http://magellan-linux.net"   echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net"
107   echo   echo
108    
109   # mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
# Line 99  then Line 119  then
119   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
120   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
121    
122   # mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev
123   if [[ $(kernel_major_version) = 2.6 ]]   if [ -d /sys ]
124   then   then
125   if [ -d /sys ]   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."
126   then   mount -n -t sysfs sysfs /sys
127   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   evaluate_retval
128   mount -n -t sysfs sysfs /sys   else
129   evaluate_retval   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
130   else   echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
131   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  
132   fi   fi
133    
  ## load devfs ##  
  # load devfs only with a 2.4 kernel or its really wanted with a 2.6  
  if [[ $(kernel_major_version) = 2.4 ]] || [[ ${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 -n -t devfs devfs /dev  
  evaluate_retval  
  fi  
   
  if [ -e /dev/.devfsd ]  
  then  
  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  
  fi  
134    
135   #### load udev ####   #### load udev ####
136   # load udev only with a 2.6 kernel   # check if /dev/console exists outside tmpfs
137   if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]]   [ -c /dev/console ] ; need_redirect=$?
  then  
  # create a ramdisk for populating udev  
  echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."  
  # many video drivers needed exec access  
  fstype=ramfs  
  # tmpfs was suggested by Greg Kroah-Hartman  
  [[ kernel_supports_fs tmpfs ]] && fstype=tmpfs  
  mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755  
  evaluate_retval  
138    
139   # if a device tarball exists load it and if it is activated   # create a ramdisk for populating udev
140   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."   echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."
141   if [[ ${RC_DEVICE_TARBALL} = yes ]]   # many video drivers needed exec access
142   then   fstype=ramfs
143   echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."   # tmpfs was suggested by Greg Kroah-Hartman
144   tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev   kernel_supports_fs tmpfs && fstype=tmpfs
145   evaluate_retval   mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M
146   fi   evaluate_retval
147    
148   # other eeded device nodes with udev   # if a device tarball exists load it and if it is activated
149   seed_dev   echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
150     if [[ ${RC_DEVICE_TARBALL} = yes ]]
151     then
152     echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."
153     tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
154     evaluate_retval
155     fi
156    
157   if [ -e /proc/sys/kernel/hotplug ]   # other eeded device nodes with udev
158   then   seed_dev
  if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ]  
  then  
  echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."  
  echo "" > /proc/sys/kernel/hotplug  
  evaluate_retval  
  else  
  echo -e ${COLOREDSTAR}"  Setting /sbin/udevsend as hotplug agent ..."  
  echo "/sbin/udevsend" > /proc/sys/kernel/hotplug  
  evaluate_retval  
  fi  
  else  
  echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"  
  print_status failure  
  fi  
159    
160   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."   if [ -e /proc/sys/kernel/hotplug ]
161   /sbin/udevd --daemon   then
162     echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."
163     echo "" > /proc/sys/kernel/hotplug
164   evaluate_retval   evaluate_retval
165     else
166     echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"
167     print_status failure
168     fi
169    
170   populate_udev   echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."
171     if [ ${need_redirect} -eq 1 ]
172     then
173     # we need to open fds 0 1 2
174     /sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console
175     else
176     /sbin/udevd --daemon
177     fi
178     evaluate_retval
179    
180   # create nodes that udev can't   # write root_link rule
181   echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."   /lib/udev/write_root_link_rule
182   [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null   # populate udev device nodes
183   [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null   populate_udev
184   [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null  
185   print_status success   # create nodes that udev can't
186     echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."
187     [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
188     [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
189     [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null
190     print_status success
191    
192     # same thing as /dev/.devfsd
193     touch /dev/.udev
194     ## end udev ##
195    
  # same thing as /dev/.devfsd  
  touch /dev/.udev  
  fi  
196    
197   ## load devpts ##   ## load devpts ##
198   # 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
199   if [[ $(kernel_major_version) = 2.6 ]]   # check if we really have devpts support
200     if kernel_supports_fs devpts
201   then   then
202   # check if we really have devpts support   # /dev/pts maybe not exists.
203   if kernel_supports_fs devpts   # We only create this directory only if devfs was mounted,
204     # or it will fail as / is still mounted readonly
205     # udev has this dir already, only a sanity check for devfs
206     if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
207     then
208     mkdir -p /dev/pts &> /dev/null || \
209     echo "Could not create /dev/pts !"
210     fi
211    
212     # now mount devpts
213     if [ -d /dev/pts ]
214   then   then
215   # /dev/pts maybe not exists.   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."
216   # We only create this directory only if devfs was mounted,   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
217   # or it will fail as / is still mounted readonly   evaluate_retval
  # 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  
218   fi   fi
219     else
220     # devpts is not supported, give a warning
221     echo -e ${COLRED}"No devpts filesystem found ..."
222     echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
223     echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts,"
224     echo -e ${COLYELLOW}"or no pty's are available."
225     echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel."
226     echo
227     echo -e ${COLYELLOW}"Press any key to continue ..."
228     read
229     fi
230     ## end devpts ##
231    
232    
233     ## load usbfs ##
234     if kernel_supports_fs usbfs
235     then
236     echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..."
237     mount -n -t usbfs usbfs /proc/bus/usb
238     evaluate_retval
239   fi   fi
240     ## end usbfs ##
241    
242   ### services state dir ###   ## services state dir ##
243   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."
244   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
245   evaluate_retval   evaluate_retval

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