Magellan Linux

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

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

revision 3 by niro, Mon Dec 13 22:52:07 2004 UTC revision 1248 by niro, Fri Mar 11 17:18:42 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3    
4  source /etc/sysconfig/rc  source /etc/conf.d/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  # override devicemanager helper functions
14  populate_udev() {  if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]]
15   /sbin/udevstart  then
16     source ${rc_base}/init.d/udev
17   #not provided by sysfs but needed  
18   ln -snf /proc/self/fd /dev/fd  elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
19   ln -snf fd/0 /dev/stdin  then
20   ln -snf fd/1 /dev/stdout   source ${rc_base}/init.d/mdev
21   ln -snf fd/2 /dev/stderr  fi
  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  
   
  return 0  
 }  
22    
23  trap "" INT QUIT TSTP  trap "" INT QUIT TSTP
24    
25  [ "$1" != "" ] && runlevel=$1  [ "$1" != "" ] && runlevel=$1
26    
27  if [ "$runlevel" = "sysinit" ]  if [[ $runlevel = sysinit ]]
28  then  then
29   echo   rc_echo
30   echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"   rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
31   echo -e "\"I'm not a Gentoo-System, I'm a pure LFS\""   rc_echo "Copyright 2001-2011 Niels Rogalla; http://magellan-linux.net"
32   echo   rc_echo
33    
34   #mount proc filesystem, needed for bootsplash;   # mount proc filesystem, needed for bootsplash;
35   #no use of '/etc/rc.d/init.d/mountproc' anymore   # no use of '/etc/rc.d/init.d/mountproc' anymore
36   if [ ! -e /proc/mounts ]   if [ ! -e /proc/mounts ]
37   then   then
38   echo -e ${COLOREDSTAR}"Mounting proc file system ..."   rc_print "Mounting proc file system ..."
39   mount -n /proc   mount -n /proc
40   evaluate_retval   evaluate_retval
41   fi   fi
42    
43   #set default verbose level for kernel messages   # set default verbose level for kernel messages
44   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3   [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
45   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk   echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
46    
47   #mount sys file system before udev or devfs (kernel-2.6)   # mount sys file system before udev
48   if [ "$(kernel_major_version)" == "2.6" ]   if [ -d /sys ]
49   then   then
50   if [ -d /sys ]   rc_print "Mounting sysfs file system ..."
51   then   mount -n -t sysfs sysfs /sys
52   echo -e ${COLOREDSTAR}"Mounting sysfs file system ..."   evaluate_retval
53   mount -t sysfs none /sys   else
54   evaluate_retval   rc_echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
55   else   rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
56   echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."   rc_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  
57   fi   fi
58    
59   ## load devfs ##   # start device management
60   #load devfs only with a 2.4 kernel or its really wanted with a 2.6   start_devicemanager
61   if [ "$(kernel_major_version)" == "2.4" -o "${RC_USED_DEV}" == "devfs" ]  
62     ## load devpts ##
63     # devfs/udev with 2.6 has no ptys, so devpts is also needed
64     # check if we really have devpts support
65     if kernel_supports_fs devpts
66   then   then
67   # start devfsd daemon, needed for bootsplash;   # /dev/pts maybe not exists.
68   # no use of '/etc/rc.d/init.d/devfs' anymore   # We only create this directory only if devfs was mounted,
69   # check if devfs was mounted by the kernel,   # or it will fail as / is still mounted readonly
70   # if not mount it (mbuild_livecd needs this one)   # udev has this dir already, only a sanity check for devfs
71   if [ ! -e /dev/.devfsd ]   if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
72   then   then
73   echo -e ${COLOREDSTAR}"Mounting devfs file system ..."   mkdir -p /dev/pts &> /dev/null || \
74   mount -t devfs devfs /dev   rc_echo "Could not create /dev/pts !"
  evaluate_retval  
75   fi   fi
76    
77     # now mount devpts
78   if [ -e /dev/.devfsd ]   if [ -d /dev/pts ]
79   then   then
80   echo -e ${COLOREDSTAR}"Starting devfsd ..."   rc_print "Mounting devpts at /dev/pts ..."
81   ## directory /lib/dev-state !must! exists ##   mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
  /sbin/devfsd /dev &> /dev/null  
82   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  
83   fi   fi
84     else
85     # devpts is not supported, give a warning
86     rc_echo -e ${COLRED}"No devpts filesystem found ..."
87     rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
88     rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
89     rc_echo -e ${COLYELLOW}"or no pty's are available."
90     rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
91     rc_echo
92     rc_echo -e ${COLYELLOW}"Press any key to continue ..."
93     read
94   fi   fi
95     ## end devpts ##
96    
  #### 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  
97    
98     ## load usbfs ##
99   ## 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 ]  
100   then   then
101   # check if we really have devpts support   rc_print "Mounting usbfs at /proc/bus/usb ..."
102   DEVPTS_CHECK="$(cat /proc/filesystems | grep devpts | cut -d $'\t' -f2)"   mount -n -t usbfs usbfs /proc/bus/usb
103   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  
104   fi   fi
105     ## end usbfs ##
106    
107   ### services state dir ###   ## services state dir ##
108   echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..."   rc_print "Mounting tmpfs at ${svcdir} ..."
109   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
110   evaluate_retval   evaluate_retval
111    
112   #load bootsplash   # load bootsplash
113   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
114  fi  fi
115    
116    
117    if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]]
 if [ "$runlevel" == "0" ]  
118  then  then
119     # load bootsplash
  #load bootsplash  
120   splash "rc_init" "${runlevel}"   splash "rc_init" "${runlevel}"
121    
   
122   # if requested save devices to a device tarball before halt   # if requested save devices to a device tarball before halt
123   # only for kernels >=2.6 *and* udev   # only for kernels >=2.6 *and* udev
124   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd   # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
125   if [ "${RC_DEVICE_TARBALL}" = "yes" \   if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
126   -a -e /dev/.udev \   [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
  -a ! -e /dev/.devfsd ]  
127   then   then
128   echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."   rc_print "Saving /dev device nodes ..."
129   cd /dev   ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
130   tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null   mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
  mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2  
131   evaluate_retval   evaluate_retval
132   fi   fi
 fi  
   
 if [ "$runlevel" == "6" ]  
 then  
133    
134   #load bootsplash   # stop device management
135   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 ]  
  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  
136  fi  fi
137    
138    
139  if [ "$runlevel" = "" ]  if [ "$runlevel" = "" ]
140  then  then
141   echo "Usage: $0 <runlevel>" >&2   rc_echo "Usage: $0 <runlevel>" >&2
142   exit 1   exit 1
143  fi  fi
144    
145    
146  previous=$PREVLEVEL  previous=$PREVLEVEL
147  [ "$previous" = "" ] && previous=N  [ "$previous" = "" ] && previous=N
148    
149  if [ ! -d $rc_base/rc$runlevel.d ]  if [ ! -d $rc_base/rc$runlevel.d ]
150  then  then
151   echo "$rc_base/rc$runlevel.d does not exist"   rc_echo "$rc_base/rc$runlevel.d does not exist"
152   exit 1   exit 1
153  fi  fi
154    
# Line 275  then Line 168  then
168   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]   if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
169   then   then
170   $WARNING   $WARNING
171   echo "$i can't be executed because it was"   rc_echo "$i can't be executed because it was"
172   echo "not started in the previous runlevel ($previous)"   rc_echo "not started in the previous runlevel ($previous)"
173   $NORMAL   $NORMAL
174   continue   continue
175   fi   fi

Legend:
Removed from v.3  
changed lines
  Added in v.1248