Magellan Linux

Contents of /trunk/initscripts/busybox/rc/rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1664 - (show annotations) (download)
Fri Jan 20 22:59:46 2012 UTC (12 years, 3 months ago) by niro
File size: 4616 byte(s)
-updated copyright
1 #!/bin/sh
2 # $Header: /home/cvsd/magellan-cvs/magellan-src/busybox-initscripts/rc/rc,v 1.2 2008-12-22 22:09:27 niro Exp $
3
4 source /etc/conf.d/rc
5 source ${rc_functions}
6
7 # source kernel config if exists
8 [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
9
10 # get mage version
11 MAGEVER="$(< /etc/mageversion)"
12
13 # source kernel config if exists
14 [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel
15
16 # override devicemanager helper functions
17 if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]]
18 then
19 source ${rc_base}/init.d/udev
20
21 elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]]
22 then
23 source ${rc_base}/init.d/mdev
24 fi
25
26 trap "" INT QUIT TSTP
27
28 [ "$1" != "" ] && runlevel=$1
29
30 if [[ $runlevel = sysinit ]]
31 then
32 rc_echo
33 rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}"
34 rc_echo "Copyright 2001-2012 Niels Rogalla; http://magellan-linux.net"
35 rc_echo
36
37 # mount proc filesystem, needed for bootsplash;
38 # no use of '/etc/rc.d/init.d/mountproc' anymore
39 if [ ! -e /proc/mounts ]
40 then
41 rc_print "Mounting proc file system ..."
42 mount -n /proc
43 evaluate_retval
44 fi
45
46 # load bootsplash
47 splash "rc_init" "${runlevel}"
48
49 # set default verbose level for kernel messages
50 [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3
51 echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk
52
53 # mount sys file system before udev
54 if [ -d /sys ]
55 then
56 rc_print "Mounting sysfs file system ..."
57 mount -n -t sysfs sysfs /sys
58 evaluate_retval
59 else
60 rc_echo -e ${COLORED}"Fatal: mountpoint /sys missing ..."
61 rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)."
62 rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel."
63 fi
64
65 # start device management
66 start_devicemanager
67
68 ## load devpts ##
69 # devfs/udev with 2.6 has no ptys, so devpts is also needed
70 # check if we really have devpts support
71 if kernel_supports_fs devpts
72 then
73 # /dev/pts maybe not exists.
74 # We only create this directory only if devfs was mounted,
75 # or it will fail as / is still mounted readonly
76 # udev has this dir already, only a sanity check for devfs
77 if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs
78 then
79 mkdir -p /dev/pts &> /dev/null || \
80 rc_echo "Could not create /dev/pts !"
81 fi
82
83 # now mount devpts
84 if [ -d /dev/pts ]
85 then
86 rc_print "Mounting devpts at /dev/pts ..."
87 mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts
88 evaluate_retval
89 fi
90 else
91 # devpts is not supported, give a warning
92 rc_echo -e ${COLRED}"No devpts filesystem found ..."
93 rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem."
94 rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts,"
95 rc_echo -e ${COLYELLOW}"or no pty's are available."
96 rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel."
97 rc_echo
98 rc_echo -e ${COLYELLOW}"Press any key to continue ..."
99 read
100 fi
101 ## end devpts ##
102
103
104 ## load usbfs ##
105 if kernel_supports_fs usbfs
106 then
107 rc_print "Mounting usbfs at /proc/bus/usb ..."
108 mount -n -t usbfs usbfs /proc/bus/usb
109 evaluate_retval
110 fi
111 ## end usbfs ##
112
113 ## services state dir ##
114 rc_print "Mounting tmpfs at ${svcdir} ..."
115 mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k
116 evaluate_retval
117 fi
118
119 if [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]]
120 then
121 # load bootsplash
122 splash "rc_init" "${runlevel}"
123
124 # if requested save devices to a device tarball before halt
125 # only for kernels >=2.6 *and* udev
126 # make shure that udev is mounted but *not* devfs --> /dev/.devfsd
127 if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
128 [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
129 then
130 rc_print "Saving /dev device nodes ..."
131 ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
132 mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2
133 evaluate_retval
134 fi
135
136 # stop device management
137 stop_devicemanager
138
139 # run through all runlevel scripts
140 for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null)
141 do
142 check_script_status
143 suffix=${i#${rc_base}/rc${runlevel}.d/K[0-9][0-9]}
144
145 ${i} stop
146 error_value=$?
147
148 if [[ ${error_value} != 0 ]]
149 then
150 print_error_msg
151 fi
152 done
153 fi
154
155 if [[ ${runlevel} = sysinit ]] || [[ ${runlevel} = boot ]]
156 then
157 for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null)
158 do
159 suffix=${i#${rc_base}/rc${runlevel}.d/S[0-9][0-9]}
160 check_script_status
161
162 ${i} start
163 error_value=$?
164
165 if [[ ${error_value} != 0 ]]
166 then
167 print_error_msg
168 fi
169 done
170 fi
171
172 if [[ ${runlevel} = boot ]]
173 then
174 # exit bootsplash
175 splash "rc_exit" "${runlevel}"
176 fi