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