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