Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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