]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
7742e157 AF |
2 | # |
3 | # /etc/rc.d/rc.sysinit - run once at boot time | |
ec8b15cb | 4 | # $Id$ |
7742e157 AF |
5 | # |
6 | # Taken in part from Miquel van Smoorenburg's bcheckrc. | |
7 | # | |
8 | ||
b6509675 AM |
9 | # reasonable start values for bootsplash progress. |
10 | export progress=0 | |
11 | export sscripts=45 | |
12 | export kscripts=45 | |
13 | ||
38198f50 | 14 | # NLS |
de1fc6ce | 15 | if [ -r /etc/sysconfig/i18n ]; then |
38198f50 AM |
16 | . /etc/sysconfig/i18n |
17 | [ -n "$LANG" ] && export LANG || unset LANG | |
18 | [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE | |
19 | [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE | |
20 | [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES | |
21 | [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC | |
22 | [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY | |
23 | [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME | |
24 | [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL | |
25 | [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE | |
26 | [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS | |
27 | fi | |
28 | ||
418c0cf3 | 29 | # Read network config data |
de1fc6ce | 30 | if [ -r /etc/sysconfig/network ]; then |
1b228409 | 31 | . /etc/sysconfig/network |
7742e157 | 32 | else |
1b228409 | 33 | NETWORKING=no |
34 | HOSTNAME=localhost | |
7742e157 AF |
35 | fi |
36 | ||
277e5f53 | 37 | CONSOLE_LOGLEVEL=1 |
45e88cd0 | 38 | |
e298d489 | 39 | # Read functions |
0bf0a92d | 40 | . /lib/rc-scripts/functions |
e298d489 | 41 | |
5d68f1bb ER |
42 | modprobe_c_cache="" |
43 | modprobe_c() { | |
44 | if [ "$modprobe_c_cache" ]; then | |
45 | echo "$modprobe_c_cache" | |
46 | return | |
47 | fi | |
48 | modprobe_c_cache=$(modprobe -c) | |
49 | } | |
50 | ||
236aa13c ER |
51 | # parse kernel cmdline |
52 | # needs /proc mounted | |
53 | parse_cmdline() { | |
54 | read cmdline < /proc/cmdline | |
55 | local arg | |
56 | ||
57 | for arg in $cmdline; do | |
58 | case "$arg" in | |
59 | pld.no-upstart) | |
60 | # default is set in /etc/sysconfig/system or detected in init.d/functions | |
61 | USE_UPSTART=no | |
62 | ;; | |
63 | noudev) | |
64 | # default is set in /etc/sysconfig/system | |
65 | START_UDEV=no | |
66 | ;; | |
09b13698 ER |
67 | nomdadm) |
68 | # default is set in /etc/sysconfig/system | |
69 | MDADM=no | |
70 | ;; | |
e7423cfb ER |
71 | nomultipath) |
72 | # default is set in /etc/sysconfig/system | |
73 | DM_MULTIPATH=no | |
74 | ;; | |
236aa13c ER |
75 | nousb) |
76 | nousb=1 | |
77 | ;; | |
78 | nohdparm) | |
79 | nohdparm=1 | |
80 | ;; | |
81 | fastboot) | |
82 | fastboot=1 | |
83 | ;; | |
84 | nopnp) | |
85 | nopnp=1 | |
86 | ;; | |
87 | nomodules) | |
88 | nomodules=1 | |
89 | ;; | |
90 | nofirewire) | |
91 | nofirewire=1 | |
92 | ;; | |
93 | nofsck) | |
94 | nofsck=1 | |
95 | ;; | |
96 | esac | |
97 | done | |
98 | } | |
99 | ||
483f1dda | 100 | disable_selinux() { |
944d6d80 | 101 | local _d selinuxfs _t _r |
483f1dda ER |
102 | |
103 | while read _d selinuxfs _t _r; do | |
104 | [ "$_t" = "selinuxfs" ] && break | |
105 | done </proc/mounts | |
106 | echo "*** Warning -- SELinux is active" | |
107 | echo "*** Disabling security enforcement for system recovery." | |
108 | echo "*** Run 'setenforce 1' to reenable." | |
109 | echo "0" > $selinuxfs/enforce | |
110 | } | |
111 | ||
112 | relabel_selinux() { | |
944d6d80 | 113 | local _d selinuxfs _t _r |
483f1dda ER |
114 | |
115 | while read _d selinuxfs _t _r; do | |
116 | [ "$_t" = "selinuxfs" ] && break | |
117 | done </proc/mounts | |
118 | echo " | |
119 | *** Warning -- SELinux relabel is required. *** | |
120 | *** Disabling security enforcement. *** | |
121 | *** Relabeling could take a very long time, *** | |
122 | *** depending on file system size. *** | |
123 | " | |
124 | echo "0" > $selinuxfs/enforce | |
125 | /sbin/fixfiles -F relabel > /dev/null 2>&1 | |
126 | rm -f /.autorelabel | |
127 | echo "*** Enabling security enforcement. ***" | |
128 | echo $SELINUX > $selinuxfs/enforce | |
129 | } | |
130 | ||
131 | # Remove duplicate entries from mtab (for vserver guest use only) | |
132 | clean_vserver_mtab() { | |
e99ccdf7 | 133 | > /etc/mtab.clean |
483f1dda ER |
134 | while read device mountpoint line; do |
135 | grep -qs "$mountpoint" /etc/mtab.clean || \ | |
136 | echo "$device $mountpoint $line" >> /etc/mtab.clean | |
137 | done < /etc/mtab | |
138 | cat /etc/mtab.clean > /etc/mtab | |
139 | rm -f /etc/mtab.clean | |
140 | } | |
141 | ||
3aabb390 ER |
142 | # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z |
143 | load_kernel_modules() { | |
de2057b8 | 144 | local modules_file=$1 |
c50336f0 | 145 | local _x _y _z v v1 old_IFS kernel kerneleq |
3aabb390 | 146 | { |
c50336f0 | 147 | read _x _y v _z |
3aabb390 | 148 | old_IFS=$IFS |
c50336f0 ER |
149 | # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1" |
150 | IFS='_-' | |
3aabb390 | 151 | set -- $v |
c50336f0 ER |
152 | v1=${1} |
153 | IFS='.' | |
154 | set -- $v1 | |
3aabb390 | 155 | IFS=$old_IFS |
c50336f0 | 156 | |
3aabb390 ER |
157 | kernel="$1.$2" |
158 | kerneleq="$1.$2.$3" | |
159 | } < /proc/version | |
160 | ||
0aa81245 | 161 | local module args |
3aabb390 ER |
162 | # Loop over every line in modules file |
163 | ( \ | |
de2057b8 | 164 | grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null |
3aabb390 ER |
165 | echo '' # make sure there is a LF at the end |
166 | ) | while read module args; do | |
167 | [ -z "$module" ] && continue | |
55bf7b40 ER |
168 | # strip comments |
169 | args=${args%%#*} | |
a37cb065 JR |
170 | show "Loading %s kernel module(s)" "$module" |
171 | busy | |
172 | modprobe -s $module -- $args && ok || fail | |
3aabb390 ER |
173 | done |
174 | } | |
483f1dda | 175 | |
069c8901 ER |
176 | # launch repair shell |
177 | # which after exiting will reboot | |
178 | repair_shell() { | |
179 | local reason="$2" | |
180 | ||
181 | # don't use '\n' in nls macro ! | |
182 | echo | |
183 | echo | |
184 | echo "$reason" | |
185 | nls "*** Dropping you to a shell; the system will reboot" | |
186 | nls "*** when you leave the shell." | |
187 | echo | |
188 | ||
189 | [ "$SELINUX" = "1" ] && disable_selinux | |
190 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then | |
191 | /sbin/sulogin | |
192 | else | |
193 | /bin/sh | |
194 | fi | |
195 | ||
196 | run_cmd "Unmounting file systems" umount -a | |
197 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
198 | run_cmd "Automatic reboot in progress" reboot | |
199 | } | |
200 | ||
c5aca554 ER |
201 | check_root_fs() { |
202 | show "Checking root filesystem"; started | |
203 | initlog -c "fsck -C -T -a $fsckoptions /" | |
204 | rc=$? | |
205 | ||
206 | # A return of 4 or higher means there were serious problems. | |
207 | if [ $rc -gt 3 ]; then | |
208 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
c5aca554 ER |
209 | |
210 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 | |
069c8901 | 211 | repair_shell "$(nls '*** An error occurred during the file system check.')" |
c5aca554 | 212 | |
c5aca554 ER |
213 | # A return of 2 or 3 means that filesystem was repaired but we need |
214 | # to reboot. | |
215 | elif [ "$rc" = "2" -o "$rc" = "3" ]; then | |
216 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
217 | echo | |
218 | nls "*** Filesystem was repaired but system needs to be" | |
219 | nls "*** rebooted before mounting it." | |
220 | nls "*** REBOOTING ***" | |
221 | echo | |
222 | ||
223 | run_cmd "Unmounting file systems" umount -a | |
224 | mount -n -o remount,ro / | |
225 | run_cmd "Automatic reboot in progress" reboot | |
226 | elif [ "$rc" = "1" ]; then | |
227 | _RUN_QUOTACHECK=1 | |
228 | fi | |
229 | } | |
230 | ||
09b13698 ER |
231 | # Add raid devices |
232 | init_mdadm() { | |
233 | if [ ! -x /sbin/mdadm -o ! -f /etc/mdadm.conf ]; then | |
234 | return | |
235 | fi | |
236 | ||
237 | modprobe -s md | |
238 | local rc=0 | |
239 | if [ -f /proc/mdstat ]; then | |
240 | golvm=0 | |
241 | ||
242 | if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf; then | |
243 | show "Starting up RAID devices"; busy | |
244 | /sbin/mdadm --assemble --scan --auto=yes | |
245 | rc=$? | |
246 | if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then | |
247 | # rc is used later, too so set sane value | |
248 | rc=0 | |
249 | deltext; ok | |
250 | golvm=1 | |
251 | else | |
252 | deltext; fail | |
253 | fi | |
254 | ||
255 | fi | |
256 | ||
257 | # A non-zero return means there were problems | |
258 | if [ $rc -gt 0 ]; then | |
259 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
260 | show "Starting up RAID devices"; fail | |
261 | ||
262 | PS1="$(nls '(RAID Repair)# ')"; export PS1 | |
263 | repair_shell "$(nls '*** An error occurred during the RAID startup.')" | |
264 | fi | |
265 | ||
266 | # LVM on RAID (keep in sync with LVM init) | |
267 | if [ "$golvm" -eq "1" ]; then | |
268 | if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then | |
269 | run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking | |
270 | run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit | |
271 | [ "$lvmversion" = "2" ] && /sbin/vgmknodes | |
272 | fi | |
273 | fi | |
274 | show "Starting up RAID devices"; ok | |
275 | fi | |
276 | return $rc | |
277 | } | |
278 | ||
279 | # Init LVM | |
280 | init_lvm() { | |
281 | if [ ! -x /sbin/vgscan -o ! -x /sbin/vgchange ] && ! is_yes "$EVMS_LVM"; then | |
282 | return | |
283 | fi | |
284 | ||
285 | if is_no "$LVM2"; then | |
286 | lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}') | |
287 | else | |
288 | lvmversion=2 | |
289 | fi | |
290 | ||
291 | if [ "$lvmversion" = "1" ] ; then | |
292 | modprobe -s lvm-mod | |
293 | lvmignorelocking="" | |
294 | lvmsysinit="" | |
295 | elif [ "$lvmversion" = "2" ] ; then | |
296 | modprobe -s dm-mod | |
297 | lvmignorelocking="--ignorelockingfailure" | |
298 | lvmsysinit="--sysinit" | |
299 | else | |
300 | modprobe -s lvm-mod | |
301 | # device mapper (2.5+ and patched 2.4) | |
302 | modprobe -s dm-mod | |
303 | lvmignorelocking="" | |
304 | lvmsysinit="" | |
305 | fi | |
306 | ||
307 | run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking | |
308 | run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit | |
309 | if [ "$lvmversion" = "2" ]; then | |
310 | /sbin/vgmknodes $lvmignorelocking | |
311 | # display VG statistics | |
312 | /sbin/vgdisplay -s $lvmignorelocking | |
313 | fi | |
314 | } | |
315 | ||
e90f4b95 | 316 | # boot logging to /var/log/boot.log. install showconsole package to get it. |
614dceb7 | 317 | if ! is_no "$RC_BOOTLOG" && [ -x /sbin/blogd ]; then |
48e500cd ER |
318 | RC_BOOTLOG=1 |
319 | else | |
320 | RC_BOOTLOG= | |
321 | fi | |
322 | ||
e82c451c ER |
323 | if ! is_yes "$VSERVER"; then |
324 | # we need /proc mounted before everything | |
325 | is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc | |
326 | ||
236aa13c ER |
327 | parse_cmdline |
328 | ||
6077f270 JR |
329 | if [ -d /run ]; then |
330 | is_fsmounted tmpfs /run || mount -n -t tmpfs run /run | |
331 | fi | |
332 | ||
f6a3c408 AO |
333 | # Early sysctls |
334 | sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1 | |
335 | ||
5163449d | 336 | # sysfs is also needed before any other things (under kernel > 2.5) |
dbb15f89 | 337 | if grep -q sysfs /proc/filesystems 2>/dev/null; then |
90f9c9ad | 338 | is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys |
dbb15f89 | 339 | if grep -q securityfs /proc/filesystems 2>/dev/null; then |
8ea815c5 | 340 | mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security |
5163449d | 341 | fi |
defac991 | 342 | fi |
e298d489 | 343 | |
5163449d | 344 | # selinux |
3f9e71a5 | 345 | if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then |
5163449d JR |
346 | mount -n -o gid=17 -t selinuxfs selinuxfs /selinux |
347 | fi | |
e298d489 | 348 | |
ffe19b59 | 349 | # PLD Linux LiveCD support |
01b60fd3 JR |
350 | if [ -x /etc/rc.d/rc.live ]; then |
351 | /etc/rc.d/rc.live | |
352 | fi | |
e298d489 | 353 | |
01b60fd3 JR |
354 | # Choose Hardware profile |
355 | if [ -f /etc/sysconfig/hwprof ]; then | |
356 | . /etc/sysconfig/hwprof | |
357 | if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then | |
358 | mount -n / -o rw,remount | |
359 | /sbin/hwprofile -qf | |
360 | mount -n / -o ro,remount | |
361 | fi | |
5e6dfc29 | 362 | fi |
e298d489 | 363 | |
01b60fd3 | 364 | # Disable splash when requested |
402378e6 | 365 | is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash |
5b0f5a94 | 366 | |
c5e74817 ER |
367 | # Check SELinux status |
368 | selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null) | |
369 | SELINUX= | |
370 | if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then | |
371 | if [ -r $selinuxfs/enforce ] ; then | |
372 | SELINUX=$(cat $selinuxfs/enforce) | |
373 | else | |
374 | # assume enforcing if you can't read it | |
375 | SELINUX=1 | |
376 | fi | |
5e6dfc29 | 377 | fi |
677fdd75 | 378 | |
3f9e71a5 | 379 | if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then |
c5e74817 ER |
380 | /sbin/restorecon -R /dev 2>/dev/null |
381 | fi | |
677fdd75 | 382 | |
7e16b45e ER |
383 | [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)" |
384 | ||
c5e74817 ER |
385 | if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then |
386 | /sbin/setsysfont | |
387 | fi | |
12c4fb70 | 388 | fi |
5b0f5a94 | 389 | |
652dbae5 | 390 | |
458f14b7 | 391 | # Print welcome message |
503bfc80 | 392 | nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)" |
8a917f32 | 393 | if ! is_no "$RC_PROMPT"; then |
503bfc80 | 394 | nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)" |
6b4a354c | 395 | echo |
6b4a354c | 396 | fi |
201c98b9 | 397 | |
cc10e704 | 398 | # Set the hostname |
499b251c | 399 | if [ -z "${HOSTNAME}" ]; then |
dbb15f89 | 400 | show "$(nls 'Host:') $(hostname)"; ok |
499b251c JR |
401 | else |
402 | run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME} | |
403 | fi | |
6956336c | 404 | |
cc10e704 JR |
405 | # Set the NIS domain name |
406 | if [ -n "$NISDOMAIN" ]; then | |
407 | run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN | |
408 | else | |
409 | domainname "" | |
4289a4ff AM |
410 | fi |
411 | ||
cc10e704 JR |
412 | if ! is_yes "$VSERVER"; then |
413 | # Set console loglevel | |
414 | if [ -n "$CONSOLE_LOGLEVEL" ]; then | |
5bf237b7 | 415 | dmesg -n $CONSOLE_LOGLEVEL |
cc10e704 | 416 | fi |
6bf50269 | 417 | |
f42edf6b | 418 | if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then |
1cf0bc6a | 419 | is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev |
de2057b8 | 420 | load_kernel_modules modules.preudev |
06657d6e | 421 | /sbin/start_udev |
848d08f5 | 422 | use_upstart && [ -x /sbin/initctl ] && /sbin/initctl -q start udev |
06657d6e | 423 | elif [ -x /lib/firmware/firmware-loader.sh ]; then |
03770dfc | 424 | /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1 |
348aacfc | 425 | fi |
5e6dfc29 | 426 | |
6a8f0f05 | 427 | # Unmount the initrd, if necessary |
426e1497 | 428 | if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then |
426e1497 | 429 | umount /initrd/dev 2>/dev/null |
6a8f0f05 ER |
430 | umount /initrd |
431 | /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 | |
432 | fi | |
433 | ||
33c6207a ER |
434 | # Start logging console output since we have all /dev stuff setup |
435 | if [ "$RC_BOOTLOG" ]; then | |
0868c9a6 | 436 | /sbin/blogd |
33c6207a ER |
437 | fi |
438 | ||
cc10e704 JR |
439 | # Configure Linux kernel (initial configuration, some required modules still |
440 | # may be missing). | |
5bf237b7 | 441 | sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1 |
201c98b9 | 442 | |
cc10e704 | 443 | # Check if timezone definition is available |
75185230 | 444 | if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then |
37932add | 445 | if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then |
cc10e704 JR |
446 | show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok |
447 | fi | |
448 | else | |
449 | TIME_SETUP_DELAYED=yes | |
450 | fi | |
7742e157 | 451 | |
af116dbe | 452 | delay_cryptsetup=0 |
6b496866 | 453 | if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then |
dd23d50d ER |
454 | # XXX might need modules dep |
455 | # Device mapper & related initialization | |
a51d5138 | 456 | if ! grep -qF device-mapper /proc/devices; then |
dbb15f89 | 457 | modprobe -s dm-mod |
dd23d50d ER |
458 | fi |
459 | ||
dd23d50d | 460 | . /etc/rc.d/init.d/cryptsetup |
8710c4b5 | 461 | show "Starting disk encryption" |
39b4e340 ER |
462 | init_crypto 0 |
463 | delay_cryptsetup=$? | |
464 | [ $delay_cryptsetup = 0 ] && ok || fail | |
dd23d50d ER |
465 | fi |
466 | ||
cc10e704 JR |
467 | # Start up swapping |
468 | run_cmd "Activating swap partitions" swapon -a -e | |
469 | ||
470 | # Initialize USB controllers | |
471 | usb=0 | |
236aa13c | 472 | if [ -z "$nousb" ] && ! is_fsmounted usbfs /proc/bus/usb; then |
5d68f1bb | 473 | aliases=$(modprobe_c | awk '/^alias[\t ]+usb-controller/ { print $3 }') |
cc10e704 | 474 | if [ -n "$aliases" -a "$aliases" != "off" ] ; then |
dbb15f89 | 475 | modprobe -s usbcore |
cc10e704 JR |
476 | for alias in $aliases ; do |
477 | [ "$alias" = "off" ] && continue | |
dbb15f89 | 478 | run_cmd "$(nls 'Initializing USB controller') ($alias)" modprobe -s $alias |
cc10e704 JR |
479 | done |
480 | [ $? -eq 0 -a -n "$aliases" ] && usb=1 | |
481 | fi | |
482 | if grep -iq "usb" /proc/devices 2>/dev/null ; then | |
483 | usb=1 | |
484 | fi | |
485 | fi | |
7742e157 | 486 | |
dfb009d6 | 487 | if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! is_fsmounted usbfs /proc/bus/usb ; then |
a40bbbec | 488 | run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb |
b3965b3d | 489 | fi |
b3965b3d | 490 | |
cc10e704 JR |
491 | needusbstorage= |
492 | if [ "$usb" = "1" ]; then | |
bc325aa3 | 493 | needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null) |
cc10e704 | 494 | if [ "$(kernelverser)" -lt "002006" ]; then |
dbb15f89 | 495 | grep -Fq 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe -s hid |
5e6dfc29 JR |
496 | mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null) |
497 | kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null) | |
498 | if [ -n "$kbdoutput" ]; then | |
dbb15f89 | 499 | run_cmd "Initializing USB keyboard" modprobe -s keybdev |
5e6dfc29 JR |
500 | fi |
501 | if [ -n "$mouseoutput" ]; then | |
dbb15f89 | 502 | run_cmd "Initializing USB mouse" modprobe -s mousedev |
5e6dfc29 | 503 | fi |
cc10e704 JR |
504 | fi |
505 | fi | |
b3965b3d | 506 | |
cc10e704 | 507 | # Setup hdparm thing (if exists and is needed) |
236aa13c | 508 | if [ -z "$nohdparm" ]; then |
cc10e704 | 509 | [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm |
ebd1845b | 510 | fi |
b3965b3d | 511 | |
236aa13c ER |
512 | if [ -z "$fastboot" ] && [ -f /fastboot ]; then |
513 | fastboot=1 | |
cc10e704 | 514 | fi |
03f9cfee | 515 | |
cc10e704 JR |
516 | if [ -f /fsckoptions ]; then |
517 | fsckoptions=$(cat /fsckoptions) | |
518 | else | |
519 | fsckoptions='' | |
520 | fi | |
cb4d1aa7 | 521 | |
cc10e704 JR |
522 | if [ -f /forcefsck ]; then |
523 | fsckoptions="-f $fsckoptions" | |
790968dd ER |
524 | else |
525 | # Obey the fs_passno setting for / (see fstab(5)) | |
526 | # - find the / entry | |
6fe4e4eb ER |
527 | # - make sure we have at least 6 fields |
528 | _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab) | |
cc10e704 | 529 | fi |
7742e157 | 530 | |
cc10e704 | 531 | _RUN_QUOTACHECK=0 |
dc12b33c | 532 | _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab) |
2fce16f9 | 533 | _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null) |
cc10e704 | 534 | |
f42edf6b | 535 | if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "aufs" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_TYPE" != "squashfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ] && [[ "$container" != lxc* ]]; then |
c5aca554 | 536 | check_root_fs |
cb4d1aa7 | 537 | fi |
7742e157 | 538 | |
cc10e704 | 539 | # set up pnp and kernel pnp |
07e4dd15 ER |
540 | if is_yes "$RUN_USERPNP" || is_yes "$RUN_KERNELPNP"; then |
541 | if [ -z "$nopnp" ] && is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then | |
5e6dfc29 JR |
542 | run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf |
543 | fi | |
07e4dd15 | 544 | if [ -z "$nopnp" ] && is_yes "$RUN_KERNELPNP"; then |
dbb15f89 | 545 | modprobe -s isa-pnp |
5e6dfc29 JR |
546 | if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then |
547 | show "Setting up ISA PNP devices (kernelspace pnp)"; busy | |
548 | grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail) | |
549 | fi | |
cc10e704 | 550 | fi |
b68f99e5 | 551 | fi |
7742e157 | 552 | |
41c877f2 | 553 | _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab) |
cc10e704 | 554 | # Remount the root filesystem read-write |
41c877f2 | 555 | if [ -z "$_ROOTFS_RO" ]; then |
47e385fd | 556 | run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw / |
557 | fi | |
cee18a41 | 558 | |
cc10e704 JR |
559 | # Update quotas if fsck was run on / |
560 | if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then | |
561 | run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug / | |
562 | fi | |
aa362992 | 563 | |
5475bb0f ER |
564 | # Clean up SELinux labels |
565 | if [ -n "$SELINUX" ]; then | |
dbb15f89 | 566 | for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache; do |
5475bb0f ER |
567 | [ -r $file ] && restorecon $file >/dev/null 2>&1 |
568 | done | |
569 | fi | |
652dbae5 | 570 | |
39b4e340 | 571 | if [ "$delay_cryptsetup" != 0 ]; then |
1b05bb8a | 572 | show "Starting disk encryption using the RNG" |
39b4e340 ER |
573 | init_crypto 1 |
574 | delay_cryptsetup=$? | |
575 | [ $delay_cryptsetup = 0 ] && ok || fail | |
dd23d50d | 576 | fi |
652dbae5 ER |
577 | else |
578 | # Start logging console output since we have all /dev stuff setup | |
579 | if [ "$RC_BOOTLOG" ]; then | |
580 | /sbin/blogd -q | |
581 | fi | |
677fdd75 | 582 | fi |
5e6dfc29 | 583 | |
cb4d1aa7 | 584 | # Remove stale backups |
47e385fd | 585 | rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1 |
cb4d1aa7 | 586 | |
ef05209d JR |
587 | # Remove /etc/nologin when starting system |
588 | [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot | |
589 | ||
277e5f53 | 590 | if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then |
ef05209d JR |
591 | show "Enabling Delay Login"; busy |
592 | echo > /etc/nologin | |
593 | nls "System bootup in progress - please wait" >> /etc/nologin | |
594 | echo >> /etc/nologin | |
595 | chmod 644 /etc/nologin | |
596 | cp -fp /etc/nologin /etc/nologin.boot | |
597 | ok | |
598 | fi | |
599 | ||
600 | # The root filesystem is now read-write, so we can now log via | |
601 | # syslog() directly... | |
602 | if [ -n "$IN_INITLOG" ]; then | |
603 | IN_INITLOG="" | |
604 | fi | |
605 | ||
cc10e704 | 606 | if ! is_yes "$VSERVER"; then |
220df3e7 | 607 | # Clear mtab |
e99ccdf7 ER |
608 | > /etc/mtab |
609 | [ -f /etc/cryptomtab ] && > /etc/cryptomtab | |
220df3e7 | 610 | |
34c624e7 | 611 | # Enter root, /proc, /sys and other into mtab. |
bdb9cdd9 AM |
612 | mount -f / 2> /dev/null |
613 | mount -f /proc 2> /dev/null | |
1cf0bc6a JR |
614 | if is_fsmounted devtmpfs /dev; then |
615 | mount -f -t devtmpfs devtmpfs /dev 2> /dev/null | |
616 | fi | |
6077f270 | 617 | if is_fsmounted tmpfs /run; then |
bdb9cdd9 | 618 | mount -f -t tmpfs run /run 2> /dev/null |
6077f270 JR |
619 | fi |
620 | ||
3f9e71a5 | 621 | if is_fsmounted usbfs /proc/bus/usb; then |
bdb9cdd9 | 622 | mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null |
3f9e71a5 | 623 | fi |
7d45bad6 | 624 | |
3f9e71a5 | 625 | if is_fsmounted sysfs /sys; then |
bdb9cdd9 | 626 | mount -f -t sysfs sysfs /sys 2> /dev/null |
3f9e71a5 | 627 | if is_fsmounted securityfs /sys/kernel/security ; then |
bdb9cdd9 | 628 | mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null |
defac991 | 629 | fi |
cc10e704 | 630 | fi |
ad084d91 | 631 | |
3f9e71a5 | 632 | if is_fsmounted selinuxfs /selinux; then |
bdb9cdd9 | 633 | mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null |
cc10e704 | 634 | fi |
cb4d1aa7 | 635 | |
cc311639 JK |
636 | emit --no-wait root-filesystem |
637 | emit --no-wait virtual-filesystems | |
fd6887dc | 638 | |
cc10e704 JR |
639 | if [ ! -f /proc/modules ]; then |
640 | USEMODULES= | |
236aa13c | 641 | elif [ -z "$nomodules" ]; then |
cc10e704 JR |
642 | USEMODULES=y |
643 | else | |
644 | USEMODULES= | |
4cc4301b | 645 | fi |
de1fc6ce | 646 | |
0b38e7f1 | 647 | uname_r=$(uname -r) |
cc10e704 JR |
648 | # Adjust symlinks as necessary in /boot to keep system services from |
649 | # spewing messages about mismatched System maps and so on. | |
277e5f53 | 650 | if ! is_no "$SET_SLINKS"; then |
c14f9857 ER |
651 | if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then |
652 | ln -s -f System.map-$uname_r /boot/System.map | |
cc10e704 | 653 | fi |
c14f9857 ER |
654 | if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then |
655 | ln -s -f System.map-$uname_r /boot/System.map | |
cc10e704 | 656 | fi |
418c0cf3 | 657 | fi |
7742e157 | 658 | |
cc10e704 JR |
659 | # Run depmod if RUN_DEPMOD != "no" and: |
660 | # a) user requested or RUN_DEPMOD=""; | |
661 | # b) modules.dep is missing | |
cc10e704 JR |
662 | if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then |
663 | if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then | |
664 | run_cmd "Finding module dependencies" depmod -a | |
0b38e7f1 | 665 | elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then |
cc10e704 JR |
666 | run_cmd "Finding module dependencies" depmod -A |
667 | fi | |
aa362992 | 668 | fi |
0b38e7f1 | 669 | unset uname_r |
5bb58804 | 670 | |
cc10e704 JR |
671 | if [ -f /proc/sys/kernel/modprobe ]; then |
672 | if [ -n "$USEMODULES" ]; then | |
673 | sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1 | |
cc10e704 JR |
674 | else |
675 | # We used to set this to NULL, but that causes | |
676 | # 'failed to exec' messages" | |
677 | sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1 | |
cc10e704 | 678 | fi |
cb4d1aa7 | 679 | fi |
cb4d1aa7 | 680 | |
cc10e704 JR |
681 | # Load usb storage here, to match most other things |
682 | if [ -n "$needusbstorage" ]; then | |
dbb15f89 | 683 | modprobe -s usb-storage |
cc10e704 | 684 | fi |
cb4d1aa7 | 685 | |
cc10e704 | 686 | # Load firewire devices |
236aa13c | 687 | if [ -z "$nofirewire" ]; then |
5d68f1bb | 688 | aliases=$(modprobe_c | awk '/^alias ieee1394-controller/ { print $3 }') |
cc10e704 | 689 | if [ -n "$aliases" -a "$aliases" != "off" ] ; then |
5e6dfc29 JR |
690 | for alias in $aliases ; do |
691 | [ "$alias" = "off" ] && continue | |
dbb15f89 | 692 | run_cmd "$(nls 'Initializing firewire controller') ($alias)" modprobe $alias |
5e6dfc29 | 693 | done |
dbb15f89 | 694 | grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && modprobe -s sbp2 |
cc10e704 | 695 | fi |
5e6dfc29 JR |
696 | fi |
697 | ||
cc10e704 | 698 | # Load sound modules if they need persistent DMA buffers |
5d68f1bb | 699 | if modprobe_c | grep -q "^options sound dmabuf=1"; then |
cc10e704 | 700 | RETURN=0 |
5d68f1bb | 701 | alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }') |
cc10e704 JR |
702 | if [ -n "$alias" -a "$alias" != "off" ] ; then |
703 | run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias | |
704 | RETURN=$? | |
705 | fi | |
5d68f1bb | 706 | alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }') |
cc10e704 JR |
707 | if [ -n "$alias" -a "$alias" != "off" ] ; then |
708 | run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias | |
709 | RETURN=$? | |
f47acf6f JR |
710 | fi |
711 | fi | |
472fa41e | 712 | |
cc10e704 | 713 | # Load modules |
5c62cff4 | 714 | if ! use_upstart; then |
de2057b8 | 715 | load_kernel_modules modules |
6bd4314e ER |
716 | for f in /etc/modules-load.d/*.conf; do |
717 | # already loaded by implicit "modules" load | |
718 | [ "${f##*/}" = "modules.conf" ] && continue | |
719 | ||
3741c52c JR |
720 | [ -r $f ] || continue |
721 | load_kernel_modules ${f##/etc/} | |
722 | done | |
5c62cff4 | 723 | fi |
7742e157 | 724 | |
e7423cfb | 725 | if ! is_no "$DM_MULTIPATH" [ -x /sbin/multipath ]; then |
2607b4f4 | 726 | # first make nodes that were discarded due (possible) new /dev mount |
6dbec259 | 727 | modprobe -s dm-mod |
2607b4f4 | 728 | /sbin/dmsetup mknodes |
7da998bd | 729 | modprobe -s dm-multipath |
e62309d9 | 730 | run_cmd "Activating dm-multipath" /sbin/multipath -v 0 |
094b84e1 | 731 | /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p' |
e62309d9 ER |
732 | fi |
733 | ||
d1383e52 | 734 | if ! is_no "$DMRAID" && [ -x /sbin/dmraid ]; then |
3a4304f3 AM |
735 | run_cmd "Activating ATARAID devices" /sbin/dmraid -ay |
736 | fi | |
737 | ||
cc10e704 JR |
738 | # Find and activate volume groups: |
739 | # EVMS | |
241bbd09 | 740 | if is_yes "$EVMS_LVM" && [ -x /sbin/evms_activate ]; then |
cc10e704 | 741 | if [ "$(kernelverser)" -lt "002006" ]; then |
5e6dfc29 | 742 | # Linux 2.4 core modules |
dbb15f89 ER |
743 | modprobe -s evms |
744 | modprobe -s evms_passthru | |
745 | modprobe -s ldev_mgr | |
746 | modprobe -s dos_part | |
cc10e704 | 747 | else |
5e6dfc29 | 748 | # Linux 2.6 core module |
dbb15f89 | 749 | modprobe -s evmscore |
d6749722 | 750 | fi |
5e6dfc29 | 751 | |
dbb15f89 ER |
752 | is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part |
753 | is_yes "$EVMS_LVM" && modprobe -s lvm_vge | |
754 | is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge | |
755 | is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge | |
cc10e704 JR |
756 | run_cmd "Discovering EVMS volumes" /sbin/evms_activate |
757 | if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then | |
758 | # Link nodes for compatibility with LVM | |
24fec6e3 ER |
759 | if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then |
760 | ln -s /dev/evms/lvm/* /dev | |
de1fc6ce | 761 | fi |
cc10e704 JR |
762 | fi |
763 | fi | |
49c61c56 | 764 | |
09b13698 ER |
765 | # Init LVM |
766 | if ! is_no "$LVM2"; then | |
767 | init_lvm | |
cc10e704 JR |
768 | fi |
769 | ||
39b4e340 ER |
770 | if [ "$delay_cryptsetup" != 0 ]; then |
771 | show "Starting disk encryption" | |
772 | init_crypto 1 | |
773 | delay_cryptsetup=$? | |
774 | [ $delay_cryptsetup = 0 ] && ok || fail | |
775 | fi | |
776 | ||
09b13698 ER |
777 | if ! is_no "$MDADM"; then |
778 | init_mdadm | |
12de71be | 779 | fi |
7742e157 | 780 | |
cc10e704 JR |
781 | _RUN_QUOTACHECK=0 |
782 | # Check filesystems | |
236aa13c | 783 | if [ -z "$fastboot" ] && [ -z "$nofsck" ]; then |
cc10e704 JR |
784 | rc_splash "fsck start" |
785 | show "Checking filesystems"; started | |
790968dd | 786 | initlog -c "fsck -C -T -R -A -a -P $fsckoptions" |
cc10e704 JR |
787 | |
788 | rc=$? | |
789 | ||
790 | # A return of 2 or higher means there were serious problems | |
791 | if [ $rc -gt 1 ]; then | |
792 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
cc10e704 JR |
793 | |
794 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 | |
069c8901 | 795 | repair_shell "$(nls '*** An error occurred during the file system check.')" |
7742e157 | 796 | |
cc10e704 JR |
797 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then |
798 | _RUN_QUOTACHECK=1 | |
799 | fi | |
800 | rc_splash "fsck stop" | |
7742e157 | 801 | fi |
7742e157 | 802 | |
cc10e704 JR |
803 | # Mount all other filesystems (except for NFS and /proc, which is already |
804 | # mounted). Contrary to standard usage, | |
805 | # filesystems are NOT unmounted in single user mode. | |
438bf720 | 806 | run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev |
cc10e704 | 807 | |
9a0a016d ER |
808 | # now we have /usr mounted, recheck if we have gettext and tput available. |
809 | if is_no "$TPUT"; then | |
810 | GETTEXT= | |
348aacfc | 811 | TPUT= |
04342743 | 812 | rc_gettext_init |
9a0a016d ER |
813 | fi |
814 | ||
cc10e704 JR |
815 | # Now do some workaround - encrypted filesystems couldn't have been fsck-ed |
816 | # before mount - that's where the password is entered. | |
817 | # mount is buggy - when remounting loopback filesystem, loop=XXX | |
818 | # option is removed from /etc/mtab | |
819 | if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then | |
820 | show "Checking encrypted filesystems"; started | |
9f6e3ec0 | 821 | LOOPLIST="$(LC_ALL=C awk ' |
cc10e704 JR |
822 | FILENAME=="/proc/mounts" { |
823 | TAB[$2]=$1; | |
824 | } | |
825 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
826 | if ($2 in TAB){print TAB[$2];} | |
827 | } | |
828 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
829 | if ($2 in TAB){print TAB[$2];} | |
830 | sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4); | |
831 | cmd="mount " $2 " -o remount," $4; | |
832 | system(cmd); | |
833 | } | |
834 | ' /proc/mounts /etc/fstab)" | |
835 | initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST" | |
836 | rc=$? | |
837 | ||
838 | # A return of 2 or higher means there were serious problems. | |
839 | if [ $rc -gt 1 ]; then | |
840 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
cc10e704 | 841 | |
bf14fcab | 842 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 |
069c8901 | 843 | repair_shell "$(nls '*** An error occurred during the file system check.')" |
6fa97a5d | 844 | |
cc10e704 JR |
845 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then |
846 | _RUN_QUOTACHECK=1 | |
847 | fi | |
5e6dfc29 | 848 | |
cc10e704 | 849 | show "Remounting encrypted filesystems back in rw mode"; busy |
9f6e3ec0 | 850 | LC_ALL=C awk ' |
cc10e704 JR |
851 | FILENAME=="/proc/mounts" { |
852 | TAB[$2]=$1; | |
853 | } | |
854 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
855 | sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4); | |
856 | cmd="mount " $2 " -o remount," $4; | |
857 | system(cmd); | |
858 | } | |
859 | ' /proc/mounts /etc/fstab | |
860 | ok | |
861 | fi | |
6e16ab8f | 862 | |
9a0a016d | 863 | # /var/log should be writable now, so start saving the boot output |
652dbae5 | 864 | if [ "$RC_BOOTLOG" ]; then |
e90f4b95 | 865 | echo > /var/log/boot.log |
652dbae5 ER |
866 | killall -IO blogd |
867 | fi | |
cb4d1aa7 | 868 | |
1aaf8c92 JR |
869 | if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then |
870 | run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa | |
871 | fi | |
cb4d1aa7 | 872 | |
1aaf8c92 JR |
873 | # Turn on quota |
874 | if [ -x /sbin/quotaon ]; then | |
875 | run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug | |
876 | fi | |
677fdd75 | 877 | |
cc311639 | 878 | emit --no-wait local-filesystems |
4db70cd2 JK |
879 | |
880 | # FIXME: this should be delayed until remote filesystems are mounted, | |
881 | # especialy when /usr or other standard fs is remote | |
cc311639 | 882 | emit --no-wait filesystem |
4db70cd2 | 883 | |
1aaf8c92 JR |
884 | # Turn on process accounting |
885 | if [ -x /etc/rc.d/rc.acct ]; then | |
886 | /etc/rc.d/rc.acct start | |
887 | fi | |
cb4d1aa7 | 888 | |
cc10e704 | 889 | # Set the clock if timezone definition wasn't available (eg. /usr not mounted) |
75185230 | 890 | if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then |
37932add | 891 | if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then |
cc10e704 JR |
892 | show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok |
893 | fi | |
0bbfed6f | 894 | fi |
0bbfed6f | 895 | |
cc10e704 JR |
896 | # Initialize the serial ports |
897 | if [ -f /etc/rc.d/rc.serial ]; then | |
898 | . /etc/rc.d/rc.serial | |
899 | fi | |
201c98b9 | 900 | |
299f2fee | 901 | if [ -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" -a -f /proc/sys/kernel/panic ]; then |
cc10e704 | 902 | show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy |
590eeb64 ER |
903 | # NOTE: you should use /etc/sysctl.conf instead |
904 | if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi | |
cc10e704 | 905 | fi |
201c98b9 | 906 | |
cc10e704 | 907 | # ... and here finish configuring parameters |
5bf237b7 | 908 | sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1 |
ef05209d | 909 | else |
cc311639 JK |
910 | emit --no-wait root-filesystem |
911 | emit --no-wait virtual-filesystems | |
912 | emit --no-wait local-filesystems | |
913 | emit --no-wait filesystem | |
4db70cd2 | 914 | |
fea9b6da | 915 | # /var/log should be writable now, so start saving the boot output |
652dbae5 | 916 | if [ "$RC_BOOTLOG" ]; then |
e90f4b95 | 917 | echo > /var/log/boot.log |
652dbae5 ER |
918 | killall -IO blogd |
919 | fi | |
920 | ||
ef05209d | 921 | clean_vserver_mtab |
cc10e704 | 922 | fi |
adec827a | 923 | |
652dbae5 | 924 | |
1aaf8c92 JR |
925 | [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux |
926 | ||
6239bd5c | 927 | # Clean up /. |
47e385fd | 928 | rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1 |
cb4d1aa7 JR |
929 | |
930 | # Clean up /var | |
5145ce41 | 931 | # /usr could be still not mounted if it is on NFS. |
cb4d1aa7 | 932 | for afile in /var/lock/* /var/run/*; do |
fea9b6da | 933 | bafile=${afile##*/} |
cb4d1aa7 | 934 | if [ -d "$afile" ]; then |
38b419e3 | 935 | case $bafile in |
fea9b6da ER |
936 | news|sudo|mon|cvs) |
937 | ;; | |
938 | *) | |
91dc9337 | 939 | echo $afile/* | xargs rm -rf |
fea9b6da | 940 | ;; |
38b419e3 | 941 | esac |
cb4d1aa7 | 942 | else |
7d175167 | 943 | [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null |
cb4d1aa7 JR |
944 | fi |
945 | done | |
5145ce41 | 946 | |
e0cba078 | 947 | # Delete stale files |
4eb58d70 AM |
948 | rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \ |
949 | /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* | |
950 | rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ | |
5e6dfc29 JR |
951 | /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ |
952 | /tmp/scrollkeeper-* /tmp/ssh-* | |
45955ed4 | 953 | |
201c98b9 | 954 | { |
6b4a354c | 955 | # Clean up utmp/wtmp |
fea9b6da | 956 | if ! is_no "$NEED_XFILES"; then |
e99ccdf7 | 957 | > /var/run/utmpx |
6b4a354c | 958 | touch /var/log/wtmpx |
afa9b748 | 959 | chown root:utmp /var/run/utmpx /var/log/wtmpx |
19b0557d | 960 | chmod 0664 /var/run/utmpx /var/log/wtmpx |
054a52c9 | 961 | else |
e99ccdf7 | 962 | > /var/run/utmp |
054a52c9 | 963 | touch /var/log/wtmp |
afa9b748 | 964 | chown root:utmp /var/run/utmp /var/log/wtmp |
19b0557d | 965 | chmod 0664 /var/run/utmp /var/log/wtmp |
6b4a354c | 966 | fi |
7e04fe0e | 967 | |
7e04fe0e | 968 | # Clean /tmp |
a90039da ER |
969 | if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then |
970 | LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]* | |
7e04fe0e | 971 | fi |
7742e157 | 972 | |
e6c8dd44 AM |
973 | # System protected dirs |
974 | mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1 | |
975 | chown root:root /tmp/.ICE-unix | |
677fdd75 | 976 | [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1 |
e6c8dd44 | 977 | |
1aaf8c92 | 978 | if ! is_yes "$VSERVER"; then |
5bf237b7 | 979 | run_cmd "Enabling swap space" true |
1aaf8c92 JR |
980 | # Right, now turn on swap in case we swap to files |
981 | swapon -a >/dev/null 2>&1 | |
cc311639 | 982 | emit --no-wait all-swaps |
7742e157 | 983 | |
0d60cc3e JR |
984 | # If a SCSI tape has been detected, load the st module unconditionally |
985 | # since many SCSI tapes don't deal well with st being loaded and unloaded | |
986 | if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then | |
987 | if grep -qv ' 9 st' /proc/devices 2>/dev/null; then | |
988 | if [ -n "$USEMODULES" ] ; then | |
989 | # Try to load the module. If it fails, ignore it... | |
dbb15f89 | 990 | insmod -p st >/dev/null 2>&1 && modprobe -s st |
0d60cc3e | 991 | fi |
7742e157 AF |
992 | fi |
993 | fi | |
7742e157 | 994 | |
cc10e704 JR |
995 | # Now that we have all of our basic modules loaded and the kernel going, |
996 | # let's dump the syslog ring somewhere so we can find it later | |
79955f85 | 997 | dmesg --raw > /var/log/dmesg |
cc10e704 JR |
998 | i=5 |
999 | while [ $i -ge 0 ]; do | |
1000 | if [ -f /var/log/dmesg.$i ]; then | |
5e6dfc29 JR |
1001 | chmod 0600 /var/log/dmesg.$i |
1002 | mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1)) | |
cc10e704 JR |
1003 | fi |
1004 | i=$(($i-1)) | |
1005 | done | |
1006 | cp -f /var/log/dmesg /var/log/dmesg.0 | |
1007 | chmod 0600 /var/log/dmesg /var/log/dmesg.0 | |
4db70cd2 | 1008 | else |
cc311639 | 1009 | emit --no-wait all-swaps |
cc10e704 | 1010 | fi |
7742e157 | 1011 | |
a81df7c5 AM |
1012 | if ! is_no "$RC_PROMPT"; then |
1013 | while :; do | |
1014 | pid=$(/sbin/pidof getkey) | |
1015 | [ -n "$pid" -o -e /var/run/getkey_done ] && break | |
1016 | usleep 100000 | |
1017 | done | |
1018 | [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1 | |
1019 | fi | |
6b4a354c | 1020 | } & |
385dc542 | 1021 | |
863baad1 | 1022 | # /proc extra check if the background process we just spawned is still running, |
385dc542 | 1023 | # as in case of vserver bootup it finishes quite instantly. |
863baad1 | 1024 | if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then |
a81df7c5 AM |
1025 | /sbin/getkey i && touch /var/run/confirm |
1026 | touch /var/run/getkey_done | |
6b4a354c AM |
1027 | fi |
1028 | wait | |
a81df7c5 AM |
1029 | if ! is_no "$RC_PROMPT"; then |
1030 | rm -f /var/run/getkey_done | |
1031 | fi | |
de1fc6ce | 1032 | echo |
4db70cd2 | 1033 | |
cc311639 | 1034 | emit --no-wait pld.sysinit-done |
4db70cd2 | 1035 |