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