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