]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/rc.sysinit
- don't check the fs on aufs and squashfs systems
[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
258 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh
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
8159a411 273 # cpuset support (mount if not found in fstab - should be ^# excluded?)
5bae5434 274 if grep -q cgroup /proc/filesystems 2>/dev/null ; then
8159a411
PG
275 if ! grep -q cgroup /etc/fstab 2>/dev/null ; then
276 mount -n -t cgroup none /dev/cpuset -o cpuset,noprefix
277 [ $? -eq 0 ] && echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent
278 fi
5bae5434 279 elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
8159a411
PG
280 if ! grep -q cpuset /etc/fstab 2>/dev/null ; then
281 mount -n -t cpuset none /dev/cpuset
282 fi
cc10e704 283 fi
201c98b9 284
cc10e704
JR
285 # Configure Linux kernel (initial configuration, some required modules still
286 # may be missing).
5bf237b7 287 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
201c98b9 288
cc10e704
JR
289 # Set the system clock.
290 ARC=0
291 SRM=0
292 UTC=0
201c98b9 293
cc10e704
JR
294 if [ -f /etc/sysconfig/clock ]; then
295 . /etc/sysconfig/clock
201c98b9 296
cc10e704
JR
297 # convert old style clock config to new values
298 if [ "${CLOCKMODE}" = "GMT" ]; then
299 UTC=true
300 elif [ "${CLOCKMODE}" = "ARC" ]; then
301 ARC=true
302 fi
303 fi
201c98b9 304
cc10e704
JR
305 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
306 ARC=true
307 fi
cb4d1aa7 308
cc10e704 309 CLOCKDEF=""
961da5e0 310 CLOCKFLAGS="--hctosys"
cb4d1aa7 311
cc10e704 312 if is_yes "$UTC" ; then
961da5e0 313 CLOCKFLAGS="$CLOCKFLAGS --utc"
cc10e704
JR
314 CLOCKDEF="$CLOCKDEF (utc)"
315 else
fa3560e0 316 CLOCKFLAGS="$CLOCKFLAGS --localtime"
cc10e704
JR
317 CLOCKDEF="$CLOCKDEF (local)"
318 fi
201c98b9 319
cc10e704
JR
320 if is_yes "$ARC" ; then
321 CLOCKFLAGS="$CLOCKFLAGS -A"
322 CLOCKDEF="$CLOCKDEF (arc)"
0bbfed6f 323 fi
e4b0481f 324
cc10e704
JR
325 if is_yes "$SRM" ; then
326 CLOCKFLAGS="$CLOCKFLAGS -S"
327 CLOCKDEF="$CLOCKDEF (srm)"
328 fi
7742e157 329
cc10e704 330 # Check if timezone definition is available
5bf237b7
ER
331 if [ -e /etc/localtime -a -e /dev/rtc ] ; then
332 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" hwclock $CLOCKFLAGS; then
cc10e704
JR
333 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
334 fi
335 else
336 TIME_SETUP_DELAYED=yes
337 fi
7742e157 338
6b496866 339 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
dd23d50d
ER
340 # XXX might need modules dep
341 # Device mapper & related initialization
a51d5138 342 if ! grep -qF device-mapper /proc/devices; then
dd23d50d
ER
343 modprobe dm-mod
344 fi
345
346 # but should do this before swapon?
347 . /etc/rc.d/init.d/cryptsetup
8710c4b5 348 show "Starting disk encryption"
dd23d50d
ER
349 init_crypto 0 && ok || fail
350 fi
351
cc10e704
JR
352 # Start up swapping
353 run_cmd "Activating swap partitions" swapon -a -e
354
355 # Initialize USB controllers
356 usb=0
3f9e71a5 357 if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then
86711d93 358 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
cc10e704 359 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
170103c8 360 /sbin/modprobe -s usbcore
cc10e704
JR
361 for alias in $aliases ; do
362 [ "$alias" = "off" ] && continue
a6a4a758 363 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
cc10e704
JR
364 done
365 [ $? -eq 0 -a -n "$aliases" ] && usb=1
366 fi
367 if grep -iq "usb" /proc/devices 2>/dev/null ; then
368 usb=1
369 fi
370 fi
7742e157 371
ff474752 372 if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
a40bbbec 373 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
b3965b3d 374 fi
b3965b3d 375
cc10e704
JR
376 needusbstorage=
377 if [ "$usb" = "1" ]; then
bc325aa3 378 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
cc10e704 379 if [ "$(kernelverser)" -lt "002006" ]; then
bc325aa3 380 grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
5e6dfc29
JR
381 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
382 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
383 if [ -n "$kbdoutput" ]; then
384 run_cmd "Initializing USB keyboard" modprobe keybdev
385 fi
386 if [ -n "$mouseoutput" ]; then
387 run_cmd "Initializing USB mouse" modprobe mousedev
388 fi
cc10e704
JR
389 fi
390 fi
b3965b3d 391
cc10e704 392 # Setup hdparm thing (if exists and is needed)
07ea1da7 393 if ! strstr "$cmdline" nohdparm; then
cc10e704 394 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
ebd1845b 395 fi
b3965b3d 396
07ea1da7 397 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
cc10e704
JR
398 fastboot=yes
399 else
400 fastboot=
401 fi
03f9cfee 402
cc10e704
JR
403 if [ -f /fsckoptions ]; then
404 fsckoptions=$(cat /fsckoptions)
405 else
406 fsckoptions=''
407 fi
cb4d1aa7 408
cc10e704
JR
409 if [ -f /forcefsck ]; then
410 fsckoptions="-f $fsckoptions"
790968dd
ER
411 else
412 # Obey the fs_passno setting for / (see fstab(5))
413 # - find the / entry
6fe4e4eb
ER
414 # - make sure we have at least 6 fields
415 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
cc10e704 416 fi
7742e157 417
cc10e704 418 _RUN_QUOTACHECK=0
dc12b33c 419 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
2fce16f9 420 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
cc10e704 421
e2822248 422 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 423 check_root_fs
cb4d1aa7 424 fi
7742e157 425
5e6dfc29 426 # Check for arguments
07ea1da7 427 if strstr "$cmdline" nopnp; then
cc10e704
JR
428 PNP=
429 else
430 PNP=yes
431 fi
7742e157 432
cc10e704
JR
433 # set up pnp and kernel pnp
434 if [ -n "$PNP" ]; then
277e5f53 435 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
5e6dfc29
JR
436 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
437 fi
277e5f53 438 if ! is_no "$RUN_KERNELPNP"; then
170103c8 439 /sbin/modprobe isa-pnp 2> /dev/null
5e6dfc29
JR
440 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
441 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
442 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
443 fi
cc10e704 444 fi
b68f99e5 445 fi
7742e157 446
41c877f2 447 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
cc10e704 448 # Remount the root filesystem read-write
41c877f2 449 if [ -z "$_ROOTFS_RO" ]; then
47e385fd 450 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
451 fi
cee18a41 452
cc10e704
JR
453 # Update quotas if fsck was run on /
454 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
455 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
456 fi
aa362992 457
5475bb0f
ER
458 # Clean up SELinux labels
459 if [ -n "$SELINUX" ]; then
460 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
461 [ -r $file ] && restorecon $file >/dev/null 2>&1
462 done
463 fi
652dbae5 464
6b496866 465 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
dd23d50d 466 # XXX, this must be probably done after random is initialized from /var/run/random-seed
1b05bb8a 467 show "Starting disk encryption using the RNG"
dd23d50d
ER
468 init_crypto 1 && ok || fail
469 fi
652dbae5
ER
470else
471 # Start logging console output since we have all /dev stuff setup
472 if [ "$RC_BOOTLOG" ]; then
473 /sbin/blogd -q
474 fi
677fdd75 475fi
5e6dfc29 476
cb4d1aa7 477# Remove stale backups
47e385fd 478rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
cb4d1aa7 479
ef05209d
JR
480# Remove /etc/nologin when starting system
481[ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
482
277e5f53 483if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
ef05209d
JR
484 show "Enabling Delay Login"; busy
485 echo > /etc/nologin
486 nls "System bootup in progress - please wait" >> /etc/nologin
487 echo >> /etc/nologin
488 chmod 644 /etc/nologin
489 cp -fp /etc/nologin /etc/nologin.boot
490 ok
491fi
492
493# The root filesystem is now read-write, so we can now log via
494# syslog() directly...
495if [ -n "$IN_INITLOG" ]; then
496 IN_INITLOG=""
497fi
498
cc10e704 499if ! is_yes "$VSERVER"; then
220df3e7
JR
500 # Clear mtab
501 :>/etc/mtab
502 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
503
34c624e7 504 # Enter root, /proc, /sys and other into mtab.
cc10e704
JR
505 mount -f /
506 mount -f /proc
3f9e71a5
JR
507 if is_fsmounted usbfs /proc/bus/usb; then
508 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
509 fi
7d45bad6 510
3f9e71a5 511 if is_fsmounted sysfs /sys; then
cc10e704 512 mount -f -t sysfs sysfs /sys
3f9e71a5
JR
513 if is_fsmounted securityfs /sys/kernel/security ; then
514 mount -f -t securityfs securityfs /sys/kernel/security
defac991 515 fi
cc10e704 516 fi
ad084d91 517
3f9e71a5 518 if is_fsmounted selinuxfs /selinux; then
cc10e704
JR
519 mount -f -t selinuxfs selinuxfs /selinux
520 fi
cb4d1aa7 521
3f9e71a5
JR
522 if is_fsmounted cgroup /dev/cpuset; then
523 mount -f -t cgroup -o cpuset,noprefix none /dev/cpuset
524 elif is_fsmounted cpuset /dev/cpuset; then
2d495b7f 525 mount -f -t cpuset none /dev/cpuset
cc10e704 526 fi
4db70cd2 527
cc311639
JK
528 emit --no-wait root-filesystem
529 emit --no-wait virtual-filesystems
fd6887dc 530
cc10e704
JR
531 if [ ! -f /proc/modules ]; then
532 USEMODULES=
07ea1da7 533 elif ! strstr "$cmdline" nomodules; then
cc10e704
JR
534 USEMODULES=y
535 else
536 USEMODULES=
4cc4301b 537 fi
de1fc6ce 538
0b38e7f1 539 uname_r=$(uname -r)
cc10e704
JR
540 # Adjust symlinks as necessary in /boot to keep system services from
541 # spewing messages about mismatched System maps and so on.
277e5f53 542 if ! is_no "$SET_SLINKS"; then
c14f9857
ER
543 if [ -L /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
c14f9857
ER
546 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
547 ln -s -f System.map-$uname_r /boot/System.map
cc10e704 548 fi
418c0cf3 549 fi
7742e157 550
cc10e704
JR
551 # Run depmod if RUN_DEPMOD != "no" and:
552 # a) user requested or RUN_DEPMOD="";
553 # b) modules.dep is missing
cc10e704
JR
554 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
555 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
556 run_cmd "Finding module dependencies" depmod -a
0b38e7f1 557 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
cc10e704
JR
558 run_cmd "Finding module dependencies" depmod -A
559 fi
aa362992 560 fi
0b38e7f1 561 unset uname_r
5bb58804 562
cc10e704
JR
563 if [ -f /proc/sys/kernel/modprobe ]; then
564 if [ -n "$USEMODULES" ]; then
565 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
cc10e704
JR
566 else
567 # We used to set this to NULL, but that causes
568 # 'failed to exec' messages"
569 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
cc10e704 570 fi
cb4d1aa7 571 fi
cb4d1aa7 572
cc10e704
JR
573 # Load usb storage here, to match most other things
574 if [ -n "$needusbstorage" ]; then
170103c8 575 modprobe usb-storage >/dev/null 2>&1
cc10e704 576 fi
cb4d1aa7 577
cc10e704 578 # Load firewire devices
07ea1da7 579 if ! strstr "$cmdline" nofirewire; then
cc10e704
JR
580 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
581 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
5e6dfc29
JR
582 for alias in $aliases ; do
583 [ "$alias" = "off" ] && continue
584 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
585 done
bc325aa3 586 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
cc10e704 587 fi
5e6dfc29
JR
588 fi
589
cc10e704 590 # Load sound modules if they need persistent DMA buffers
e0fdf0af 591 if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
cc10e704 592 RETURN=0
a51d5138 593 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
cc10e704
JR
594 if [ -n "$alias" -a "$alias" != "off" ] ; then
595 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
596 RETURN=$?
597 fi
a51d5138 598 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
cc10e704
JR
599 if [ -n "$alias" -a "$alias" != "off" ] ; then
600 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
601 RETURN=$?
f47acf6f
JR
602 fi
603 fi
472fa41e 604
cc10e704 605 # Load modules
3aabb390 606 load_kernel_modules
7742e157 607
e62309d9 608 if [ -x /sbin/multipath ]; then
2607b4f4 609 # first make nodes that were discarded due (possible) new /dev mount
6dbec259 610 modprobe -s dm-mod
2607b4f4 611 /sbin/dmsetup mknodes
7da998bd 612 modprobe -s dm-multipath
e62309d9 613 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
094b84e1 614 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
e62309d9
ER
615 fi
616
3a4304f3
AM
617 if [ -x /sbin/dmraid ]; then
618 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
619 fi
620
cc10e704
JR
621 # Find and activate volume groups:
622 # EVMS
623 if [ -x /sbin/evms_activate ]; then
cc10e704 624 if [ "$(kernelverser)" -lt "002006" ]; then
5e6dfc29 625 # Linux 2.4 core modules
170103c8 626 modprobe -s evms > /dev/null 2>&1
627 modprobe -s evms_passthru > /dev/null 2>&1
628 modprobe -s ldev_mgr > /dev/null 2>&1
629 modprobe -s dos_part > /dev/null 2>&1
cc10e704 630 else
5e6dfc29 631 # Linux 2.6 core module
170103c8 632 modprobe -s evmscore > /dev/null 2>&1
d6749722 633 fi
5e6dfc29 634
170103c8 635 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1
636 is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1
637 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1
638 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1
cc10e704
JR
639 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
640 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
641 # Link nodes for compatibility with LVM
24fec6e3
ER
642 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
643 ln -s /dev/evms/lvm/* /dev
de1fc6ce 644 fi
cc10e704
JR
645 fi
646 fi
49c61c56 647
cc10e704
JR
648 # LVM (keep in sync with LVM starting after RAID run!)
649 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
0174ae89 650 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
cc10e704 651 if [ "$lvmversion" = "1" ] ; then
170103c8 652 modprobe -s lvm-mod >/dev/null 2>&1
cc10e704
JR
653 lvmignorelock=""
654 elif [ "$lvmversion" = "2" ] ; then
170103c8 655 modprobe -s dm-mod >/dev/null 2>&1
cc10e704
JR
656 lvmignorelock="--ignorelockingfailure"
657 else
170103c8 658 modprobe -s lvm-mod >/dev/null 2>&1
5e6dfc29 659 # device mapper (2.5+ and patched 2.4)
170103c8 660 modprobe -s dm-mod >/dev/null 2>&1
5e6dfc29 661 lvmignorelock=""
cc10e704 662 fi
5e6dfc29 663
2607b4f4 664 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
cc10e704 665 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
fcc79c02 666 if [ "$lvmversion" = "2" ]; then
2269afad 667 /sbin/vgmknodes $lvmignorelock
fcc79c02 668 # display VG statistics
2269afad 669 /sbin/vgdisplay -s $lvmignorelock
fcc79c02 670 fi
cc10e704
JR
671 fi
672
673 # Add raid devices
674 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
cc10e704
JR
675 modprobe -s md >/dev/null 2>&1
676 if [ -f /proc/mdstat ]; then
5e6dfc29
JR
677 goraidtab=1
678 golvm=0
679 rc=0
680 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
681 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
d1b96465
AM
682 show "Starting up RAID devices"; busy
683 /sbin/mdadm --assemble --scan --auto=yes
5e6dfc29 684 rc=$?
d1b96465 685 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
1851f49d
AM
686 # rc is used later, too so set sane value
687 rc=0
d1b96465
AM
688 deltext; ok
689 goraidtab=0
690 golvm=1
691 else
692 deltext; fail
693 fi
694
cc10e704 695 fi
5e6dfc29
JR
696 fi
697
698 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
49c61c56 699 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
5e6dfc29
JR
700 golvm=1
701 RAIDDEV=$(basename $i)
702 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
703 show "Starting up RAID device %s" $RAIDDEV
704 busy
705 if [ -z "$RAIDSTAT" ]; then
706 # Try raidstart first...if that fails then
707 # fall back to raid0run and if that fails too
708 # fall back to raidadd, raidrun.
709 RESULT=1
710 if [ -x /sbin/raidstart ]; then
711 /sbin/raidstart $i
712 RESULT=$?
713 fi
714 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
715 /sbin/raid0run $i
716 RESULT=$?
717 fi
718 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
719 /sbin/raidadd $i
720 /sbin/raidrun $i
721 RESULT=$?
722 fi
723 if [ $RESULT -gt 0 ]; then
724 rc=1
725 fail
726 else
727 ok
728 fi
729 else
730 ok
731 fi
732 done
733 fi
734
735 # A non-zero return means there were problems
736 if [ $rc -gt 0 ]; then
737 [ -e /proc/splash ] && echo "verbose" > /proc/splash
738 show "Starting up RAID devices"; fail
739 echo
740 echo
741 nls "*** An error occurred during the RAID startup."
742 nls "*** Dropping you to a shell; the system will reboot"
743 nls "*** when you leave the shell."
744 echo
745
746 PS1="$(nls '(RAID Repair)# ')"; export PS1
747 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 748 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
5e6dfc29 749 /sbin/sulogin
cc10e704 750 else
5e6dfc29 751 /bin/sh
cc10e704 752 fi
12de71be 753
5e6dfc29
JR
754 run_cmd "Unmounting file systems" umount -a
755 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
756 run_cmd "Automatic reboot in progress" reboot
cc10e704 757 fi
5e6dfc29
JR
758 # LVM on RAID (keep in sync with LVM setting few lines above)
759 if [ "$golvm" -eq "1" ]; then
9bec7e9f 760 if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
2607b4f4 761 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock
5e6dfc29 762 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
2607b4f4 763 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
5e6dfc29 764 fi
cc10e704 765 fi
5e6dfc29 766 show "Starting up RAID devices"; ok
2619a5cf 767 fi
12de71be 768 fi
7742e157 769
cc10e704
JR
770 _RUN_QUOTACHECK=0
771 # Check filesystems
07ea1da7 772 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
cc10e704
JR
773 rc_splash "fsck start"
774 show "Checking filesystems"; started
790968dd 775 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
cc10e704
JR
776
777 rc=$?
778
779 # A return of 2 or higher means there were serious problems
780 if [ $rc -gt 1 ]; then
781 [ -e /proc/splash ] && echo "verbose" > /proc/splash
782 echo
783 echo
784 nls "*** An error occurred during the file system check."
785 nls "*** Dropping you to a shell; the system will reboot"
786 nls "*** when you leave the shell."
787 echo
788
789 PS1="$(nls '(Repair filesystem)# ')"; export PS1
790 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 791 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
792 /sbin/sulogin
793 else
794 /bin/sh
795 fi
7742e157 796
cc10e704
JR
797 run_cmd "Unmounting file systems" umount -a
798 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
799 run_cmd "Automatic reboot in progress" reboot
800 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
801 _RUN_QUOTACHECK=1
802 fi
803 rc_splash "fsck stop"
7742e157 804 fi
7742e157 805
cc10e704
JR
806 # Mount all other filesystems (except for NFS and /proc, which is already
807 # mounted). Contrary to standard usage,
808 # filesystems are NOT unmounted in single user mode.
809
438bf720 810 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
cc10e704 811
9a0a016d
ER
812 # now we have /usr mounted, recheck if we have gettext and tput available.
813 if is_no "$TPUT"; then
814 GETTEXT=
348aacfc 815 TPUT=
04342743 816 rc_gettext_init
9a0a016d
ER
817 fi
818
cc10e704
JR
819 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
820 # before mount - that's where the password is entered.
821 # mount is buggy - when remounting loopback filesystem, loop=XXX
822 # option is removed from /etc/mtab
823 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
824 show "Checking encrypted filesystems"; started
bc325aa3 825 LOOPLIST="$(awk '
cc10e704
JR
826 FILENAME=="/proc/mounts" {
827 TAB[$2]=$1;
828 }
829 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
830 if ($2 in TAB){print TAB[$2];}
831 }
832 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
833 if ($2 in TAB){print TAB[$2];}
834 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
835 cmd="mount " $2 " -o remount," $4;
836 system(cmd);
837 }
838 ' /proc/mounts /etc/fstab)"
839 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
840 rc=$?
841
842 # A return of 2 or higher means there were serious problems.
843 if [ $rc -gt 1 ]; then
844 [ -e /proc/splash ] && echo "verbose" > /proc/splash
845 echo
846 echo
847 nls "*** An error occurred during the file system check."
848 nls "*** Dropping you to a shell; the system will reboot"
849 nls "*** when you leave the shell."
850 echo
851
bf14fcab 852 PS1="$(nls '(Repair filesystem)# ')"; export PS1
cc10e704 853 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 854 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
855 /sbin/sulogin
856 else
857 /bin/sh
858 fi
6fa97a5d 859
cc10e704
JR
860 run_cmd "Unmounting file systems" umount -a
861 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
862 run_cmd "Automatic reboot in progress" reboot
863 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
864 _RUN_QUOTACHECK=1
865 fi
5e6dfc29 866
cc10e704
JR
867 show "Remounting encrypted filesystems back in rw mode"; busy
868 awk '
869 FILENAME=="/proc/mounts" {
870 TAB[$2]=$1;
871 }
872 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
873 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
874 cmd="mount " $2 " -o remount," $4;
875 system(cmd);
876 }
877 ' /proc/mounts /etc/fstab
878 ok
879 fi
6e16ab8f 880
9a0a016d 881 # /var/log should be writable now, so start saving the boot output
652dbae5 882 if [ "$RC_BOOTLOG" ]; then
e90f4b95 883 echo > /var/log/boot.log
652dbae5
ER
884 killall -IO blogd
885 fi
cb4d1aa7 886
1aaf8c92
JR
887 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
888 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
889 fi
cb4d1aa7 890
1aaf8c92
JR
891 # Turn on quota
892 if [ -x /sbin/quotaon ]; then
893 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
894 fi
677fdd75 895
cc311639 896 emit --no-wait local-filesystems
4db70cd2
JK
897
898 # FIXME: this should be delayed until remote filesystems are mounted,
899 # especialy when /usr or other standard fs is remote
cc311639 900 emit --no-wait filesystem
4db70cd2 901
1aaf8c92
JR
902 # Turn on process accounting
903 if [ -x /etc/rc.d/rc.acct ]; then
904 /etc/rc.d/rc.acct start
905 fi
cb4d1aa7 906
cc10e704 907 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
5bf237b7
ER
908 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc ]; then
909 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" hwclock $CLOCKFLAGS; then
cc10e704
JR
910 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
911 fi
0bbfed6f 912 fi
0bbfed6f 913
cc10e704
JR
914 # Initialize the serial ports
915 if [ -f /etc/rc.d/rc.serial ]; then
916 . /etc/rc.d/rc.serial
917 fi
201c98b9 918
277e5f53 919 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
cc10e704 920 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
590eeb64
ER
921 # NOTE: you should use /etc/sysctl.conf instead
922 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
cc10e704 923 fi
201c98b9 924
cc10e704 925 # ... and here finish configuring parameters
5bf237b7 926 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
ef05209d 927else
cc311639
JK
928 emit --no-wait root-filesystem
929 emit --no-wait virtual-filesystems
930 emit --no-wait local-filesystems
931 emit --no-wait filesystem
4db70cd2 932
fea9b6da 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
938
ef05209d 939 clean_vserver_mtab
cc10e704 940fi
adec827a 941
652dbae5 942
1aaf8c92
JR
943[ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
944
6239bd5c 945# Clean up /.
47e385fd 946rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
cb4d1aa7
JR
947
948# Clean up /var
5145ce41 949# /usr could be still not mounted if it is on NFS.
cb4d1aa7 950for afile in /var/lock/* /var/run/*; do
fea9b6da 951 bafile=${afile##*/}
cb4d1aa7 952 if [ -d "$afile" ]; then
38b419e3 953 case $bafile in
fea9b6da
ER
954 news|sudo|mon|cvs)
955 ;;
956 *)
91dc9337 957 echo $afile/* | xargs rm -rf
fea9b6da 958 ;;
38b419e3 959 esac
cb4d1aa7 960 else
7d175167 961 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
cb4d1aa7
JR
962 fi
963done
5145ce41 964
e0cba078 965# Delete stale files
4eb58d70
AM
966rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
967 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
968rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
5e6dfc29
JR
969 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
970 /tmp/scrollkeeper-* /tmp/ssh-*
45955ed4 971
201c98b9 972{
6b4a354c 973# Clean up utmp/wtmp
fea9b6da 974if ! is_no "$NEED_XFILES"; then
6b4a354c
AM
975 :>/var/run/utmpx
976 touch /var/log/wtmpx
afa9b748 977 chown root:utmp /var/run/utmpx /var/log/wtmpx
19b0557d 978 chmod 0664 /var/run/utmpx /var/log/wtmpx
054a52c9
JR
979else
980 :>/var/run/utmp
981 touch /var/log/wtmp
afa9b748 982 chown root:utmp /var/run/utmp /var/log/wtmp
19b0557d 983 chmod 0664 /var/run/utmp /var/log/wtmp
6b4a354c 984fi
7e04fe0e 985
7e04fe0e 986# Clean /tmp
fcf89189 987if is_yes "$CLEAN_TMP"; then
fea9b6da 988 # XXX LC_ALL needed here
cb4d1aa7 989 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
7e04fe0e 990fi
7742e157 991
e6c8dd44
AM
992# System protected dirs
993mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
994chown root:root /tmp/.ICE-unix
677fdd75 995[ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
e6c8dd44 996
1aaf8c92 997if ! is_yes "$VSERVER"; then
5bf237b7 998 run_cmd "Enabling swap space" true
1aaf8c92
JR
999 # Right, now turn on swap in case we swap to files
1000 swapon -a >/dev/null 2>&1
cc311639 1001 emit --no-wait all-swaps
7742e157 1002
0d60cc3e
JR
1003 # If a SCSI tape has been detected, load the st module unconditionally
1004 # since many SCSI tapes don't deal well with st being loaded and unloaded
1005 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
1006 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
1007 if [ -n "$USEMODULES" ] ; then
1008 # Try to load the module. If it fails, ignore it...
1009 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
1010 fi
7742e157
AF
1011 fi
1012 fi
7742e157 1013
cc10e704
JR
1014 # Now that we have all of our basic modules loaded and the kernel going,
1015 # let's dump the syslog ring somewhere so we can find it later
c8f4b766 1016 dmesg > /var/log/dmesg
cc10e704
JR
1017 i=5
1018 while [ $i -ge 0 ]; do
1019 if [ -f /var/log/dmesg.$i ]; then
5e6dfc29
JR
1020 chmod 0600 /var/log/dmesg.$i
1021 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
cc10e704
JR
1022 fi
1023 i=$(($i-1))
1024 done
1025 cp -f /var/log/dmesg /var/log/dmesg.0
1026 chmod 0600 /var/log/dmesg /var/log/dmesg.0
4db70cd2 1027else
cc311639 1028 emit --no-wait all-swaps
cc10e704 1029fi
7742e157 1030
a81df7c5
AM
1031if ! is_no "$RC_PROMPT"; then
1032 while :; do
1033 pid=$(/sbin/pidof getkey)
1034 [ -n "$pid" -o -e /var/run/getkey_done ] && break
1035 usleep 100000
1036 done
1037 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1038fi
6b4a354c 1039} &
385dc542 1040
863baad1 1041# /proc extra check if the background process we just spawned is still running,
385dc542 1042# as in case of vserver bootup it finishes quite instantly.
863baad1 1043if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
a81df7c5
AM
1044 /sbin/getkey i && touch /var/run/confirm
1045 touch /var/run/getkey_done
6b4a354c
AM
1046fi
1047wait
a81df7c5
AM
1048if ! is_no "$RC_PROMPT"; then
1049 rm -f /var/run/getkey_done
1050fi
de1fc6ce 1051echo
4db70cd2 1052
cc311639 1053emit --no-wait pld.sysinit-done
4db70cd2 1054
This page took 0.376262 seconds and 4 git commands to generate.