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