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