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