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