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