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