#!/bin/sh # # /etc/rc.d/rc.sysinit - run once at boot time # # Taken in part from Miquel van Smoorenburg's bcheckrc. # # reasonable start values for bootsplash progress. export progress=0 export sscripts=45 export kscripts=45 # NLS if [ -r /etc/sysconfig/i18n ]; then . /etc/sysconfig/i18n [ -n "$LANG" ] && export LANG || unset LANG [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS fi # Read network config data if [ -r /etc/sysconfig/network ]; then . /etc/sysconfig/network else NETWORKING=no HOSTNAME=localhost fi CONSOLE_LOGLEVEL=1 # Read functions . /lib/rc-scripts/functions modprobe_c_cache="" modprobe_c() { if [ "$modprobe_c_cache" ]; then echo "$modprobe_c_cache" return fi # filter only what is wanted by this script: aliases and options modprobe_c_cache=$(modprobe -c | grep -E '^(alias|options)') } # parse kernel cmdline # needs /proc mounted parse_cmdline() { local arg cmdline read cmdline < /proc/cmdline for arg in $cmdline; do case "$arg" in noudev) # default is set in /etc/sysconfig/system START_UDEV=no ;; nomdadm) # default is set in /etc/sysconfig/system MDADM=no ;; nomultipath) # default is set in /etc/sysconfig/system DM_MULTIPATH=no ;; noselinux) # default is set in /etc/sysconfig/system SELINUX=no ;; nousb) nousb=1 ;; nohdparm) nohdparm=1 ;; fastboot) fastboot=1 ;; nopnp) nopnp=1 ;; nomodules) nomodules=1 ;; nofirewire) nofirewire=1 ;; nofsck) nofsck=1 ;; esac done } # resolve a device node to its major:minor numbers in decimal or hex get_numeric_dev() { local dev=$1 enc=${2:-hex} res res=$(stat -Lc "%t:%T" "$dev") if [ "$enc" = dec ]; then local oifs=$IFS IFS=":" set -- $res IFS=$oifs res=$((0x$1)):$((0x$2)) fi echo -n $res } # setup SELINUX variable init_selinux() { # user knows! if is_no "$SELINUX"; then return fi if ! grep -Fq selinuxfs /proc/filesystems; then # no support in kernel, no chance SELINUX=no elif ! is_fsmounted selinuxfs /selinux; then mount -n -o gid=17 -t selinuxfs selinuxfs /selinux fi # Check SELinux status local selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null) SELINUX= if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then if [ -r $selinuxfs/enforce ] ; then SELINUX=$(cat $selinuxfs/enforce) else # assume enforcing if you can't read it SELINUX=1 fi fi } disable_selinux() { local _d selinuxfs _t _r while read _d selinuxfs _t _r; do [ "$_t" = "selinuxfs" ] && break done $selinuxfs/enforce } relabel_selinux() { local _d selinuxfs _t _r while read _d selinuxfs _t _r; do [ "$_t" = "selinuxfs" ] && break done $selinuxfs/enforce /sbin/fixfiles -F relabel > /dev/null 2>&1 rm -f /.autorelabel echo "*** Enabling security enforcement. ***" echo $SELINUX > $selinuxfs/enforce } # Enable automatic swapon of all partitions with the proper swap magic. # This allows setting up swap without editing /etc/fstab. enable_autoswap() { local swappartitions=$(blkid -t TYPE=swap -o device) if [ -z "$swappartitions" ]; then return fi local curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do echo -n " "; get_numeric_dev $x; echo -n " "; done) local partition for partition in $swappartitions; do [ ! -e $partition ] && continue majmin=$(get_numeric_dev $partition) if ! strstr "$curswap" " $majmin "; then run_cmd "$(nls 'Enabling local swap partitions: %s' $partition)" swapon $partition fi done } enable_swap() { run_cmd "Activating swap" swapon -a "$@" is_yes "$AUTOSWAP" && enable_autoswap } # Remove duplicate entries from mtab (for vserver guest use only) clean_vserver_mtab() { > /etc/mtab.clean while read device mountpoint line; do grep -qs "$mountpoint" /etc/mtab.clean || \ echo "$device $mountpoint $line" >> /etc/mtab.clean done < /etc/mtab cat /etc/mtab.clean > /etc/mtab rm -f /etc/mtab.clean } # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z load_kernel_modules() { local modules_file=$1 local _x _y _z v v1 old_IFS kernel kerneleq { read _x _y v _z old_IFS=$IFS # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1" IFS='_-' set -- $v v1=${1} IFS='.' set -- $v1 IFS=$old_IFS kernel="$1.$2" kerneleq="$1.$2.$3" } < /proc/version local module args # Loop over every line in modules file ( \ grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null echo '' # make sure there is a LF at the end ) | while read module args; do [ -z "$module" ] && continue # strip comments args=${args%%#*} show "Loading %s kernel module(s)" "$module" busy modprobe -s $module -- $args && ok || fail done } # launch repair shell # which after exiting will reboot repair_shell() { local reason="$2" # don't use '\n' in nls macro ! echo echo echo "$reason" nls "*** Dropping you to a shell; the system will reboot" nls "*** when you leave the shell." echo [ "$SELINUX" = "1" ] && disable_selinux if ! is_no "$RUN_SULOGIN_ON_ERR"; then /sbin/sulogin else /bin/sh fi run_cmd "Unmounting file systems" umount -a run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / run_cmd "Automatic reboot in progress" reboot } check_root_fs() { show "Checking root filesystem"; started initlog -c "fsck -C -T -a $fsckoptions /" rc=$? # A return of 4 or higher means there were serious problems. if [ $rc -gt 3 ]; then [ -e /proc/splash ] && echo "verbose" > /proc/splash PS1="$(nls '(Repair filesystem)# ')"; export PS1 repair_shell "$(nls '*** An error occurred during the file system check.')" # A return of 2 or 3 means that filesystem was repaired but we need # to reboot. elif [ "$rc" = "2" -o "$rc" = "3" ]; then [ -e /proc/splash ] && echo "verbose" > /proc/splash echo nls "*** Filesystem was repaired but system needs to be" nls "*** rebooted before mounting it." nls "*** REBOOTING ***" echo run_cmd "Unmounting file systems" umount -a mount -n -o remount,ro / run_cmd "Automatic reboot in progress" reboot elif [ "$rc" = "1" ]; then _RUN_QUOTACHECK=1 fi } # Init software RAID arrays init_mdadm() { local output if [ ! -x /sbin/mdadm ]; then return fi modprobe -s md if [ ! -f /proc/mdstat ]; then return fi show "Starting up RAID devices"; busy output=$(/sbin/mdadm --assemble --scan 2>&1) ok if [ -n "$output" ]; then echo "$output" fi } # Init LVM init_lvm() { if [ ! -x /sbin/vgscan -o ! -x /sbin/vgchange ] && ! is_yes "$EVMS_LVM"; then return fi if is_no "$LVM2"; then lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}') else lvmversion=2 fi if [ "$lvmversion" = "1" ] ; then modprobe -s lvm-mod lvmignorelocking="" lvmsysinit="" elif [ "$lvmversion" = "2" ] ; then modprobe -s dm-mod lvmignorelocking="--ignorelockingfailure" lvmsysinit="--sysinit" else modprobe -s lvm-mod # device mapper (2.5+ and patched 2.4) modprobe -s dm-mod lvmignorelocking="" lvmsysinit="" fi run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit if [ "$lvmversion" = "2" ]; then # silently refresh LV /dev nodes (just in case) /sbin/vgmknodes $lvmignorelocking 1>/dev/null 2>&1 # display VG statistics /sbin/vgdisplay -s $lvmignorelocking fi } # boot logging to /var/log/boot.log. install showconsole package to get it. if ! is_no "$RC_BOOTLOG" && [ -x /sbin/blogd ]; then RC_BOOTLOG=1 else RC_BOOTLOG= fi if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then # we need /proc mounted before everything is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc parse_cmdline if [ -d /run ]; then is_fsmounted tmpfs /run || mount -n -t tmpfs run /run -o mode=0755,noexec,nosuid,nodev fi # Early sysctls apply_sysctl # sysfs is also needed before any other things (under kernel > 2.5) if ! is_fsmounted sysfs /sys; then grep -Fq sysfs /proc/filesystems && mount -n -o gid=17 -t sysfs sysfs /sys fi if grep -Fq securityfs /proc/filesystems; then mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security fi init_selinux # TLD Linux LiveCD support if [ -x /etc/rc.d/rc.live ]; then /etc/rc.d/rc.live fi # Choose Hardware profile if ! is_no "$HWPROFILES" && [ -f /etc/sysconfig/hwprof ]; then . /etc/sysconfig/hwprof if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then mount -n / -o rw,remount /sbin/hwprofile -qf mount -n / -o ro,remount fi fi # Disable splash when requested is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then /sbin/restorecon -R /dev 2>/dev/null fi [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)" if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then /sbin/setsysfont fi fi # Print welcome message nls "\t\t\t%sPowered by %sTLD Linux%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CTLD)" "$(termput op)" if ! is_no "$RC_PROMPT"; then nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)" echo fi # Set the hostname if [ -z "${HOSTNAME}" ]; then show "$(nls 'Host:') $(hostname)"; ok else run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME} fi # Set the NIS domain name if [ -n "$NISDOMAIN" ]; then run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN else domainname "" fi if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then # Set console loglevel if [ -n "$CONSOLE_LOGLEVEL" ]; then dmesg -n $CONSOLE_LOGLEVEL fi if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev load_kernel_modules modules.preudev /sbin/start_udev elif [ -x /lib/firmware/firmware-loader.sh ]; then /sbin/sysctl -q -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh fi # Unmount the initrd, if necessary if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then umount /initrd/dev 2>/dev/null umount /initrd /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 fi # Start logging console output since we have all /dev stuff setup if [ "$RC_BOOTLOG" ]; then /sbin/blogd fi # Configure Linux kernel (initial configuration, some required modules still may be missing). apply_sysctl # Check if timezone definition is available if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok fi else TIME_SETUP_DELAYED=yes fi delay_cryptsetup=0 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then # XXX might need modules dep # Device mapper & related initialization if ! grep -qF device-mapper /proc/devices; then modprobe -s dm-mod fi . /etc/rc.d/init.d/cryptsetup show "Starting disk encryption" init_crypto 0 delay_cryptsetup=$? [ $delay_cryptsetup = 0 ] && ok || fail fi # Start up swapping enable_swap -e # Initialize USB controllers usb=0 if [ -z "$nousb" ] && ! is_fsmounted usbfs /proc/bus/usb; then aliases=$(modprobe_c | awk '/^alias[[:space:]]+usb[-_]controller[[:space:]]+/{ print $3 }') if [ -n "$aliases" -a "$aliases" != "off" ] ; then modprobe -s usbcore for alias in $aliases ; do [ "$alias" = "off" ] && continue run_cmd "$(nls 'Initializing USB controller') ($alias)" modprobe -s $alias done [ $? -eq 0 -a -n "$aliases" ] && usb=1 fi if grep -iq "usb" /proc/devices 2>/dev/null ; then usb=1 fi fi if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! is_fsmounted usbfs /proc/bus/usb; then run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb fi needusbstorage= if [ "$usb" = "1" ]; then needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null) if [ "$(kernelverser)" -lt "002006" ]; then grep -Fq 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe -s hid mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null) kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null) if [ -n "$kbdoutput" ]; then run_cmd "Initializing USB keyboard" modprobe -s keybdev fi if [ -n "$mouseoutput" ]; then run_cmd "Initializing USB mouse" modprobe -s mousedev fi fi fi # Setup hdparm thing (if exists and is needed) if [ -z "$nohdparm" ]; then [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm fi if [ -z "$fastboot" ] && [ -f /fastboot ]; then fastboot=1 fi if [ -f /fsckoptions ]; then fsckoptions=$(cat /fsckoptions) else fsckoptions='' fi if [ -f /forcefsck ]; then fsckoptions="-f $fsckoptions" else # Obey the fs_passno setting for / (see fstab(5)) # - find the / entry # - make sure we have at least 6 fields _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab) fi _RUN_QUOTACHECK=0 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab) _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null) if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "aufs" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_TYPE" != "tmpfs" -a "$_ROOTFS_TYPE" != "squashfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ] && [[ "$container" != lxc* ]]; then check_root_fs fi # set up pnp and kernel pnp if is_yes "$RUN_USERPNP" || is_yes "$RUN_KERNELPNP"; then if [ -z "$nopnp" ] && is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf fi if [ -z "$nopnp" ] && is_yes "$RUN_KERNELPNP"; then modprobe -s isa-pnp if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then show "Setting up ISA PNP devices (kernelspace pnp)"; busy grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail) fi fi fi _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab) # Remount the root filesystem read-write if [ -z "$_ROOTFS_RO" ]; then run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw / fi # Update quotas if fsck was run on / if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug / fi # Clean up SELinux labels if is_yes "$SELINUX"; then for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache; do [ -r $file ] && restorecon $file >/dev/null 2>&1 done fi if [ "$delay_cryptsetup" != 0 ]; then show "Starting disk encryption using the RNG" init_crypto 1 delay_cryptsetup=$? [ $delay_cryptsetup = 0 ] && ok || fail fi else # Start logging console output since we have all /dev stuff setup if [ "$RC_BOOTLOG" ]; then /sbin/blogd -q fi fi # Remove stale backups rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1 # Remove /etc/nologin when starting system [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then show "Enabling Delay Login"; busy echo > /etc/nologin nls "System bootup in progress - please wait" >> /etc/nologin echo >> /etc/nologin chmod 644 /etc/nologin cp -fp /etc/nologin /etc/nologin.boot ok fi # The root filesystem is now read-write, so we can now log via # syslog() directly... if [ -n "$IN_INITLOG" ]; then IN_INITLOG="" fi if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then # Clear mtab > /etc/mtab [ -f /etc/cryptomtab ] && > /etc/cryptomtab # Enter root, /proc, /sys and other into mtab. mount -f / 2> /dev/null mount -f /proc 2> /dev/null if is_fsmounted devtmpfs /dev; then mount -f -t devtmpfs devtmpfs /dev 2> /dev/null fi if is_fsmounted tmpfs /run; then mount -f -t tmpfs run /run -o mode=0755,noexec,nosuid,nodev 2> /dev/null fi if is_fsmounted usbfs /proc/bus/usb; then mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null fi if is_fsmounted sysfs /sys; then mount -f -t sysfs sysfs /sys 2> /dev/null if is_fsmounted securityfs /sys/kernel/security ; then mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null fi fi if is_fsmounted selinuxfs /selinux; then mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null fi if [ ! -f /proc/modules ]; then USEMODULES= elif [ -z "$nomodules" ]; then USEMODULES=y else USEMODULES= fi uname_r=$(uname -r) # Adjust symlinks as necessary in /boot to keep system services from # spewing messages about mismatched System maps and so on. if ! is_no "$SET_SLINKS"; then if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then ln -s -f System.map-$uname_r /boot/System.map fi if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then ln -s -f System.map-$uname_r /boot/System.map fi fi # Run depmod if RUN_DEPMOD != "no" and: # a) user requested or RUN_DEPMOD=""; # b) modules.dep is missing if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then run_cmd "Finding module dependencies" depmod -a elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then run_cmd "Finding module dependencies" depmod -A fi fi unset uname_r if [ -f /proc/sys/kernel/modprobe ]; then if [ -n "$USEMODULES" ]; then sysctl -q -w kernel.modprobe="/sbin/modprobe" else # We used to set this to NULL, but that causes # 'failed to exec' messages" sysctl -q -w kernel.modprobe="/bin/true" fi fi # Load usb storage here, to match most other things if [ -n "$needusbstorage" ]; then modprobe -s usb-storage fi # Load firewire devices if [ -z "$nofirewire" ]; then aliases=$(modprobe_c | awk '/^alias[[:space:]]+ieee1394[-_]controller[[:space:]]+/{ print $3 }') if [ -n "$aliases" -a "$aliases" != "off" ] ; then for alias in $aliases ; do [ "$alias" = "off" ] && continue run_cmd "$(nls 'Initializing firewire controller') ($alias)" modprobe $alias done grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && modprobe -s sbp2 fi fi # Load sound modules if they need persistent DMA buffers if modprobe_c | grep -q "^options sound dmabuf=1"; then RETURN=0 alias=$(modprobe_c | awk '/^alias[[:space:]]+sound[[:space:]]+/{ print $3 }') if [ -n "$alias" -a "$alias" != "off" ] ; then run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias RETURN=$? fi alias=$(modprobe_c | awk '/^alias[[:space:]]+sound[-_]slot[-_]0[[:space:]]+/ { print $3 }') if [ -n "$alias" -a "$alias" != "off" ] ; then run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias RETURN=$? fi fi # Load modules load_kernel_modules modules for f in /etc/modules-load.d/*.conf; do # already loaded by implicit "modules" load [ "${f##*/}" = "modules.conf" ] && continue [ -r $f ] || continue load_kernel_modules ${f##/etc/} done if ! is_no "$DM_MULTIPATH" && [ -x /sbin/multipath ]; then modprobe -s dm-mod modprobe -s dm-multipath # make nodes that were discarded due (possible) new /dev mount /sbin/dmsetup mknodes run_cmd "Activating dm-multipath" /sbin/multipath -v 0 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p' fi if ! is_no "$DMRAID" && [ -x /sbin/dmraid ]; then run_cmd "Activating ATARAID devices" /sbin/dmraid -ay fi # Find and activate volume groups: # EVMS if is_yes "$EVMS_LVM" && [ -x /sbin/evms_activate ]; then if [ "$(kernelverser)" -lt "002006" ]; then # Linux 2.4 core modules modprobe -s evms modprobe -s evms_passthru modprobe -s ldev_mgr modprobe -s dos_part else # Linux 2.6 core module modprobe -s evmscore fi is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part is_yes "$EVMS_LVM" && modprobe -s lvm_vge is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge run_cmd "Discovering EVMS volumes" /sbin/evms_activate if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then # Link nodes for compatibility with LVM if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then ln -s /dev/evms/lvm/* /dev fi fi fi if ! is_no "$MDADM"; then init_mdadm fi if ! is_no "$LVM2"; then init_lvm fi if [ "$delay_cryptsetup" != 0 ]; then show "Starting disk encryption" init_crypto 1 delay_cryptsetup=$? [ $delay_cryptsetup = 0 ] && ok || fail fi _RUN_QUOTACHECK=0 # Check filesystems if [ -z "$fastboot" ] && [ -z "$nofsck" ]; then rc_splash "fsck start" show "Checking filesystems"; started initlog -c "fsck -C -T -R -A -a -P $fsckoptions" rc=$? # A return of 2 or higher means there were serious problems if [ $rc -gt 1 ]; then [ -e /proc/splash ] && echo "verbose" > /proc/splash PS1="$(nls '(Repair filesystem)# ')"; export PS1 repair_shell "$(nls '*** An error occurred during the file system check.')" elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then _RUN_QUOTACHECK=1 fi rc_splash "fsck stop" fi # Mount all other filesystems (except for NFS and /proc, which is already # mounted). Contrary to standard usage, # filesystems are NOT unmounted in single user mode. run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev # now we have /usr mounted, recheck if we have gettext and tput available. if is_no "$TPUT"; then GETTEXT= TPUT= rc_gettext_init fi # Now do some workaround - encrypted filesystems couldn't have been fsck-ed # before mount - that's where the password is entered. # mount is buggy - when remounting loopback filesystem, loop=XXX # option is removed from /etc/mtab if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then show "Checking encrypted filesystems"; started LOOPLIST="$(LC_ALL=C awk ' FILENAME=="/proc/mounts" { TAB[$2]=$1; } FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ { if ($2 in TAB){print TAB[$2];} } FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { if ($2 in TAB){print TAB[$2];} sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4); cmd="mount " $2 " -o remount," $4; system(cmd); } ' /proc/mounts /etc/fstab)" initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST" rc=$? # A return of 2 or higher means there were serious problems. if [ $rc -gt 1 ]; then [ -e /proc/splash ] && echo "verbose" > /proc/splash PS1="$(nls '(Repair filesystem)# ')"; export PS1 repair_shell "$(nls '*** An error occurred during the file system check.')" elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then _RUN_QUOTACHECK=1 fi show "Remounting encrypted filesystems back in rw mode"; busy LC_ALL=C awk ' FILENAME=="/proc/mounts" { TAB[$2]=$1; } FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ { sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4); cmd="mount " $2 " -o remount," $4; system(cmd); } ' /proc/mounts /etc/fstab ok fi # /var/log should be writable now, so start saving the boot output if [ "$RC_BOOTLOG" ]; then echo > /var/log/boot.log killall -IO blogd fi if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa fi # Turn on quota if [ -x /sbin/quotaon ]; then run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug fi # Turn on process accounting if [ -x /etc/rc.d/rc.acct ]; then /etc/rc.d/rc.acct start fi # Set the clock if timezone definition wasn't available (eg. /usr not mounted) if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok fi fi # Initialize the serial ports if [ -f /etc/rc.d/rc.serial ]; then . /etc/rc.d/rc.serial fi if [ -n "$PANIC_REBOOT_TIME" ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] && [ -f /proc/sys/kernel/panic ]; then show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy # DEPRECATED: use /etc/sysctl.conf or kernel commandline instead if sysctl -q -w kernel.panic=$PANIC_REBOOT_TIME; then ok; else fail; fi fi # ... and here finish configuring parameters apply_sysctl else # /var/log should be writable now, so start saving the boot output if [ "$RC_BOOTLOG" ]; then echo > /var/log/boot.log killall -IO blogd fi clean_vserver_mtab fi is_yes "$SELINUX" && [ -f /.autorelabel ] && relabel_selinux # Clean up /. rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1 # Clean up /var # /usr could be still not mounted if it is on NFS. for afile in /var/lock/* /var/run/*; do bafile=${afile##*/} if [ -d "$afile" ]; then case $bafile in news|sudo|mon|cvs) ;; *) echo $afile/* | xargs rm -rf ;; esac else [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null fi done # Delete stale files rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \ /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ /tmp/scrollkeeper-* /tmp/ssh-* { # Clean up utmp/wtmp rm -f /var/run/utmpx > /var/run/utmp if [ -e /var/log/wtmpx ]; then if [ -e /var/log/wtmp ]; then rm -f /var/log/wtmpx else mv /var/log/wtmpx /var/log/wtmp fi fi touch /var/log/wtmp chown root:utmp /var/run/utmp /var/log/wtmp chmod 0664 /var/run/utmp /var/log/wtmp # Clean /tmp if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]* fi # System protected dirs mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1 chown root:root /tmp/.ICE-unix is_yes "$SELINUX" && restorecon /tmp/.ICE-unix >/dev/null 2>&1 test -d /var/run/netreport || mkdir -m 770 /var/run/netreport if ! is_yes "$VSERVER"; then enable_swap # If a SCSI tape has been detected, load the st module unconditionally # since many SCSI tapes don't deal well with st being loaded and unloaded if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then if grep -qv ' 9 st' /proc/devices 2>/dev/null; then if [ -n "$USEMODULES" ] ; then # Try to load the module. If it fails, ignore it... insmod -p st >/dev/null 2>&1 && modprobe -s st fi fi fi # Now that we have all of our basic modules loaded and the kernel going, # let's dump the syslog ring somewhere so we can find it later mode=0600 if [ "$(cat /proc/sys/kernel/dmesg_restrict)" = 0 ]; then mode=0644 fi dmesg --raw > /var/log/dmesg chmod $mode /var/log/dmesg i=5 while [ $i -ge 0 ]; do if [ -f /var/log/dmesg.$i ]; then mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1)) fi i=$(($i-1)) done cp -pf /var/log/dmesg /var/log/dmesg.0 fi if ! is_no "$RC_PROMPT"; then while :; do pid=$(/sbin/pidof getkey) [ -n "$pid" -o -e /var/run/getkey_done ] && break usleep 100000 done [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1 fi } & # /proc extra check if the background process we just spawned is still running, # as in case of vserver bootup it finishes quite instantly. if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then /sbin/getkey i && touch /var/run/confirm touch /var/run/getkey_done fi wait if ! is_no "$RC_PROMPT"; then rm -f /var/run/getkey_done fi echo