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