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