]>
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 | |
dfb009d6 | 338 | if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! 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 |
6bd4314e ER |
576 | for f in /etc/modules-load.d/*.conf; do |
577 | # already loaded by implicit "modules" load | |
578 | [ "${f##*/}" = "modules.conf" ] && continue | |
579 | ||
3741c52c JR |
580 | [ -r $f ] || continue |
581 | load_kernel_modules ${f##/etc/} | |
582 | done | |
5c62cff4 | 583 | fi |
7742e157 | 584 | |
9ae2b877 | 585 | if [ -x /sbin/multipath ] && ! is_no "$DM_MULTIPATH"; then |
2607b4f4 | 586 | # first make nodes that were discarded due (possible) new /dev mount |
6dbec259 | 587 | modprobe -s dm-mod |
2607b4f4 | 588 | /sbin/dmsetup mknodes |
7da998bd | 589 | modprobe -s dm-multipath |
e62309d9 | 590 | run_cmd "Activating dm-multipath" /sbin/multipath -v 0 |
094b84e1 | 591 | /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p' |
e62309d9 ER |
592 | fi |
593 | ||
3a4304f3 AM |
594 | if [ -x /sbin/dmraid ]; then |
595 | run_cmd "Activating ATARAID devices" /sbin/dmraid -ay | |
596 | fi | |
597 | ||
cc10e704 JR |
598 | # Find and activate volume groups: |
599 | # EVMS | |
600 | if [ -x /sbin/evms_activate ]; then | |
cc10e704 | 601 | if [ "$(kernelverser)" -lt "002006" ]; then |
5e6dfc29 | 602 | # Linux 2.4 core modules |
170103c8 | 603 | modprobe -s evms > /dev/null 2>&1 |
604 | modprobe -s evms_passthru > /dev/null 2>&1 | |
605 | modprobe -s ldev_mgr > /dev/null 2>&1 | |
606 | modprobe -s dos_part > /dev/null 2>&1 | |
cc10e704 | 607 | else |
5e6dfc29 | 608 | # Linux 2.6 core module |
170103c8 | 609 | modprobe -s evmscore > /dev/null 2>&1 |
d6749722 | 610 | fi |
5e6dfc29 | 611 | |
170103c8 | 612 | is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1 |
613 | is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1 | |
614 | is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1 | |
615 | is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1 | |
cc10e704 JR |
616 | run_cmd "Discovering EVMS volumes" /sbin/evms_activate |
617 | if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then | |
618 | # Link nodes for compatibility with LVM | |
24fec6e3 ER |
619 | if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then |
620 | ln -s /dev/evms/lvm/* /dev | |
de1fc6ce | 621 | fi |
cc10e704 JR |
622 | fi |
623 | fi | |
49c61c56 | 624 | |
cc10e704 | 625 | # LVM (keep in sync with LVM starting after RAID run!) |
312dab1e | 626 | if ! is_no "$LVM2" && [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then |
7d0f3baf | 627 | if is_no "$LVM2"; then |
00035959 | 628 | lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}') |
7d0f3baf JR |
629 | else |
630 | lvmversion=2 | |
00035959 | 631 | fi |
cc10e704 | 632 | if [ "$lvmversion" = "1" ] ; then |
170103c8 | 633 | modprobe -s lvm-mod >/dev/null 2>&1 |
4897df7d | 634 | lvmignorelocking="" |
ffa93fa2 | 635 | lvmsysinit="" |
cc10e704 | 636 | elif [ "$lvmversion" = "2" ] ; then |
170103c8 | 637 | modprobe -s dm-mod >/dev/null 2>&1 |
4897df7d | 638 | lvmignorelocking="--ignorelockingfailure" |
ffa93fa2 | 639 | lvmsysinit="--sysinit" |
cc10e704 | 640 | else |
170103c8 | 641 | modprobe -s lvm-mod >/dev/null 2>&1 |
5e6dfc29 | 642 | # device mapper (2.5+ and patched 2.4) |
170103c8 | 643 | modprobe -s dm-mod >/dev/null 2>&1 |
4897df7d | 644 | lvmignorelocking="" |
ffa93fa2 | 645 | lvmsysinit="" |
cc10e704 | 646 | fi |
5e6dfc29 | 647 | |
4897df7d | 648 | run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking |
ffa93fa2 | 649 | run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit |
fcc79c02 | 650 | if [ "$lvmversion" = "2" ]; then |
4897df7d | 651 | /sbin/vgmknodes $lvmignorelocking |
fcc79c02 | 652 | # display VG statistics |
4897df7d | 653 | /sbin/vgdisplay -s $lvmignorelocking |
fcc79c02 | 654 | fi |
cc10e704 JR |
655 | fi |
656 | ||
39b4e340 ER |
657 | if [ "$delay_cryptsetup" != 0 ]; then |
658 | show "Starting disk encryption" | |
659 | init_crypto 1 | |
660 | delay_cryptsetup=$? | |
661 | [ $delay_cryptsetup = 0 ] && ok || fail | |
662 | fi | |
663 | ||
cc10e704 JR |
664 | # Add raid devices |
665 | if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then | |
cc10e704 JR |
666 | modprobe -s md >/dev/null 2>&1 |
667 | if [ -f /proc/mdstat ]; then | |
5e6dfc29 JR |
668 | goraidtab=1 |
669 | golvm=0 | |
670 | rc=0 | |
671 | if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then | |
8d0f23dd | 672 | if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then |
d1b96465 | 673 | show "Starting up RAID devices"; busy |
8d0f23dd | 674 | /sbin/mdadm --assemble --scan --auto=yes |
5e6dfc29 | 675 | rc=$? |
d1b96465 | 676 | if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then |
1851f49d AM |
677 | # rc is used later, too so set sane value |
678 | rc=0 | |
d1b96465 AM |
679 | deltext; ok |
680 | goraidtab=0 | |
681 | golvm=1 | |
682 | else | |
683 | deltext; fail | |
684 | fi | |
685 | ||
cc10e704 | 686 | fi |
5e6dfc29 JR |
687 | fi |
688 | ||
689 | if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then | |
49c61c56 | 690 | for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do |
5e6dfc29 JR |
691 | golvm=1 |
692 | RAIDDEV=$(basename $i) | |
693 | RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null) | |
694 | show "Starting up RAID device %s" $RAIDDEV | |
695 | busy | |
696 | if [ -z "$RAIDSTAT" ]; then | |
697 | # Try raidstart first...if that fails then | |
698 | # fall back to raid0run and if that fails too | |
699 | # fall back to raidadd, raidrun. | |
700 | RESULT=1 | |
701 | if [ -x /sbin/raidstart ]; then | |
702 | /sbin/raidstart $i | |
703 | RESULT=$? | |
704 | fi | |
705 | if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then | |
706 | /sbin/raid0run $i | |
707 | RESULT=$? | |
708 | fi | |
709 | if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then | |
710 | /sbin/raidadd $i | |
711 | /sbin/raidrun $i | |
712 | RESULT=$? | |
713 | fi | |
714 | if [ $RESULT -gt 0 ]; then | |
715 | rc=1 | |
716 | fail | |
717 | else | |
718 | ok | |
719 | fi | |
720 | else | |
721 | ok | |
722 | fi | |
723 | done | |
724 | fi | |
725 | ||
726 | # A non-zero return means there were problems | |
727 | if [ $rc -gt 0 ]; then | |
728 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
729 | show "Starting up RAID devices"; fail | |
730 | echo | |
731 | echo | |
732 | nls "*** An error occurred during the RAID startup." | |
733 | nls "*** Dropping you to a shell; the system will reboot" | |
734 | nls "*** when you leave the shell." | |
735 | echo | |
736 | ||
737 | PS1="$(nls '(RAID Repair)# ')"; export PS1 | |
738 | [ "$SELINUX" = "1" ] && disable_selinux | |
277e5f53 | 739 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
5e6dfc29 | 740 | /sbin/sulogin |
cc10e704 | 741 | else |
5e6dfc29 | 742 | /bin/sh |
cc10e704 | 743 | fi |
12de71be | 744 | |
5e6dfc29 JR |
745 | run_cmd "Unmounting file systems" umount -a |
746 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
747 | run_cmd "Automatic reboot in progress" reboot | |
cc10e704 | 748 | fi |
5e6dfc29 JR |
749 | # LVM on RAID (keep in sync with LVM setting few lines above) |
750 | if [ "$golvm" -eq "1" ]; then | |
9bec7e9f | 751 | if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then |
4897df7d | 752 | run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking |
ffa93fa2 | 753 | run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit |
2607b4f4 | 754 | [ "$lvmversion" = "2" ] && /sbin/vgmknodes |
5e6dfc29 | 755 | fi |
cc10e704 | 756 | fi |
5e6dfc29 | 757 | show "Starting up RAID devices"; ok |
2619a5cf | 758 | fi |
12de71be | 759 | fi |
7742e157 | 760 | |
cc10e704 JR |
761 | _RUN_QUOTACHECK=0 |
762 | # Check filesystems | |
07ea1da7 | 763 | if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then |
cc10e704 JR |
764 | rc_splash "fsck start" |
765 | show "Checking filesystems"; started | |
790968dd | 766 | initlog -c "fsck -C -T -R -A -a -P $fsckoptions" |
cc10e704 JR |
767 | |
768 | rc=$? | |
769 | ||
770 | # A return of 2 or higher means there were serious problems | |
771 | if [ $rc -gt 1 ]; then | |
772 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
773 | echo | |
774 | echo | |
775 | nls "*** An error occurred during the file system check." | |
776 | nls "*** Dropping you to a shell; the system will reboot" | |
777 | nls "*** when you leave the shell." | |
778 | echo | |
779 | ||
780 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 | |
781 | [ "$SELINUX" = "1" ] && disable_selinux | |
277e5f53 | 782 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
cc10e704 JR |
783 | /sbin/sulogin |
784 | else | |
785 | /bin/sh | |
786 | fi | |
7742e157 | 787 | |
cc10e704 JR |
788 | run_cmd "Unmounting file systems" umount -a |
789 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
790 | run_cmd "Automatic reboot in progress" reboot | |
791 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then | |
792 | _RUN_QUOTACHECK=1 | |
793 | fi | |
794 | rc_splash "fsck stop" | |
7742e157 | 795 | fi |
7742e157 | 796 | |
cc10e704 JR |
797 | # Mount all other filesystems (except for NFS and /proc, which is already |
798 | # mounted). Contrary to standard usage, | |
799 | # filesystems are NOT unmounted in single user mode. | |
800 | ||
438bf720 | 801 | run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev |
cc10e704 | 802 | |
9a0a016d ER |
803 | # now we have /usr mounted, recheck if we have gettext and tput available. |
804 | if is_no "$TPUT"; then | |
805 | GETTEXT= | |
348aacfc | 806 | TPUT= |
04342743 | 807 | rc_gettext_init |
9a0a016d ER |
808 | fi |
809 | ||
cc10e704 JR |
810 | # Now do some workaround - encrypted filesystems couldn't have been fsck-ed |
811 | # before mount - that's where the password is entered. | |
812 | # mount is buggy - when remounting loopback filesystem, loop=XXX | |
813 | # option is removed from /etc/mtab | |
814 | if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then | |
815 | show "Checking encrypted filesystems"; started | |
9f6e3ec0 | 816 | LOOPLIST="$(LC_ALL=C awk ' |
cc10e704 JR |
817 | FILENAME=="/proc/mounts" { |
818 | TAB[$2]=$1; | |
819 | } | |
820 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
821 | if ($2 in TAB){print TAB[$2];} | |
822 | } | |
823 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
824 | if ($2 in TAB){print TAB[$2];} | |
825 | sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4); | |
826 | cmd="mount " $2 " -o remount," $4; | |
827 | system(cmd); | |
828 | } | |
829 | ' /proc/mounts /etc/fstab)" | |
830 | initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST" | |
831 | rc=$? | |
832 | ||
833 | # A return of 2 or higher means there were serious problems. | |
834 | if [ $rc -gt 1 ]; then | |
835 | [ -e /proc/splash ] && echo "verbose" > /proc/splash | |
836 | echo | |
837 | echo | |
838 | nls "*** An error occurred during the file system check." | |
839 | nls "*** Dropping you to a shell; the system will reboot" | |
840 | nls "*** when you leave the shell." | |
841 | echo | |
842 | ||
bf14fcab | 843 | PS1="$(nls '(Repair filesystem)# ')"; export PS1 |
cc10e704 | 844 | [ "$SELINUX" = "1" ] && disable_selinux |
277e5f53 | 845 | if ! is_no "$RUN_SULOGIN_ON_ERR"; then |
cc10e704 JR |
846 | /sbin/sulogin |
847 | else | |
848 | /bin/sh | |
849 | fi | |
6fa97a5d | 850 | |
cc10e704 JR |
851 | run_cmd "Unmounting file systems" umount -a |
852 | run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / | |
853 | run_cmd "Automatic reboot in progress" reboot | |
854 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then | |
855 | _RUN_QUOTACHECK=1 | |
856 | fi | |
5e6dfc29 | 857 | |
cc10e704 | 858 | show "Remounting encrypted filesystems back in rw mode"; busy |
9f6e3ec0 | 859 | LC_ALL=C awk ' |
cc10e704 JR |
860 | FILENAME=="/proc/mounts" { |
861 | TAB[$2]=$1; | |
862 | } | |
863 | FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { | |
864 | sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4); | |
865 | cmd="mount " $2 " -o remount," $4; | |
866 | system(cmd); | |
867 | } | |
868 | ' /proc/mounts /etc/fstab | |
869 | ok | |
870 | fi | |
6e16ab8f | 871 | |
9a0a016d | 872 | # /var/log should be writable now, so start saving the boot output |
652dbae5 | 873 | if [ "$RC_BOOTLOG" ]; then |
e90f4b95 | 874 | echo > /var/log/boot.log |
652dbae5 ER |
875 | killall -IO blogd |
876 | fi | |
cb4d1aa7 | 877 | |
1aaf8c92 JR |
878 | if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then |
879 | run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa | |
880 | fi | |
cb4d1aa7 | 881 | |
1aaf8c92 JR |
882 | # Turn on quota |
883 | if [ -x /sbin/quotaon ]; then | |
884 | run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug | |
885 | fi | |
677fdd75 | 886 | |
cc311639 | 887 | emit --no-wait local-filesystems |
4db70cd2 JK |
888 | |
889 | # FIXME: this should be delayed until remote filesystems are mounted, | |
890 | # especialy when /usr or other standard fs is remote | |
cc311639 | 891 | emit --no-wait filesystem |
4db70cd2 | 892 | |
1aaf8c92 JR |
893 | # Turn on process accounting |
894 | if [ -x /etc/rc.d/rc.acct ]; then | |
895 | /etc/rc.d/rc.acct start | |
896 | fi | |
cb4d1aa7 | 897 | |
cc10e704 | 898 | # Set the clock if timezone definition wasn't available (eg. /usr not mounted) |
75185230 | 899 | if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then |
37932add | 900 | if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then |
cc10e704 JR |
901 | show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok |
902 | fi | |
0bbfed6f | 903 | fi |
0bbfed6f | 904 | |
cc10e704 JR |
905 | # Initialize the serial ports |
906 | if [ -f /etc/rc.d/rc.serial ]; then | |
907 | . /etc/rc.d/rc.serial | |
908 | fi | |
201c98b9 | 909 | |
277e5f53 | 910 | if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then |
cc10e704 | 911 | show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy |
590eeb64 ER |
912 | # NOTE: you should use /etc/sysctl.conf instead |
913 | if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi | |
cc10e704 | 914 | fi |
201c98b9 | 915 | |
cc10e704 | 916 | # ... and here finish configuring parameters |
5bf237b7 | 917 | sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1 |
ef05209d | 918 | else |
cc311639 JK |
919 | emit --no-wait root-filesystem |
920 | emit --no-wait virtual-filesystems | |
921 | emit --no-wait local-filesystems | |
922 | emit --no-wait filesystem | |
4db70cd2 | 923 | |
fea9b6da | 924 | # /var/log should be writable now, so start saving the boot output |
652dbae5 | 925 | if [ "$RC_BOOTLOG" ]; then |
e90f4b95 | 926 | echo > /var/log/boot.log |
652dbae5 ER |
927 | killall -IO blogd |
928 | fi | |
929 | ||
ef05209d | 930 | clean_vserver_mtab |
cc10e704 | 931 | fi |
adec827a | 932 | |
652dbae5 | 933 | |
1aaf8c92 JR |
934 | [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux |
935 | ||
6239bd5c | 936 | # Clean up /. |
47e385fd | 937 | rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1 |
cb4d1aa7 JR |
938 | |
939 | # Clean up /var | |
5145ce41 | 940 | # /usr could be still not mounted if it is on NFS. |
cb4d1aa7 | 941 | for afile in /var/lock/* /var/run/*; do |
fea9b6da | 942 | bafile=${afile##*/} |
cb4d1aa7 | 943 | if [ -d "$afile" ]; then |
38b419e3 | 944 | case $bafile in |
fea9b6da ER |
945 | news|sudo|mon|cvs) |
946 | ;; | |
947 | *) | |
91dc9337 | 948 | echo $afile/* | xargs rm -rf |
fea9b6da | 949 | ;; |
38b419e3 | 950 | esac |
cb4d1aa7 | 951 | else |
7d175167 | 952 | [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null |
cb4d1aa7 JR |
953 | fi |
954 | done | |
5145ce41 | 955 | |
e0cba078 | 956 | # Delete stale files |
4eb58d70 AM |
957 | rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \ |
958 | /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* | |
959 | rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ | |
5e6dfc29 JR |
960 | /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ |
961 | /tmp/scrollkeeper-* /tmp/ssh-* | |
45955ed4 | 962 | |
201c98b9 | 963 | { |
6b4a354c | 964 | # Clean up utmp/wtmp |
fea9b6da | 965 | if ! is_no "$NEED_XFILES"; then |
6b4a354c AM |
966 | :>/var/run/utmpx |
967 | touch /var/log/wtmpx | |
afa9b748 | 968 | chown root:utmp /var/run/utmpx /var/log/wtmpx |
19b0557d | 969 | chmod 0664 /var/run/utmpx /var/log/wtmpx |
054a52c9 JR |
970 | else |
971 | :>/var/run/utmp | |
972 | touch /var/log/wtmp | |
afa9b748 | 973 | chown root:utmp /var/run/utmp /var/log/wtmp |
19b0557d | 974 | chmod 0664 /var/run/utmp /var/log/wtmp |
6b4a354c | 975 | fi |
7e04fe0e | 976 | |
7e04fe0e | 977 | # Clean /tmp |
a90039da ER |
978 | if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then |
979 | LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]* | |
7e04fe0e | 980 | fi |
7742e157 | 981 | |
e6c8dd44 AM |
982 | # System protected dirs |
983 | mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1 | |
984 | chown root:root /tmp/.ICE-unix | |
677fdd75 | 985 | [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1 |
e6c8dd44 | 986 | |
1aaf8c92 | 987 | if ! is_yes "$VSERVER"; then |
5bf237b7 | 988 | run_cmd "Enabling swap space" true |
1aaf8c92 JR |
989 | # Right, now turn on swap in case we swap to files |
990 | swapon -a >/dev/null 2>&1 | |
cc311639 | 991 | emit --no-wait all-swaps |
7742e157 | 992 | |
0d60cc3e JR |
993 | # If a SCSI tape has been detected, load the st module unconditionally |
994 | # since many SCSI tapes don't deal well with st being loaded and unloaded | |
995 | if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then | |
996 | if grep -qv ' 9 st' /proc/devices 2>/dev/null; then | |
997 | if [ -n "$USEMODULES" ] ; then | |
998 | # Try to load the module. If it fails, ignore it... | |
999 | insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1 | |
1000 | fi | |
7742e157 AF |
1001 | fi |
1002 | fi | |
7742e157 | 1003 | |
cc10e704 JR |
1004 | # Now that we have all of our basic modules loaded and the kernel going, |
1005 | # let's dump the syslog ring somewhere so we can find it later | |
79955f85 | 1006 | dmesg --raw > /var/log/dmesg |
cc10e704 JR |
1007 | i=5 |
1008 | while [ $i -ge 0 ]; do | |
1009 | if [ -f /var/log/dmesg.$i ]; then | |
5e6dfc29 JR |
1010 | chmod 0600 /var/log/dmesg.$i |
1011 | mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1)) | |
cc10e704 JR |
1012 | fi |
1013 | i=$(($i-1)) | |
1014 | done | |
1015 | cp -f /var/log/dmesg /var/log/dmesg.0 | |
1016 | chmod 0600 /var/log/dmesg /var/log/dmesg.0 | |
4db70cd2 | 1017 | else |
cc311639 | 1018 | emit --no-wait all-swaps |
cc10e704 | 1019 | fi |
7742e157 | 1020 | |
a81df7c5 AM |
1021 | if ! is_no "$RC_PROMPT"; then |
1022 | while :; do | |
1023 | pid=$(/sbin/pidof getkey) | |
1024 | [ -n "$pid" -o -e /var/run/getkey_done ] && break | |
1025 | usleep 100000 | |
1026 | done | |
1027 | [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1 | |
1028 | fi | |
6b4a354c | 1029 | } & |
385dc542 | 1030 | |
863baad1 | 1031 | # /proc extra check if the background process we just spawned is still running, |
385dc542 | 1032 | # as in case of vserver bootup it finishes quite instantly. |
863baad1 | 1033 | if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then |
a81df7c5 AM |
1034 | /sbin/getkey i && touch /var/run/confirm |
1035 | touch /var/run/getkey_done | |
6b4a354c AM |
1036 | fi |
1037 | wait | |
a81df7c5 AM |
1038 | if ! is_no "$RC_PROMPT"; then |
1039 | rm -f /var/run/getkey_done | |
1040 | fi | |
de1fc6ce | 1041 | echo |
4db70cd2 | 1042 | |
cc311639 | 1043 | emit --no-wait pld.sysinit-done |
4db70cd2 | 1044 |