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