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