[1108] | 1 | #!/bin/bash |
---|
| 2 | # |
---|
| 3 | # /etc/rc.sysinit - run once at boot time |
---|
| 4 | # |
---|
| 5 | # Taken in part from Miquel van Smoorenburg's bcheckrc. |
---|
| 6 | # |
---|
| 7 | |
---|
| 8 | # Set the path |
---|
| 9 | PATH=/bin:/sbin:/usr/bin:/usr/sbin |
---|
| 10 | export PATH |
---|
| 11 | |
---|
| 12 | HOSTNAME=`/bin/hostname` |
---|
| 13 | HOSTTYPE=`uname -m` |
---|
| 14 | KERNELRELEASE=`uname -r` |
---|
| 15 | KERNELVERSION=`echo $KERNELRELEASE | cut -f 1-2 -d.` |
---|
| 16 | |
---|
| 17 | # VLEE: make host dependent /etc |
---|
| 18 | if [ -x /etc/rc.diskless ]; then |
---|
| 19 | echo -n "Preparing diskless setup :" |
---|
| 20 | if /etc/rc.diskless ; then |
---|
| 21 | echo " [ OK ]" |
---|
| 22 | else |
---|
| 23 | echo " [ NG ]" |
---|
| 24 | fi |
---|
| 25 | elif [ -x /DLKit/etc/rc.diskless ]; then |
---|
| 26 | echo -n "Preparing diskless setup :" |
---|
| 27 | if /DLKit/etc/rc.diskless ; then |
---|
| 28 | echo " [ OK ]" |
---|
| 29 | else |
---|
| 30 | echo " [ NG ]" |
---|
| 31 | fi |
---|
| 32 | fi |
---|
| 33 | |
---|
| 34 | # Read in config data. |
---|
| 35 | if [ -f /etc/sysconfig/network ]; then |
---|
| 36 | . /etc/sysconfig/network |
---|
| 37 | else |
---|
| 38 | NETWORKING=no |
---|
| 39 | fi |
---|
| 40 | |
---|
| 41 | if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then |
---|
| 42 | HOSTNAME=localhost |
---|
| 43 | fi |
---|
| 44 | |
---|
| 45 | # Mount /proc, /sys |
---|
| 46 | if [ ! -e /proc/mounts ]; then |
---|
| 47 | mount -n -t proc /proc /proc |
---|
| 48 | mount -n -t sysfs /sys /sys >/dev/null 2>&1 |
---|
| 49 | fi |
---|
| 50 | if [ ! -d /proc/bus/usb ]; then |
---|
| 51 | modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb |
---|
| 52 | else |
---|
| 53 | mount -n -t usbfs /proc/bus/usb /proc/bus/usb |
---|
| 54 | fi |
---|
| 55 | |
---|
| 56 | # readahead |
---|
| 57 | if [ -f /.readahead_collect -a -r /etc/sysconfig/readahead ]; then |
---|
| 58 | . /etc/sysconfig/readahead |
---|
| 59 | if [ "x$READAHEAD_COLLECT" == "xyes" -a ! -f /forcefsck -a -x /sbin/readahead-collector ]; then |
---|
| 60 | /sbin/readahead-collector |
---|
| 61 | fi |
---|
| 62 | elif [ -x /sbin/readahead_early ]; then |
---|
| 63 | /sbin/readahead_early & |
---|
| 64 | fi |
---|
| 65 | |
---|
| 66 | if [ -x /etc/rc.early.local ]; then |
---|
| 67 | . /etc/rc.early.local |
---|
| 68 | fi |
---|
| 69 | |
---|
| 70 | # Source functions |
---|
| 71 | . /etc/init.d/functions |
---|
| 72 | |
---|
| 73 | PLYMOUTH= |
---|
| 74 | [ -x /usr/bin/plymouth ] && PLYMOUTH=yes |
---|
| 75 | |
---|
| 76 | # Print a banner. ;) |
---|
| 77 | echo -en $"\t\t\tWelcome to " |
---|
| 78 | [ "$BOOTUP" != "serial" ] && echo -en $"\\033[1;36m" |
---|
| 79 | echo -en $"Vine" |
---|
| 80 | [ "$BOOTUP" != "serial" ] && echo -en $"\\033[0;39m" |
---|
| 81 | echo $" Linux" |
---|
| 82 | if [ "$PROMPT" != "no" ]; then |
---|
| 83 | echo -en $"\t\tPress 'I' to enter interactive startup." |
---|
| 84 | echo |
---|
| 85 | fi |
---|
| 86 | |
---|
| 87 | # Fix console loglevel |
---|
| 88 | /bin/dmesg -n $LOGLEVEL |
---|
| 89 | |
---|
| 90 | # read /proc/cmdline once |
---|
| 91 | cmdline=$(cat /proc/cmdline) |
---|
| 92 | |
---|
| 93 | # Initialize hardware |
---|
| 94 | if [ -f /proc/sys/kernel/modprobe ]; then |
---|
| 95 | if ! strstr "$cmdline" nomodules && [ -f /proc/modules ] ; then |
---|
| 96 | sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1 |
---|
| 97 | else |
---|
| 98 | sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1 |
---|
| 99 | fi |
---|
| 100 | fi |
---|
[3690] | 101 | |
---|
| 102 | touch /dev/.in_sysinit >/dev/null 2>&1 |
---|
| 103 | |
---|
[1108] | 104 | # kill nash and start udev |
---|
| 105 | nashpid=$(pidof nash 2>/dev/null) |
---|
| 106 | [ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1 |
---|
| 107 | unset nashpid |
---|
[3727] | 108 | if [ ! -f "/lxcroot" ]; then |
---|
| 109 | /sbin/start_udev |
---|
| 110 | fi |
---|
[1108] | 111 | |
---|
[3727] | 112 | # static /dev filesystem |
---|
| 113 | if [ -x /etc/rc.MAKEDEV ]; then |
---|
| 114 | action $"Making and Mounting /dev filesystem: " /etc/rc.d/rc.MAKEDEV |
---|
| 115 | elif [ -x /DLKit/etc/rc.MAKEDEV ]; then |
---|
| 116 | action $"Making and Mounting /dev filesystem: " /DLKit/etc/rc.d/rc.MAKEDEV |
---|
| 117 | fi |
---|
| 118 | |
---|
[1108] | 119 | # Load user-defined modules |
---|
| 120 | for file in /etc/sysconfig/modules/*.modules ; do |
---|
| 121 | [ -x $file ] && $file |
---|
| 122 | done |
---|
| 123 | |
---|
| 124 | # Load modules (for backward compatibility with VARs) |
---|
| 125 | if [ -f /etc/rc.modules ]; then |
---|
| 126 | /etc/rc.modules |
---|
| 127 | fi |
---|
| 128 | |
---|
| 129 | # Unmount the initrd, if necessary |
---|
| 130 | if grep -q /initrd /proc/mounts && ! grep -q /initrd/loopfs /proc/mounts ; then |
---|
| 131 | action $"Unmounting initrd: " umount /initrd |
---|
| 132 | /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 |
---|
| 133 | fi |
---|
| 134 | |
---|
| 135 | # load SCSI modules |
---|
| 136 | for module in `/sbin/modprobe -c | LC_ALL=C awk '/^alias[[:space:]]+scsi_hostadapter[0-9]*[[:space:]]/ { print $3 }'` |
---|
| 137 | do |
---|
[3551] | 138 | if ( modprobe --dry-run $module 2> /dev/null ) ; then |
---|
| 139 | action $"Loading SCSI module ($module): " /sbin/modprobe $module |
---|
| 140 | fi |
---|
[1108] | 141 | done |
---|
| 142 | |
---|
| 143 | # Configure kernel parameters |
---|
| 144 | update_boot_stage RCkernelparam |
---|
| 145 | action $"Configuring kernel parameters: " sysctl -e -p /etc/sysctl.conf |
---|
| 146 | |
---|
| 147 | # Set the system clock. |
---|
| 148 | ARC=0 |
---|
| 149 | SRM=0 |
---|
| 150 | UTC=0 |
---|
| 151 | |
---|
| 152 | if [ -f /etc/sysconfig/clock ]; then |
---|
| 153 | . /etc/sysconfig/clock |
---|
| 154 | |
---|
| 155 | # convert old style clock config to new values |
---|
| 156 | if [ "${CLOCKMODE}" = "GMT" ]; then |
---|
| 157 | UTC=true |
---|
| 158 | elif [ "${CLOCKMODE}" = "ARC" ]; then |
---|
| 159 | ARC=true |
---|
| 160 | fi |
---|
| 161 | fi |
---|
| 162 | |
---|
| 163 | CLOCKDEF="" |
---|
| 164 | CLOCKFLAGS="$CLOCKFLAGS --hctosys" |
---|
| 165 | |
---|
| 166 | case "$UTC" in |
---|
| 167 | yes|true) |
---|
| 168 | CLOCKFLAGS="$CLOCKFLAGS --utc"; |
---|
| 169 | CLOCKDEF="$CLOCKDEF (utc)"; |
---|
| 170 | ;; |
---|
| 171 | no|false) |
---|
| 172 | CLOCKFLAGS="$CLOCKFLAGS --localtime"; |
---|
| 173 | CLOCKDEF="$CLOCKDEF (localtime)"; |
---|
| 174 | ;; |
---|
| 175 | esac |
---|
| 176 | |
---|
| 177 | case "$ARC" in |
---|
| 178 | yes|true) |
---|
| 179 | CLOCKFLAGS="$CLOCKFLAGS --arc"; |
---|
| 180 | CLOCKDEF="$CLOCKDEF (arc)"; |
---|
| 181 | ;; |
---|
| 182 | esac |
---|
| 183 | case "$SRM" in |
---|
| 184 | yes|true) |
---|
| 185 | CLOCKFLAGS="$CLOCKFLAGS --srm"; |
---|
| 186 | CLOCKDEF="$CLOCKDEF (srm)"; |
---|
| 187 | ;; |
---|
| 188 | esac |
---|
| 189 | |
---|
| 190 | /sbin/hwclock $CLOCKFLAGS |
---|
| 191 | |
---|
| 192 | action $"Setting clock $CLOCKDEF: `date`" date |
---|
| 193 | |
---|
| 194 | if [ "`/sbin/consoletype`" = "vt" ]; then |
---|
| 195 | # Load keymap |
---|
| 196 | if [ -x /bin/loadkeys ]; then |
---|
| 197 | KEYTABLE= |
---|
| 198 | KEYMAP= |
---|
| 199 | if [ -f /etc/sysconfig/console/default.kmap ]; then |
---|
| 200 | KEYMAP=/etc/sysconfig/console/default.kmap |
---|
| 201 | else |
---|
| 202 | if [ -f /etc/sysconfig/keyboard ]; then |
---|
| 203 | . /etc/sysconfig/keyboard |
---|
| 204 | fi |
---|
| 205 | if [ -n "$KEYTABLE" -a -d "/lib/kbd/keymaps" ]; then |
---|
| 206 | KEYMAP=$KEYTABLE |
---|
| 207 | fi |
---|
| 208 | fi |
---|
| 209 | if [ -n "$KEYMAP" ]; then |
---|
| 210 | # Since this takes in/output from stdin/out, we can't use initlog |
---|
| 211 | if [ -n "$KEYTABLE" ]; then |
---|
| 212 | echo -n $"Loading default keymap ($KEYTABLE): " |
---|
| 213 | else |
---|
| 214 | echo -n $"Loading default keymap: " |
---|
| 215 | fi |
---|
| 216 | loadkeys $KEYMAP < /dev/tty0 > /dev/tty0 2>/dev/null && \ |
---|
| 217 | success $"Loading default keymap" || failure $"Loading default keymap" |
---|
| 218 | echo |
---|
| 219 | fi |
---|
| 220 | fi |
---|
| 221 | fi |
---|
| 222 | |
---|
| 223 | # Start up swapping. |
---|
| 224 | action $"Activating swap partitions: " swapon -a -e |
---|
| 225 | |
---|
| 226 | # Set the hostname. |
---|
| 227 | update_boot_stage RChostname |
---|
| 228 | action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME} |
---|
| 229 | |
---|
[3551] | 230 | # Sync waiting for storage. |
---|
| 231 | { rmmod scsi_wait_scan ; modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; } >/dev/null 2>&1 |
---|
| 232 | |
---|
[3690] | 233 | # Device mapper & related initialization |
---|
| 234 | if ! grep -q -F "device-mapper" /proc/devices >/dev/null 2>&1 ; then |
---|
| 235 | modprobe dm-mod >/dev/null 2>&1 |
---|
[1108] | 236 | fi |
---|
| 237 | |
---|
[3690] | 238 | [ -f /etc/mdadm.conf -a -x /sbin/mdadm ] && /sbin/mdadm -As --auto=yes --run |
---|
| 239 | |
---|
| 240 | if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then |
---|
[1108] | 241 | modprobe dm-multipath >/dev/null 2>&1 |
---|
[3588] | 242 | /sbin/multipath -v 0 |
---|
[1108] | 243 | if [ -x /sbin/kpartx ]; then |
---|
| 244 | /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a" |
---|
| 245 | fi |
---|
[3690] | 246 | fi |
---|
[1108] | 247 | |
---|
[3690] | 248 | if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid.static ]; then |
---|
[1108] | 249 | modprobe dm-mirror > /dev/null 2>&1 |
---|
[3690] | 250 | dmraidsets=$(LC_ALL=C /sbin/dmraid -s -c -i) |
---|
| 251 | if [ "$?" = "0" ]; then |
---|
| 252 | for dmname in $dmraidsets; do |
---|
| 253 | if [[ "$dmname" == isw_* ]] && \ |
---|
| 254 | ! strstr "$cmdline" noiswmd; then |
---|
| 255 | continue |
---|
| 256 | fi |
---|
| 257 | /sbin/dmraid.static -ay -i --rm_partitions -p "$dmname" >/dev/null 2>&1 |
---|
| 258 | /sbin/kpartx -a -p p "/dev/mapper/$dmname" |
---|
| 259 | done |
---|
| 260 | fi |
---|
[1108] | 261 | fi |
---|
| 262 | |
---|
[3690] | 263 | # Start any MD RAID arrays that haven't been started yet |
---|
| 264 | [ -r /proc/mdstat ] && [ -r /dev/md/md-device-map ] && /sbin/mdadm -IRs |
---|
| 265 | |
---|
| 266 | if [ -x /sbin/lvm ]; then |
---|
| 267 | action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --sysinit |
---|
| 268 | fi |
---|
| 269 | |
---|
[1108] | 270 | update_boot_stage RCfsck |
---|
| 271 | |
---|
[3727] | 272 | if [ -f /fastboot ] || [ -f /lxcroot ] || strstr "$cmdline" fastboot ; then |
---|
[1108] | 273 | fastboot=yes |
---|
| 274 | else |
---|
| 275 | fastboot= |
---|
| 276 | fi |
---|
| 277 | |
---|
| 278 | if [ -f /fsckoptions ]; then |
---|
| 279 | fsckoptions=`cat /fsckoptions` |
---|
| 280 | else |
---|
| 281 | fsckoptions= |
---|
| 282 | fi |
---|
| 283 | |
---|
| 284 | READONLY= |
---|
| 285 | if [ -f /etc/sysconfig/readonly-root ]; then |
---|
| 286 | . /etc/sysconfig/readonly-root |
---|
| 287 | fi |
---|
| 288 | if strstr "$cmdline" readonlyroot ; then |
---|
| 289 | READONLY=yes |
---|
| 290 | fi |
---|
| 291 | if strstr "$cmdline" noreadonlyroot ; then |
---|
| 292 | READONLY=no |
---|
| 293 | fi |
---|
| 294 | |
---|
| 295 | |
---|
| 296 | if [ -f /forcefsck ]; then |
---|
| 297 | fsckoptions="-f $fsckoptions" |
---|
[3727] | 298 | elif [ -f /.autofsck ] && [ ! -f /lxcroot ]; then |
---|
[1108] | 299 | echo $"Your system appears to have shut down uncleanly" |
---|
| 300 | AUTOFSCK_TIMEOUT=5 |
---|
| 301 | AUTOFSCK_DEF_CHECK=no |
---|
| 302 | [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck |
---|
| 303 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
---|
| 304 | AUTOFSCK_OPT=-f |
---|
| 305 | else |
---|
| 306 | AUTOFSCK_OPT= |
---|
| 307 | fi |
---|
| 308 | |
---|
| 309 | if [ "$PROMPT" != "no" ]; then |
---|
| 310 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
---|
| 311 | if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press N within %d seconds to not force file system integrity check..." n ; then |
---|
| 312 | AUTOFSCK_OPT= |
---|
| 313 | fi |
---|
| 314 | else |
---|
| 315 | if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press Y within %d seconds to force file system integrity check..." y ; then |
---|
| 316 | AUTOFSCK_OPT=-f |
---|
| 317 | fi |
---|
| 318 | fi |
---|
| 319 | echo |
---|
| 320 | else |
---|
| 321 | # PROMPT not allowed |
---|
| 322 | if [ "$AUTOFSCK_DEF_CHECK" = "yes" ] ; then |
---|
| 323 | echo $"Forcing file system integrity check due to default setting" |
---|
| 324 | else |
---|
| 325 | echo $"Not forcing file system integrity check due to default setting" |
---|
| 326 | fi |
---|
| 327 | fi |
---|
| 328 | fsckoptions="$AUTOFSCK_OPT $fsckoptions" |
---|
| 329 | fi |
---|
| 330 | |
---|
| 331 | if [ "$BOOTUP" != "serial" ]; then |
---|
| 332 | fsckoptions="-C $fsckoptions" |
---|
| 333 | else |
---|
| 334 | fsckoptions="-V $fsckoptions" |
---|
| 335 | fi |
---|
| 336 | |
---|
| 337 | _RUN_QUOTACHECK=0 |
---|
| 338 | ROOTFSTYPE=`grep " / " /proc/mounts | awk '{ print $3 }'` |
---|
| 339 | if [ -z "$fastboot" -a "$READONLY" != "yes" -a "$ROOTFSTYPE" != "nfs" -a "$ROOTFSTYPE" != "reiserfs" -a "$ROOTFSTYPE" != "unionfs" -a "$ROOTFSTYPE" != "squashfs" ]; then |
---|
| 340 | |
---|
| 341 | STRING=$"Checking root filesystem" |
---|
| 342 | echo $STRING |
---|
[3550] | 343 | fsck -T -a $fsckoptions / |
---|
[1108] | 344 | rc=$? |
---|
| 345 | |
---|
| 346 | if [ "$rc" = "0" ]; then |
---|
| 347 | success "$STRING" |
---|
| 348 | echo |
---|
| 349 | elif [ "$rc" = "1" ]; then |
---|
| 350 | passed $"$STRING" |
---|
| 351 | echo |
---|
| 352 | fi |
---|
| 353 | |
---|
| 354 | # A return of 2 or higher means there were serious problems. |
---|
| 355 | if [ $rc -gt 1 ]; then |
---|
| 356 | [ -n "$PLYMOUTH" ] && plymouth --hide-splash |
---|
| 357 | |
---|
| 358 | failure "$STRING" |
---|
| 359 | echo |
---|
| 360 | echo |
---|
| 361 | echo $"*** An error occurred during the file system check." |
---|
| 362 | echo $"*** Dropping you to a shell; the system will reboot" |
---|
| 363 | echo $"*** when you leave the shell." |
---|
| 364 | |
---|
| 365 | PS1=$"(Repair filesystem) \# # "; export PS1 |
---|
| 366 | sulogin |
---|
| 367 | |
---|
| 368 | echo $"Unmounting file systems" |
---|
| 369 | umount -a |
---|
| 370 | mount -n -o remount,ro / |
---|
| 371 | echo $"Automatic reboot in progress." |
---|
| 372 | reboot -f |
---|
| 373 | elif [ "$rc" = "1" ]; then |
---|
| 374 | _RUN_QUOTACHECK=1 |
---|
| 375 | fi |
---|
| 376 | fi |
---|
| 377 | |
---|
| 378 | update_boot_stage RCquotacheck |
---|
| 379 | |
---|
| 380 | # Possibly update quotas if fsck was run on /. |
---|
| 381 | grep -E '[[:space:]]+/[[:space:]]+' /etc/fstab | \ |
---|
| 382 | awk '{ print $4 }' | \ |
---|
| 383 | grep -q quota |
---|
| 384 | _ROOT_HAS_QUOTA=$? |
---|
| 385 | if [ X"$_RUN_QUOTACHECK" = X1 -a \ |
---|
| 386 | "$_ROOT_HAS_QUOTA" -a \ |
---|
| 387 | -x /sbin/quotacheck ]; then |
---|
| 388 | if [ -x /sbin/convertquota ]; then |
---|
| 389 | if [ -f /quota.user ]; then |
---|
| 390 | action $"Converting old user quota files: " \ |
---|
| 391 | /sbin/convertquota -u / && rm -f /quota.user |
---|
| 392 | fi |
---|
| 393 | if [ -f /quota.group ]; then |
---|
| 394 | action $"Converting old group quota files: " \ |
---|
| 395 | /sbin/convertquota -g / && rm -f /quota.group |
---|
| 396 | fi |
---|
| 397 | fi |
---|
| 398 | action $"Checking root filesystem quotas: " /sbin/quotacheck -nug / |
---|
| 399 | fi |
---|
| 400 | |
---|
| 401 | # check for arguments passed from kernel |
---|
| 402 | |
---|
| 403 | update_boot_stage RCmountfs |
---|
| 404 | |
---|
| 405 | # Remount the root filesystem in specified mode |
---|
| 406 | state=`awk '/(^\/dev\/root| \/ )/ { print $4 }' /proc/mounts` |
---|
| 407 | newstate=`awk '/^#/{next} $2 == "/" {print $4 }' /etc/fstab` |
---|
| 408 | if strstr "$cmdline" no_remount_rootfs ;then |
---|
| 409 | action $"Staying readonly root filesystem mode : " /bin/true |
---|
| 410 | else |
---|
[3727] | 411 | [ "$state" != "rw" ] && [ ! -f "/lxcroot" ] && \ |
---|
[1108] | 412 | action $"Remounting root filesystem in specified mode($newstate): " mount -n -o remount,$newstate / |
---|
| 413 | fi |
---|
| 414 | |
---|
[3549] | 415 | if [ "$READONLY" != "yes" ]; then |
---|
| 416 | # Clear mtab |
---|
| 417 | (>/etc/mtab) &> /dev/null |
---|
[1108] | 418 | |
---|
[3549] | 419 | # Remove stale backups |
---|
| 420 | rm -f /etc/mtab~ /etc/mtab~~ |
---|
[1108] | 421 | |
---|
[3549] | 422 | # Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab. |
---|
| 423 | mount -f / |
---|
| 424 | mount -f /proc >/dev/null 2>&1 |
---|
| 425 | mount -f /sys >/dev/null 2>&1 |
---|
| 426 | mount -f /dev/pts >/dev/null 2>&1 |
---|
| 427 | mount -f /dev/shm >/dev/null 2>&1 |
---|
| 428 | mount -f /proc/bus/usb >/dev/null 2>&1 |
---|
[1108] | 429 | fi |
---|
| 430 | |
---|
| 431 | if strstr "$cmdline" hdparm ;then |
---|
| 432 | update_boot_stage RChdparm |
---|
| 433 | |
---|
| 434 | # Turn on harddisk optimization |
---|
| 435 | # There is only one file /etc/sysconfig/harddisks for all disks |
---|
| 436 | # after installing the hdparm-RPM. If you need different hdparm parameters |
---|
| 437 | # for each of your disks, copy /etc/sysconfig/harddisks to |
---|
| 438 | # /etc/sysconfig/harddiskhda (hdb, hdc...) and modify it. |
---|
| 439 | # each disk which has no special parameters will use the defaults. |
---|
| 440 | |
---|
| 441 | disk[0]=s; disk[1]=hda; disk[2]=hdb; disk[3]=hdc; |
---|
| 442 | disk[4]=hdd; disk[5]=hde; disk[6]=hdf; disk[7]=hdg; disk[8]=hdh; |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | if [ -x /sbin/hdparm ]; then |
---|
| 446 | for device in 0 1 2 3 4 5 6 7 8; do |
---|
| 447 | unset MULTIPLE_IO USE_DMA EIDE_32BIT LOOKAHEAD EXTRA_PARAMS |
---|
| 448 | if [ -f /etc/sysconfig/harddisk${disk[$device]} ]; then |
---|
| 449 | . /etc/sysconfig/harddisk${disk[$device]} |
---|
| 450 | HDFLAGS[$device]= |
---|
| 451 | if [ -n "$MULTIPLE_IO" ]; then |
---|
| 452 | HDFLAGS[$device]="-q -m$MULTIPLE_IO" |
---|
| 453 | fi |
---|
| 454 | if [ -n "$USE_DMA" ]; then |
---|
| 455 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -d$USE_DMA" |
---|
| 456 | fi |
---|
| 457 | if [ -n "$EIDE_32BIT" ]; then |
---|
| 458 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -c$EIDE_32BIT" |
---|
| 459 | fi |
---|
| 460 | if [ -n "$LOOKAHEAD" ]; then |
---|
| 461 | HDFLAGS[$device]="${HDFLAGS[$device]} -q -A$LOOKAHEAD" |
---|
| 462 | fi |
---|
| 463 | if [ -n "$EXTRA_PARAMS" ]; then |
---|
| 464 | HDFLAGS[$device]="${HDFLAGS[$device]} $EXTRA_PARAMS" |
---|
| 465 | fi |
---|
| 466 | else |
---|
| 467 | HDFLAGS[$device]="${HDFLAGS[0]}" |
---|
| 468 | fi |
---|
| 469 | if [ -e "/proc/ide/${disk[$device]}/media" ] ; then |
---|
| 470 | hdmedia=`cat /proc/ide/${disk[$device]}/media` |
---|
| 471 | if [ "$hdmedia" = "disk" ]; then |
---|
| 472 | if [ -n "${HDFLAGS[$device]}" ]; then |
---|
| 473 | action $"Setting hard drive parameters for ${disk[$device]}: " /sbin/hdparm ${HDFLAGS[$device]} /dev/${disk[$device]} |
---|
| 474 | fi |
---|
| 475 | fi |
---|
| 476 | fi |
---|
| 477 | done |
---|
| 478 | fi |
---|
| 479 | fi |
---|
| 480 | |
---|
| 481 | # The root filesystem is now read-write, so we can now log via syslog() directly.. |
---|
| 482 | if [ -n "$IN_INITLOG" ]; then |
---|
| 483 | IN_INITLOG= |
---|
| 484 | fi |
---|
| 485 | |
---|
| 486 | update_boot_stage RCfsck |
---|
| 487 | |
---|
| 488 | _RUN_QUOTACHECK=0 |
---|
| 489 | # Check filesystems |
---|
| 490 | if [ -z "$fastboot" ]; then |
---|
| 491 | STRING=$"Checking filesystems" |
---|
| 492 | echo $STRING |
---|
[3550] | 493 | fsck -T -R -A -a $fsckoptions |
---|
[1108] | 494 | rc=$? |
---|
| 495 | if [ "$rc" = "0" ]; then |
---|
| 496 | success "$STRING" |
---|
| 497 | echo |
---|
| 498 | elif [ "$rc" = "1" ]; then |
---|
| 499 | passed "$STRING" |
---|
| 500 | echo |
---|
| 501 | fi |
---|
| 502 | |
---|
| 503 | # A return of 2 or higher means there were serious problems. |
---|
| 504 | if [ $rc -gt 1 ]; then |
---|
| 505 | failure "$STRING" |
---|
| 506 | echo |
---|
| 507 | echo |
---|
| 508 | echo $"*** An error occurred during the file system check." |
---|
| 509 | echo $"*** Dropping you to a shell; the system will reboot" |
---|
| 510 | echo $"*** when you leave the shell." |
---|
| 511 | |
---|
| 512 | PS1=$"(Repair filesystem) \# # "; export PS1 |
---|
| 513 | sulogin |
---|
| 514 | |
---|
| 515 | echo $"Unmounting file systems" |
---|
| 516 | umount -a |
---|
| 517 | mount -n -o remount,ro / |
---|
| 518 | echo $"Automatic reboot in progress." |
---|
| 519 | reboot -f |
---|
| 520 | elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then |
---|
| 521 | _RUN_QUOTACHECK=1 |
---|
| 522 | fi |
---|
| 523 | fi |
---|
| 524 | |
---|
| 525 | update_boot_stage RClocalfs |
---|
| 526 | |
---|
| 527 | # Mount all other filesystems (except for NFS and /proc, which is already |
---|
| 528 | # mounted). Contrary to standard usage, |
---|
| 529 | # filesystems are NOT unmounted in single user mode. |
---|
[3549] | 530 | if [ "$READONLY" != "yes" ] ; then |
---|
| 531 | action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev >/dev/null 2>&1 |
---|
| 532 | else |
---|
| 533 | action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev >/dev/null 2>&1 |
---|
| 534 | fi |
---|
[1108] | 535 | |
---|
| 536 | # check remaining quotas other than root |
---|
| 537 | if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then |
---|
| 538 | if [ -x /sbin/convertquota ]; then |
---|
| 539 | # try to convert old quotas |
---|
| 540 | for mountpt in `cat /etc/mtab | awk '$4 ~ /quota/{print $2}'`; do |
---|
| 541 | if [ -f "$mountpt/quota.user" ]; then |
---|
| 542 | action $"Converting old user quota files: " \ |
---|
| 543 | /sbin/convertquota -u $mountpt && \ |
---|
| 544 | rm -f $mountpt/quota.user |
---|
| 545 | fi |
---|
| 546 | if [ -f "$mountpt/quota.group" ]; then |
---|
| 547 | action $"Converting old group quota files: " \ |
---|
| 548 | /sbin/convertquota -g $mountpt && \ |
---|
| 549 | rm -f $mountpt/quota.group |
---|
| 550 | fi |
---|
| 551 | done |
---|
| 552 | fi |
---|
| 553 | action $"Checking local filesystem quotas: " /sbin/quotacheck -aRnug |
---|
| 554 | fi |
---|
| 555 | |
---|
| 556 | if [ -x /sbin/quotaon ]; then |
---|
| 557 | action $"Enabling local filesystem quotas: " /sbin/quotaon -aug |
---|
| 558 | fi |
---|
| 559 | |
---|
| 560 | # Configure machine if necessary. |
---|
| 561 | if [ -f /.unconfigured ]; then |
---|
[3549] | 562 | if [ -x /usr/bin/plymouth ]; then |
---|
| 563 | /usr/bin/plymouth quit |
---|
| 564 | fi |
---|
[1108] | 565 | if [ -x /usr/bin/system-config-keyboard ]; then |
---|
| 566 | /usr/bin/system-config-keyboard |
---|
| 567 | fi |
---|
| 568 | if [ -x /usr/bin/passwd ]; then |
---|
| 569 | /usr/bin/passwd root |
---|
| 570 | fi |
---|
| 571 | if [ -x /usr/sbin/system-config-network-tui ]; then |
---|
| 572 | /usr/sbin/system-config-network-tui |
---|
| 573 | fi |
---|
| 574 | if [ -x /usr/sbin/timeconfig ]; then |
---|
| 575 | /usr/sbin/timeconfig |
---|
| 576 | fi |
---|
| 577 | if [ -x /usr/sbin/authconfig-tui ]; then |
---|
| 578 | /usr/sbin/authconfig-tui --nostart |
---|
| 579 | fi |
---|
| 580 | if [ -x /usr/sbin/ntsysv ]; then |
---|
| 581 | /usr/sbin/ntsysv --level 35 |
---|
| 582 | fi |
---|
| 583 | |
---|
| 584 | # Reread in network configuration data. |
---|
| 585 | if [ -f /etc/sysconfig/network ]; then |
---|
| 586 | . /etc/sysconfig/network |
---|
| 587 | |
---|
| 588 | # Reset the hostname. |
---|
| 589 | action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} |
---|
| 590 | fi |
---|
| 591 | |
---|
| 592 | rm -f /.unconfigured |
---|
| 593 | fi |
---|
| 594 | |
---|
| 595 | # Clean out /etc. |
---|
| 596 | rm -f /fastboot /fsckoptions /forcefsck /.autofsck /halt /poweroff |
---|
| 597 | |
---|
| 598 | # Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might... |
---|
| 599 | _NEED_XFILES= |
---|
| 600 | [ -f /var/run/utmpx -o -f /var/log/wtmpx ] && _NEED_XFILES=1 |
---|
| 601 | |
---|
| 602 | # Clean up /var |
---|
| 603 | rm -rf /var/lock/cvs/* /var/run/screen/* |
---|
| 604 | find /var/lock /var/run -type f -exec rm -f {} \; |
---|
| 605 | |
---|
| 606 | rm -f /var/lib/rpm/__db* &> /dev/null |
---|
| 607 | rm -f /var/gdm/.gdmfifo &> /dev/null |
---|
| 608 | |
---|
| 609 | { |
---|
| 610 | # Clean up utmp/wtmp |
---|
| 611 | >/var/run/utmp |
---|
[3727] | 612 | touch /var/log/wtmp /var/log/btmp |
---|
[1108] | 613 | chgrp utmp /var/run/utmp /var/log/wtmp |
---|
| 614 | chmod 0664 /var/run/utmp /var/log/wtmp |
---|
[3690] | 615 | chmod 0600 /var/log/btmp |
---|
[1108] | 616 | if [ -n "$_NEED_XFILES" ]; then |
---|
| 617 | >/var/run/utmpx |
---|
| 618 | touch /var/log/wtmpx |
---|
| 619 | chgrp utmp /var/run/utmpx /var/log/wtmpx |
---|
| 620 | chmod 0664 /var/run/utmpx /var/log/wtmpx |
---|
| 621 | fi |
---|
| 622 | |
---|
| 623 | # Clean up various /tmp bits |
---|
| 624 | rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* \ |
---|
| 625 | /tmp/.esd/* |
---|
| 626 | rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ |
---|
| 627 | /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ |
---|
[3690] | 628 | /tmp/scrollkeeper-* /tmp/ssh-* \ |
---|
| 629 | /dev/.in_sysinit |
---|
[1108] | 630 | # Make ICE directory |
---|
| 631 | mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1 |
---|
| 632 | chown root:root /tmp/.ICE-unix |
---|
| 633 | |
---|
| 634 | # Now turn on swap in case we swap to files. |
---|
[3690] | 635 | update_boot_stage RCswap |
---|
| 636 | action $"Enabling swap space: " swapon -a -e |
---|
[1108] | 637 | |
---|
| 638 | # Initialize the serial ports. |
---|
| 639 | if [ -f /etc/rc.serial ]; then |
---|
| 640 | . /etc/rc.serial |
---|
| 641 | fi |
---|
| 642 | |
---|
| 643 | update_boot_stage RCusbstorage |
---|
| 644 | |
---|
| 645 | # Load usb storage here, to match most other things |
---|
| 646 | if [ -n "$needusbstorage" ]; then |
---|
| 647 | modprobe usb-storage >/dev/null 2>&1 |
---|
| 648 | fi |
---|
| 649 | |
---|
| 650 | # Adjust symlinks as necessary in /boot to keep system services from |
---|
| 651 | # spewing messages about mismatched System maps and so on. |
---|
| 652 | if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ]; then |
---|
| 653 | ln -s -f System.map-`uname -r` /boot/System.map |
---|
| 654 | fi |
---|
| 655 | if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then |
---|
| 656 | ln -s -f System.map-`uname -r` /boot/System.map |
---|
| 657 | fi |
---|
| 658 | |
---|
| 659 | # Now that we have all of our basic modules loaded and the kernel going, |
---|
| 660 | # let's dump the syslog ring somewhere so we can find it later |
---|
| 661 | dmesg -s 131072 > /var/log/dmesg |
---|
| 662 | # Also keep kernel symbols around in case we need them for debugging |
---|
| 663 | i=5 |
---|
| 664 | while [ $i -ge 0 ] ; do |
---|
| 665 | if [ -f /var/log/ksyms.$i ] ; then |
---|
| 666 | mv /var/log/ksyms.$i /var/log/ksyms.$(($i+1)) |
---|
| 667 | fi |
---|
| 668 | i=$(($i-1)) |
---|
| 669 | done |
---|
| 670 | if [ "$KERNELVERSION" = "2.6" ]; then |
---|
| 671 | _ksyms=/proc/kallsyms |
---|
| 672 | else |
---|
| 673 | _ksyms=/proc/ksyms |
---|
| 674 | fi |
---|
| 675 | (/bin/date; |
---|
| 676 | /bin/uname -a; |
---|
| 677 | /bin/cat /proc/cpuinfo; |
---|
| 678 | /bin/cat /proc/modules; |
---|
| 679 | /bin/cat ${_ksyms}) >/var/log/ksyms.0 |
---|
| 680 | # create the crash indicator flag to warn on crashes, offer fsck with timeout |
---|
| 681 | touch /.autofsck |
---|
| 682 | kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1 |
---|
| 683 | } & |
---|
| 684 | if [ "$PROMPT" != "no" ]; then |
---|
| 685 | /sbin/getkey i && touch /var/run/confirm |
---|
| 686 | fi |
---|
| 687 | wait |
---|
| 688 | |
---|
[3690] | 689 | # let plymouth know that we're leaving rc.sysinit |
---|
[2969] | 690 | if [ -x /usr/bin/plymouth ]; then |
---|
| 691 | /usr/bin/plymouth --sysinit |
---|
| 692 | fi |
---|
| 693 | |
---|