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 71 by niro, Tue Mar 15 19:07:56 2005 UTC trunk/initscripts/sysvinit/rc/rc revision 1832 by niro, Tue Jun 26 16:42:54 2012 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 $  # $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  #some needed functions functions  # override devicemanager helper functions
22  populate_udev() {  if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]]
23   /sbin/udevstart  then
24     source ${rc_base}/init.d/udev
  #not provided by sysfs but needed  
  ln -snf /proc/self/fd /dev/fd  
  ln -snf fd/0 /dev/stdin  
  ln -snf fd/1 /dev/stdout  
  ln -snf fd/2 /dev/stderr  
  ln -snf /proc/kcore /dev/core  
  ln -snf /proc/asound/oss/sndstat /dev/sndstat  
   
  #create problematic directories  
  mkdir -p /dev/{pts,shm}  
   
  #same as /dev/.devfsd  
  touch /dev/.udev  
25    
26   return 0  elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
27  }  then
28     source ${rc_base}/init.d/mdev
29    fi
30    
31  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
32    
33  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
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 "\"I'm not a Gentoo-System, I'm a pure LFS\""   rc_echo "Copyright 2001-2012 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
50    
51   #set default verbose level for kernel messages   # set default verbose level for kernel messages
52   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
53   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
54    
55   #mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev
56   if [ "$(kernel_major_version)" == "2.6" ]   if [ -d /sys ]
57   then   then
58   if [ -d /sys ]   if [ ! -e /sys/kernel/notes ]
59   then   then
60   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   rc_print "Mounting sysfs file system ..."
61   mount -t sysfs none /sys   mount -n -t sysfs sysfs /sys
62   evaluate_retval   evaluate_retval
  else  
  echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."  
  echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."  
  echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."  
63   fi   fi
64     else
65     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
69    
70   ## load devfs ##   # start device management
71   #load devfs only with a 2.4 kernel or its really wanted with a 2.6   start_devicemanager
72   if [ "$(kernel_major_version)" == "2.4" -o "${RC_USED_DEV}" == "devfs" ]  
73     ## load devpts ##
74     # devfs/udev with 2.6 has no ptys, so devpts is also needed
75     # check if we really have devpts support
76     if kernel_supports_fs devpts
77   then   then
78   # start devfsd daemon, needed for bootsplash;   # /dev/pts maybe not exists.
79   # no use of '/etc/rc.d/init.d/devfs' anymore   # We only create this directory only if devfs was mounted,
80   # check if devfs was mounted by the kernel,   # or it will fail as / is still mounted readonly
81   # if not mount it (mbuild_livecd needs this one)   # udev has this dir already, only a sanity check for devfs
82   if [ ! -e /dev/.devfsd ]   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
83   then   then
84   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."   mkdir -p /dev/pts &> /dev/null || \
85   mount -t devfs devfs /dev   rc_echo "Could not create /dev/pts !"
  evaluate_retval  
86   fi   fi
87    
88     # now mount devpts
89   if [ -e /dev/.devfsd ]   if [ -d /dev/pts ]
90   then   then
91   echo -e ${COLOREDSTAR}"Starting devfsd ..."   rc_print "Mounting devpts at /dev/pts ..."
92   ## directory /lib/dev-state !must! exists ##   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
  /sbin/devfsd /dev &> /dev/null  
