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