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