93   evaluate_retval   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  
94   fi   fi
95     else
96     # devpts is not supported, give a warning
97     rc_echo -e ${COLRED}"No devpts filesystem found ..."
98     rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
99     rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
100     rc_echo -e ${COLYELLOW}"or no pty's are available."
101     rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
102     rc_echo
103     rc_echo -e ${COLYELLOW}"Press any key to continue ..."
104     read
105   fi   fi
106     ## end devpts ##
107    
  #### load udev ####  
  #load udev only with a 2.6 kernel  
  if [ "$(kernel_major_version)" == "2.6" -a "${RC_USED_DEV}" == "udev" ]  
  then  
 # #first at all unmount devfs if this was loaded by the kernel  
 # DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"  
 # if [ "${DEVFS_MOUNTED}" == "devfs" ]  
 # then  
 # umount -n /dev \  
 # && 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  
  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 with device nodes ..."  
  tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev  
  evaluate_retval  
  fi  
   
  #now load udev  
  populate_udev  
   
  #if hotplug support exists in the kernel use it to manage udev  
  if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ]  
  then  
  echo -e ${COLOREDSTAR}"  Using /sbin/hotplug for udev management ..."  
   
  elif [ -e /proc/sys/kernel/hotplug ]  
  then  
  echo -e ${COLOREDSTAR}"  Setting /sbin/udev as hotplug agent ..."  
  echo "/sbin/udev" > /proc/sys/kernel/hotplug  
  else  
  echo -e ${COLOREDSTAR}${COLYELLOW}"  Kernel was not compiled with hotplug support !"  
  fi  
  evaluate_retval  
  fi  
108    
109     ## load usbfs ##
110   ## load devpts ##   if kernel_supports_fs usbfs
  # devfs/udev with 2.6 has no ptys, so devpts is also needed  
  if [ $(kernel_major_version) == 2.6 ]  
111   then   then
112   # check if we really have devpts support   rc_print "Mounting usbfs at /proc/bus/usb ..."
113   DEVPTS_CHECK="$(cat /proc/filesystems | grep devpts | cut -d $'\t' -f2)"   mount -n -t usbfs usbfs /proc/bus/usb
114   DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)"   evaluate_retval
  if [ "${DEVPTS_CHECK}" == devpts ]  
  then  
  # /dev/pts maybe not exists.  
  # We only create this directory only if devfs was mounted,  
  # or it will fail as / is still mounted readonly  
  if [ ! -d "/dev/pts" \  
  -a -e "/dev/.devfsd" \  
  -a  "${DEVFS_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 none /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  
  fi  
115   fi   fi
116     ## 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   #load bootsplash   # load bootsplash
124   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
125  fi  fi
126    
127    
128    if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
 if [ "$runlevel" == "0" ]  
129  then  then
130     # load bootsplash
  #load bootsplash  
131   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
132    
   
133   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
134   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
135   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make sure that udev is mounted but *not* devfs --> /dev/.devfsd
136   if [ "${RC_DEVICE_TARBALL}" = "yes" \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
137   -a -e /dev/.udev \   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
138   -a ! -e /dev/.devfsd \   then
139   -a ! -e /.bootdev ]   rc_print "Saving /dev device nodes ..."
140   then   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
141   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
  cd /dev  
  tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null  
  mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2  
142   evaluate_retval   evaluate_retval
143   fi   fi
 fi  
   
 if [ "$runlevel" == "6" ]  
 then  
144    
145   #load bootsplash   # stop device management
146   splash "rc_init" "${runlevel}"   stop_devicemanager
   
  # 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  
147  fi  fi
148    
149    
150  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
151  then  then
152   echo "Usage: $0 <runlevel>" >&2   rc_echo "Usage: $0 <runlevel>" >&2
153   exit 1   exit 1
154  fi  fi
155    
156    
157  previous=$PREVLEVEL  previous=$PREVLEVEL
158  [ "$previous" = "" ] && previous=N  [ "$previous" = "" ] && previous=N
159    
160  if [ ! -d $rc_base/rc$runlevel.d ]  if [ ! -d $rc_base/rc$runlevel.d ]
161  then  then
162   echo "$rc_base/rc$runlevel.d does not exist"   rc_echo "$rc_base/rc$runlevel.d does not exist"
163   exit 1   exit 1
164  fi  fi
165    
# Line 279  then Line 179  then
179   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
180   then   then
181   $WARNING   $WARNING
182   echo "$i can't be executed because it was"   rc_echo "$i can't be executed because it was"
183   echo "not started in the previous runlevel ($previous)"   rc_echo "not started in the previous runlevel ($previous)"
184   $NORMAL   $NORMAL
185   continue   continue
186   fi   fi

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