Magellan Linux

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

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

trunk/magellan-initscripts/etc/rc.d/init.d/rc revision 694 by niro, Sat Mar 22 19:59:32 2008 UTC trunk/initscripts/sysvinit/rc/rc revision 2049 by niro, Wed Feb 20 08:00:29 2013 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.20 2008-03-22 19:58:58 niro Exp $  # $Id$
3    
4  source /etc/sysconfig/rc  source /etc/conf.d/rc
5  source $rc_functions  source ${rc_functions}
6    
7  # get mage version  # get mage version
8  MAGEVER="$(< /etc/mageversion)"  if [[ -f /etc/os-release ]]
9    then
10     MAGEVER="$(read_os_release version_id)"
11    elif [ -f /etc/mageversion ]
12    then
13     MAGEVER="$(< /etc/mageversion)"
14    else
15     MAGEVER="unkown"
16    fi
17    
18  # source kernel config if exists  # source kernel config if exists
19  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel  [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
20    
21  udev_version()  # override devicemanager helper functions
22  {  if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]]
23   local version=0  then
24     source ${rc_base}/init.d/udev
  if [[ -x /sbin/udev ]]  
  then  
  version=$(/sbin/udev -V)  
  # We need it without a leading '0', else bash do the wrong thing  
  version=${version##0}  
  # Older udev's will print nothing  
  [[ -z ${version} ]] && version=0  
  elif [[ -x /sbin/udevd ]]  
  then  
  version=$(/sbin/udevd --version)  
  version=${version##0}  
  [[ -z ${version} ]] && version=0  
  fi  
   
  echo "${version}"  
 }  
   
 populate_udev()  
 {  
  local opts  
   
  # tell modprobe.sh to be verbose to $CONSOLE  
  echo CONSOLE=${CONSOLE} > /dev/.udev_populate  
   
  # populate /dev with devices already found by the kernel  
  echo -e ${COLOREDSTAR}"  Populating /dev with existing devices through uevents ..."  
  if [[ ${RC_COLDPLUG} = yes ]]  
  then  
  /sbin/udevtrigger  
  else  
  # do not run any init-scripts  
  /sbin/udevadm control --env do_not_run_plug_service=1  
   
  # only create device nodes  
  /sbin/udevtrigger --attr-match=dev  
   
  # run persistent-net stuff  
  /sbin/udevtrigger --subsystem-match=net  
  fi  
  evaluate_retval  
   
  # loop until everything is finished  
  echo -e ${COLOREDSTAR}"  Letting udev process events ..."  
  /sbin/udevsettle --timeout=60  
  evaluate_retval  
   
  # unset this variable  
  udevadm control --env do_not_run_plug_service=  
   
  rm -f /dev/.udev_populate  
  return 0  
 }  
   
 seed_dev()  
 {  
  # seed /dev with some things that we know we need  
  echo -e ${COLOREDSTAR}"  Seeding /dev with needed nodes ..."  
  (  
  [ ! -c /dev/console ] && mknod /dev/console c 5 1  
  [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1  
  [ ! -c /dev/null ] && mknod /dev/null c 1 3  
   
  # copy over any persistant things  
  if [[ -d /lib/udev/devices ]]  
  then  
  cp -RPp /lib/udev/devices/* /dev 2>/dev/null  
  fi  
25    
26   # not provided by sysfs but needed  elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
27   ln -snf /proc/self/fd /dev/fd  then
28   ln -snf fd/0 /dev/stdin   source ${rc_base}/init.d/mdev
29   ln -snf fd/1 /dev/stdout  fi
  ln -snf fd/2 /dev/stderr  
  [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core  
   
  # create problematic directories  
  mkdir -p /dev/pts /dev/shm  
  )  
  evaluate_retval  
 }  
30    
31  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
32    
# Line 101  trap "" INT QUIT TSTP Line 34  trap "" INT QUIT TSTP
34    
35  if [[ $runlevel = sysinit ]]  if [[ $runlevel = sysinit ]]
36  then  then
37   echo   rc_echo
38   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
39   echo -e "Copyright 2001-2008 Niels Rogalla; http://magellan-linux.net"   rc_echo "Copyright 2001-2013 Niels Rogalla; http://magellan-linux.net"
40   echo   rc_echo
41    
42   # mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
43   # no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
44   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
45   then   then
46   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   rc_print "Mounting proc file system ..."
47   mount -n /proc   mount -n /proc
48   evaluate_retval   evaluate_retval
49   fi   fi
# Line 122  then Line 55  then
55   # mount sys file system before udev   # mount sys file system before udev
56   if [ -d /sys ]   if [ -d /sys ]
57   then   then
58   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   if [ ! -e /sys/kernel/notes ]
59   mount -n -t sysfs sysfs /sys   then
60   evaluate_retval   rc_print "Mounting sysfs file system ..."
61   else   mount -n -t sysfs sysfs /sys
62   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   evaluate_retval
63   echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."   fi
  echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."  
  fi  
   
   
  #### load udev ####  
  # check if /dev/console exists outside tmpfs  
  [ -c /dev/console ] ; need_redirect=$?  
   
  # 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,size=10M  
  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 ]]  
  then  
  echo -e ${COLOREDSTAR}"  Populating /dev with saved device nodes ..."  
  tar -jxpf /lib/udev/state/devices.tar.bz2 -C /dev  
  evaluate_retval  
  fi  
   
  # other eeded device nodes with udev  
  seed_dev  
   
  if [ -e /proc/sys/kernel/hotplug ]  
  then  
  echo -e ${COLOREDSTAR}"  Using netlink for hotplug events ..."  
  echo "" > /proc/sys/kernel/hotplug  
  evaluate_retval  
  else  
  echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"  
  print_status failure  
  fi  
   
  echo -e ${COLOREDSTAR}"  Starting udevd daemon ..."  
  if [ ${need_redirect} -eq 1 ]  
  then  
  # we need to open fds 0 1 2  
  /sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console  
64   else   else
65   /sbin/udevd --daemon   rc_echo -e ${COLRED}"Fatal: mountpoint /sys missing ..."
66     rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
67     rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."
68   fi   fi
  evaluate_retval  
   
  # write root_link rule  
  /lib/udev/write_root_link_rule  
  # populate udev device nodes  
  populate_udev  
   
  # create nodes that udev can't  
  echo -e ${COLOREDSTAR}"  Finializing udev configuration ..."  
  [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null  
  [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null  
  [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null  
  print_status success  
   
  # same thing as /dev/.devfsd  
  touch /dev/.udev  
  ## end udev ##  
69    
70     # start device management
71     start_devicemanager
72    
73   ## load devpts ##   ## load devpts ##
74   # 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
# Line 206  then Line 82  then
82   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
83   then   then
84   mkdir -p /dev/pts &> /dev/null || \   mkdir -p /dev/pts &> /dev/null || \
85   echo "Could not create /dev/pts !"   rc_echo "Could not create /dev/pts !"
86   fi   fi
87    
88   # now mount devpts   # now mount devpts
89   if [ -d /dev/pts ]   if [ -d /dev/pts ]
90   then   then
91   echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..."   rc_print "Mounting devpts at /dev/pts ..."
92   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
93   evaluate_retval   evaluate_retval
94   fi   fi
95   else   else
96   # devpts is not supported, give a warning   # devpts is not supported, give a warning
97   echo -e ${COLRED}"No devpts filesystem found ..."   rc_echo -e ${COLRED}"No devpts filesystem found ..."
98   echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."   rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
99   echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts,"   rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
100   echo -e ${COLYELLOW}"or no pty's are available."   rc_echo -e ${COLYELLOW}"or no pty's are available."
101   echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel."   rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
102   echo   rc_echo
103   echo -e ${COLYELLOW}"Press any key to continue ..."   rc_echo -e ${COLYELLOW}"Press any key to continue ..."
104   read   read
105   fi   fi
106   ## end devpts ##   ## end devpts ##
# Line 233  then Line 109  then
109   ## load usbfs ##   ## load usbfs ##
110   if kernel_supports_fs usbfs   if kernel_supports_fs usbfs
111   then   then
112   echo -e ${COLOREDSTAR}"Mounting usbfs at /proc/bus/usb ..."   rc_print "Mounting usbfs at /proc/bus/usb ..."
113   mount -n -t usbfs usbfs /proc/bus/usb   mount -n -t usbfs usbfs /proc/bus/usb
114   evaluate_retval   evaluate_retval
115   fi   fi
116   ## end usbfs ##   ## end usbfs ##
117    
118   ## services state dir ##   ## services state dir ##
119   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."   rc_print "Mounting tmpfs at ${svcdir} ..."
120   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
121   evaluate_retval   evaluate_retval
122    
123     ## /run /tmp /var/lock
124     for i in /run /tmp /var/lock
125     do
126     if [ -d ${i} ]
127     then
128     rc_print "Mounting tmpfs at ${i} ..."
129     mount -n -t tmpfs tmpfs ${i} -o rw,nosuid,nodev,relatime
130     evaluate_retval
131     fi
132     done
133     # extra check for /var/lock
134     if [ -L /var/lock ]
135     then
136     mkdir -p /run/lock
137     rc_print "Mounting tmpfs at /run/lock ..."
138     mount -n -t tmpfs tmpfs /run/lock -o rw,nosuid,nodev,relatime
139     evaluate_retval
140     fi
141     # extra check if /run and /var/run are directories
142     if [ -d /run ] && [ -d /var/run ]
143     then
144     rc_print "Mounting tmpfs at /var/run ..."
145     mount -n -o bind /run /var/run
146     evaluate_retval
147     fi
148    
149   # load bootsplash   # load bootsplash
150   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
151  fi  fi
# Line 256  then Line 158  then
158    
159   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
160   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
161   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make sure that udev is mounted but *not* devfs --> /dev/.devfsd
162   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
163   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
164   then   then
165   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   rc_print "Saving /dev device nodes ..."
166   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
167   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
168   evaluate_retval   evaluate_retval
169   fi   fi
170    
171     # stop device management
172     stop_devicemanager
173  fi  fi
174    
175    
176  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
177  then  then
178   echo "Usage: $0 <runlevel>" >&2   rc_echo "Usage: $0 <runlevel>" >&2
179   exit 1   exit 1
180  fi  fi
181    
# Line 280  previous=$PREVLEVEL Line 185  previous=$PREVLEVEL
185    
186  if [ ! -d $rc_base/rc$runlevel.d ]  if [ ! -d $rc_base/rc$runlevel.d ]
187  then  then
188   echo "$rc_base/rc$runlevel.d does not exist"   rc_echo "$rc_base/rc$runlevel.d does not exist"
189   exit 1   exit 1
190  fi  fi
191    
# Line 300  then Line 205  then
205   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
206   then   then
207   $WARNING   $WARNING
208   echo "$i can't be executed because it was"   rc_echo "$i can't be executed because it was"
209   echo "not started in the previous runlevel ($previous)"   rc_echo "not started in the previous runlevel ($previous)"
210   $NORMAL   $NORMAL
211   continue   continue
212   fi   fi

Legend:
Removed from v.694  
changed lines
  Added in v.2049