diff options
Diffstat (limited to 'rc.d/init.d')
-rw-r--r-- | rc.d/init.d/functions | 414 | ||||
-rwxr-xr-x | rc.d/init.d/halt | 285 | ||||
-rwxr-xr-x | rc.d/init.d/killall | 35 | ||||
-rw-r--r-- | rc.d/init.d/netconsole | 2 | ||||
-rwxr-xr-x | rc.d/init.d/netfs | 192 | ||||
-rwxr-xr-x | rc.d/init.d/network | 37 | ||||
-rwxr-xr-x | rc.d/init.d/single | 40 |
7 files changed, 44 insertions, 961 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 48fa2c01..33f9eb20 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -61,7 +61,14 @@ systemctl_redirect () { } -[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype <&2)" +if [ -z "${CONSOLETYPE:-}" ]; then + if [ -c "/dev/stderr" -a -r "/dev/stderr" ]; then + CONSOLETYPE="$(/sbin/consoletype < /dev/stderr 2>/dev/null)" + else + CONSOLETYPE="serial" + fi +fi + # Get a sane screen width, and default to 80 when exact info not available [ -z "${COLUMNS:-}" ] && COLUMNS=`stty -a 2>/dev/null | sed -n 's/.*columns \([0-9]*\);.*/\1/p'` [ -z "${COLUMNS:-}" ] && COLUMNS=80 @@ -176,11 +183,6 @@ inmyroot() { } -# Interpret escape sequences in an fstab entry -fstab_decode_str() { - fstab-decode echo "$1" -} - # Check if any of $pid (could be plural) are running checkpid() { local i @@ -191,82 +193,6 @@ checkpid() { return 1 } -__readlink() { - ls -bl "$@" 2>/dev/null| awk '{ print $NF }' -} - -__fgrep() { - s=$1 - f=$2 - while read line; do - if strstr "$line" "$s"; then - echo $line - return 0 - fi - done < $f - return 1 -} - -# __umount_loop awk_program fstab_file first_msg retry_msg retry_umount_args -# awk_program should process fstab_file and return a list of fstab-encoded -# paths; it doesn't have to handle comments in fstab_file. -__umount_loop() { - local remaining sig=-15 - local retry=3 count - - remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r) - while [ -n "$remaining" -a "$retry" -gt 0 ]; do - if [ "$retry" -eq 3 ]; then - action "$3" fstab-decode umount $remaining - else - action "$4" fstab-decode umount $5 $remaining - fi - count=4 - remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r) - while [ "$count" -gt 0 ]; do - [ -z "$remaining" ] && break - count=$(($count-1)) - usleep 500000 - remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r) - done - [ -z "$remaining" ] && break - fstab-decode /sbin/fuser -k -m $sig $remaining >/dev/null - sleep 3 - retry=$(($retry -1)) - sig=-9 - done -} - -# Similar to __umount loop above, specialized for loopback devices -__umount_loopback_loop() { - local remaining devremaining sig=-15 - local retry=3 - - remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" && $2 !~ /^\/live\// {print $2}' /proc/mounts) - devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" && $2 !~ /^\/live\// {print $1}' /proc/mounts) - while [ -n "$remaining" -a "$retry" -gt 0 ]; do - if [ "$retry" -eq 3 ]; then - action "Unmounting loopback filesystems: " \ - fstab-decode umount $remaining - else - action "Unmounting loopback filesystems (retry):" \ - fstab-decode umount $remaining - fi - for dev in $devremaining ; do - losetup $dev > /dev/null 2>&1 && \ - action "Detaching loopback device %s: " $dev \ - losetup -d $dev - done - remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" && $2 !~ /^\/live\// {print $2}' /proc/mounts) - devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" && $2 !~ /^\/live\// {print $1}' /proc/mounts) - [ -z "$remaining" ] && break - fstab-decode /sbin/fuser -k -m $sig $remaining >/dev/null - sleep 3 - retry=$(($retry -1)) - sig=-9 - done -} - # __proc_pids {program} [pidfile] # Set $pid to pids from /var/run* for {program}. $pid should be declared # local in the caller. @@ -398,7 +324,7 @@ daemon() { killproc() { local RC killlevel= base pid pid_file= delay try - RC=0; delay=3 + RC=0; delay=3; try=0 # Test syntax. if [ "$#" -eq 0 ]; then gprintf "Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" @@ -409,7 +335,11 @@ killproc() { shift 2 fi if [ "$1" = "-d" ]; then - delay=$2 + delay=$(echo $2 | awk -v RS=' ' -v IGNORECASE=1 '{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} END {printf("%d",delay+0.5)}') + if [ "$?" -eq 1 ]; then + echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" + return 1 + fi shift 2 fi @@ -697,121 +627,6 @@ strstr() { return 0 } - -# Confirm whether we really want to run this service -confirm() { - gprintf "Start service %s (Y)es/(N)o/(C)ontinue? [Y] \n" $1 - local YES=`gprintf "yY"` - local NOT=`gprintf "nN"` - local CNT=`gprintf "cC"` - read answer - - if strstr "$YES" "$answer" || [ "$answer" = "" ] ; then - return 0 - elif strstr "$CNT" "$answer" ; then - return 2 - elif strstr "$NOT" "$answer" ; then - return 1 - fi - confirm $* -} - -initsplash() { - [[ -f /etc/sysconfig/bootsplash ]] && source /etc/sysconfig/bootsplash - [[ -n $SPLASH ]] && splash_rc=$SPLASH - [[ -x /sbin/plymouthd ]] || splash_rc=no - if [ -x /sbin/plymouthd ]; then - splash_mode=plymouth - if [ -r /proc/cmdline ] && grep -q splash /proc/cmdline && [ "$splash_rc" != "no" ]; then - splash_rc=yes - else - splash_rc=no - /bin/plymouth quit 2>/dev/null - PLYMOUTH= - fi - else - splash_rc=no - fi - - [[ $splash_rc != "no" && $splash_rc != "No" && $splash_rc != "NO" ]] && export splash_rc=yes - [[ $splash_mode = "plymouth" ]] || splash_rc= - if [[ -z "$1" ]]; then - set `/sbin/runlevel` - __runlevel=$2 - __previous=$1 - else - __runlevel=$1 - __previous=N - fi - [ "$splash_mode" = "plymouth" -a "$splash_rc" = "yes" -a -e /sys/class/graphics/fb0 ] && [ "$__runlevel" = 0 -o "$__runlevel" = 6 ] && /sbin/plymouthd --mode=shutdown - export splash_mode splash_rc -} - -rc_splash() { - [[ "$splash_rc" = "yes" ]] || return - if [ "$splash_mode" = "plymouth" ]; then - if [ "$1" = "start" ]; then - /bin/plymouth --show-splash 2>/dev/null - if [ "$2" = "1" ]; then - /bin/plymouth message --text="`OUTPUT_CHARSET=UTF-8 gprintf 'Booting the system... Press Esc for verbose mode.'`" 2> /dev/null - elif [ "$2" = "0" ]; then - /bin/plymouth message --text="`OUTPUT_CHARSET=UTF-8 gprintf 'Shutting down the system... Press Esc for verbose mode.'`" 2> /dev/null - else - /bin/plymouth message --text="`OUTPUT_CHARSET=UTF-8 gprintf 'Restarting the system... Press Esc for verbose mode.'`" 2> /dev/null - fi - elif [ "$1" = "stop" -o "$1" = "exit" ]; then - /bin/plymouth quit 2>/dev/null - elif [ "$1" = "umount" ]; then - /bin/plymouth quit --retain-splash 2>/dev/null - elif [ "$1" = "verbose" ]; then - /bin/plymouth --hide-splash 2>/dev/null - else - /bin/plymouth --update "$1" 2>/dev/null - fi - fi -} - -# -# This function finds the encoding of the current locale (it can -# be overwritten by a "CHARSET" variable if needed); the call -# to "locale charmap" should return the proper value; in case it -# fails, a guess from the locale name is done. -# this function is also defined in setsysfont script -# if you change it here change it there too, to have the same behaviour -# -get_locale_encoding() { - CHARSET=${CHARSET=`LC_ALL=$GP_LANG locale charmap 2> /dev/null`} - case "$CHARSET" in - ANSI_X3.4-1968) - # this means that the locale has not been - # correctly initialized; we will look at the - # locale naming and use the known - # default values for various languages - case "${LC_ALL}${LC_CTYPE}${LANG}" in - # the locale tells it is in UTF-8, or it is a language - # we know must be in UTF-8 by default - *.utf8*|*.UTF-8*| \ - am*|an*|ar*|as*|az*|bn*|cy*|eo*|fa*|gn*|gu*|he*|hi*|hy*| \ - id*|ka*|kn*|ku*|ky*|lo*|m*|ne*|om*|pa*|ph*|se*|sr*|st*| \ - ta*|te*|tg*|ti*|tk*|tl*|tt*|ug*|ur*|uz*|vi*|xh*|y*) - CHARSET="UTF-8" ;; - esac - ;; - esac - echo "$CHARSET" -} - -# resolve a device node to its major:minor numbers in decimal or hex -get_numeric_dev() { -( - fmt="%d:%d" - if [ "$1" = "hex" ]; then - fmt="%x:%x" - fi - ls -lH "$2" | awk '{ sub(/,/, "", $5); printf("'"$fmt"'", $5, $6); }' -) 2>/dev/null -} - # Check whether file $1 is a backup or rpm-generated file and should be ignored is_ignored_file() { case "$1" in @@ -844,187 +659,26 @@ is_false() { # Apply sysctl settings, including files in /etc/sysctl.d apply_sysctl() { - sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1 - for file in /etc/sysctl.d/* ; do - is_ignored_file "$file" && continue - test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1 - done -} - -key_is_random() { - [ "$1" = "/dev/urandom" -o "$1" = "/dev/hw_random" \ - -o "$1" = "/dev/random" ] -} - -find_crypto_mount_point() { - local fs_spec fs_file fs_vfstype remaining_fields - local fs - while read fs_spec fs_file remaining_fields; do - if [ "$fs_spec" = "/dev/mapper/$1" ]; then - echo $fs_file - break; - fi - done < /etc/fstab -} - -# Because of a chicken/egg problem, init_crypto must be run twice. /var may be -# encrypted but /var/lib/random-seed is needed to initialize swap. -init_crypto() { - local have_random dst src key opt lsl owner params makeswap skip arg opt - local param value rc ret mke2fs mdir prompt mount_point - - ret=0 - have_random=$1 - while read dst src key opt; do - [ -z "$dst" -o "${dst#\#}" != "$dst" ] && continue - [ -b "/dev/mapper/$dst" ] && continue; - if [ "$have_random" = 0 ] && key_is_random "$key"; then - continue - fi - if [ -n "$key" -a "x$key" != "xnone" ]; then - if test -e "$key" ; then - owner=$(ls -l $key | (read a b owner rest; echo $owner)) - if ! key_is_random "$key"; then - lsl=$(ls -l "$key") - if [ "${lsl:4:6}" != "------" ]; then - gprintf "INSECURE MODE FOR %s\n" $key - fi - fi - if [ "$owner" != root ]; then - gprintf "INSECURE OWNER FOR %s\n" $key - fi - else - gprintf "Key file for %s not found, skipping\n" $dst - ret=1 - continue - fi - else - key="" - fi - params="" - makeswap="" - mke2fs="" - skip="" - # Parse the src field for UUID= and convert to real device names - if [ "${src%%=*}" == "UUID" ]; then - src=$(/sbin/blkid -t "$src" -l -o device) - elif [ "${src/^\/dev\/disk\/by-uuid\/}" != "$src" ]; then - src=$(__readlink $src) - fi - # Is it a block device? - [ -b "$src" ] || continue - # Is it already a device mapper slave? (this is gross) - devesc=${src##/dev/} - devesc=${devesc//\//!} - for d in /sys/block/dm-*/slaves ; do - [ -e $d/$devesc ] && continue 2 - done - # Parse the options field, convert to cryptsetup parameters and - # contruct the command line - while [ -n "$opt" ]; do - arg=${opt%%,*} - opt=${opt##$arg} - opt=${opt##,} - param=${arg%%=*} - value=${arg##$param=} - - case "$param" in - cipher) - params="$params -c $value" - if [ -z "$value" ]; then - gprintf "%s: no value for cipher option, skipping\n" $dst - skip="yes" - fi - ;; - size) - params="$params -s $value" - if [ -z "$value" ]; then - gprintf "%s: no value for size option, skipping\n" $dst - skip="yes" - fi - ;; - hash) - params="$params -h $value" - if [ -z "$value" ]; then - gprintf "%s: no value for hash option, skipping\n" $dst - skip="yes" - fi - ;; - noauto) - skip="yes" - ;; - verify) - params="$params -y" - ;; - swap) - makeswap=yes - ;; - tmp) - mke2fs=yes - esac - done - if [ "$skip" = "yes" ]; then - ret=1 - continue - fi - if [ -z "$makeswap" ] && cryptsetup isLuks "$src" 2>/dev/null ; then - if key_is_random "$key"; then - gprintf "%s: LUKS requires non-random key, skipping\n" $dst - ret=1 - continue - fi - if [ -n "$params" ]; then - echo "$dst: options are invalid for LUKS partitions," \ - "ignoring them" - fi - if [ -n "$key" ]; then - /sbin/cryptsetup -d $key luksOpen "$src" "$dst" <&1 2>/dev/null && success || failure - rc=$? - else - mount_point="$(find_crypto_mount_point $dst)" - [ -n "$mount_point" ] || mount_point=${src##*/} - prompt=$(printf $"%s is password protected" "$mount_point") - if [ "$splash_rc" = yes ] && [ -d /usr/share/plymouth ]; then - plymouth ask-for-password --prompt "$prompt" --command="/sbin/cryptsetup luksOpen -T1 $src $dst" --number-of-tries=3 <&1 - rc=$? - else - # stop splash to ask for password - rc_splash verbose - /sbin/cryptsetup luksOpen "$src" "$dst" <&1 && success || failure - rc=$? - fi - fi - else - if [ -z "$key" ]; then - mount_point="$(find_crypto_mount_point $dst)" - [ -n "$mount_point" ] || mount_point=${src##*/} - prompt=$(printf $"%s is password protected" "$mount_point") - plymouth ask-for-password --prompt "$prompt" --command="/sbin/cryptsetup $params create $dst $src" <&1 - rc=$? - else - /sbin/cryptsetup $params ${key:+-d $key} create "$dst" "$src" <&1 2>/dev/null && success || failure - rc=$? - fi - fi - if [ $rc -ne 0 ]; then - ret=1 - continue - fi - if [ -b "/dev/mapper/$dst" ]; then - if [ "$makeswap" = "yes" ]; then - mkswap "/dev/mapper/$dst" 2>/dev/null >/dev/null - fi - if [ "$mke2fs" = "yes" ]; then - if mke2fs "/dev/mapper/$dst" 2>/dev/null >/dev/null \ - && mdir=$(mktemp -d /tmp/mountXXXXXX); then - mount "/dev/mapper/$dst" "$mdir" && chmod 1777 "$mdir" - umount "$mdir" - rmdir "$mdir" - fi - fi - fi - done < /etc/crypttab - return $ret + if [ -x /lib/systemd/systemd-sysctl ]; then + /lib/systemd/systemd-sysctl + else + for file in /usr/lib/sysctl.d/*.conf ; do + is_ignored_file "$file" && continue + [ -f /run/sysctl.d/${file##*/} ] && continue + [ -f /etc/sysctl.d/${file##*/} ] && continue + test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1 + done + for file in /run/sysctl.d/*.conf ; do + is_ignored_file "$file" && continue + [ -f /etc/sysctl.d/${file##*/} ] && continue + test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1 + done + for file in /etc/sysctl.d/*.conf ; do + is_ignored_file "$file" && continue + test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1 + done + sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1 + fi } # A sed expression to filter out the files that is_ignored_file recognizes diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt deleted file mode 100755 index 80deb629..00000000 --- a/rc.d/init.d/halt +++ /dev/null @@ -1,285 +0,0 @@ -#!/bin/bash -# -# halt This file is executed by init when it goes into runlevel -# 0 (halt) or runlevel 6 (reboot). It kills all processes, -# unmounts file systems and then either halts or reboots. -# -# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> -# Modified for RHS Linux by Damien Neil -# - -NOLOCALE=1 -. /etc/init.d/functions - -UMOUNT="umount" -[ ! -w /etc ] && UMOUNT="umount -n" - -halt_crypto() { - fnval=0 - while read dst src key; do - [ -z "$dst" -o "${dst#\#}" != "$dst" ] && continue - if [ -b "/dev/mapper/$dst" ]; then - if /sbin/dmsetup info "$dst" | grep -q '^Open count: *0$'; then - action "Stopping disk encryption for %s" $dst /sbin/cryptsetup remove "$dst" - else - fnval=1 - fi - fi - done < /etc/crypttab - return $fnval -} - -kill_all() { - /sbin/killall5 "$@" - rc=$? - if [ "$rc" == 1 ]; then - return 1 - fi - return 0 -} - -# See how we were called. -case "$0" in - *halt) - message=`gprintf "Halting system..."` - command="/sbin/halt" - ;; - *reboot) - message=`gprintf "Please stand by while rebooting the system..."` - command="/sbin/reboot" - kexec_command="/sbin/kexec" - ;; - *) - gprintf "%s: call me as 'halt' or 'reboot' please!\n" $0 - exit 1 - ;; -esac -case "$1" in - *start) - ;; - *) - gprintf "Usage: %s\n" "$(basename $0) {start}" - exit 1 - ;; -esac - -# Recreate the /initrd if needed -if [ ! -d /initrd ]; then - action "Creating initrd directory" mkdir /initrd -fi -if [ -d /initrd -a ! -f /initrd/README.WARNING ]; then - cat > /initrd/README.WARNING <<EOF -(mkinitrd) Don't remove this directory, it's needed at boot time, -in the initrd, to perform the pivot_root. -EOF -fi - -update_boot_stage kill - -# Kill all processes. -[ "${BASH+bash}" = bash ] && enable kill - -OMITPIDS= -omitfile=/var/run/sendsigs.omit -if [ -e $omitfile ]; then - for pid in $(cat $omitfile); do - OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid" - done -fi -# Find mdmon pid's and omit killing them -OMITARGS= -for i in /dev/.mdadm/*.pid; do - if [ "$i" = "mdadm.pid" -o ! -r "$i" ]; then - continue - fi - OMITARGS="$OMITARGS -o $(cat $i)" -done - - -action "Sending all processes the TERM signal..." kill_all -15 $OMITPIDS $OMITARGS -alldead="" -for i in 0 1 2 3 4 5 6 7 8 9 10; do - # use SIGCONT/signal 18 to check if there are - # processes left. No need to check the exit code - # value, because either killall5 work and it make - # sense to wait for processes to die, or it fail and - # there is nothing to wait for. - if /sbin/killall5 -18 $OMITPIDS $OMITARGS; then - : - else - alldead=1 - break - fi - - sleep 1 -done -# No need to sleep and kill -9 if no processes to kill were found -if [ -z "$alldead" ]; then - action "Sending all processes the KILL signal..." kill_all -9 $OMITPIDS $OMITARGS -fi - -# Write to wtmp file before unmounting /var -/sbin/halt -w - -# Save mixer settings, here for lack of a better place. -if [ -x /sbin/alsactl ]; then - action "Saving mixer settings" /sbin/alsactl --ignore store -fi - -# Save random seed -touch /var/lib/random-seed -chmod 600 /var/lib/random-seed -action "Saving random seed: " dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null - -update_boot_stage clock -[ -x /sbin/hwclock ] && action "Syncing hardware clock to system time" /sbin/hwclock --systohc - -if [ -x /sbin/halt.pre ]; then - /sbin/halt.pre -fi - -update_boot_stage umount - -# Try to unmount tmpfs filesystems to avoid swapping them in. Ignore failures. -tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; } - $3 == "tmpfs" { print $2; }' /proc/mounts | sort -r) -[ -n "$tmpfs" ] && fstab-decode $UMOUNT $tmpfs 2>/dev/null - -# Turn off swap, then unmount file systems. -[ -f /proc/swaps ] && SWAPS=$(awk '! /^Filename/ { print $1 }' /proc/swaps) -if [ -n "$SWAPS" ]; then - action "Turning off swap: " swapoff $SWAPS - for dst in $SWAPS; do - if [[ "$dst" == /dev/mapper* ]] \ - && [ "$(dmsetup status "$dst" | cut -d ' ' -f 3)" = crypt ]; then - backdev=$(/sbin/cryptsetup status "$dst" \ - | awk '$1 == "device:" { print $2 }') - /sbin/cryptsetup remove "$dst" - fi - done -fi - -[ -x /sbin/quotaoff ] && action "Turning off quotas: " /sbin/quotaoff -aug - -# Only adjust mtab if it's not a symbolic link -if [ ! -L /etc/mtab ]; then - # first remove entry /initrd/loopfs as it can't be unmounted :( - mtab=$(fgrep -v "/initrd/loopfs[^/]" /etc/mtab) - (IFS= ; echo $mtab > /etc/mtab) -fi - -# Unmount file systems, killing processes if we have to. -# Unmount loopback stuff first -__umount_loopback_loop - -# Unmount RPC pipe file systems -__umount_loop '$3 ~ /^rpc_pipefs$/ || $3 ~ /^rpc_svc_gss_pipefs$/ {print $2}' \ - /proc/mounts \ - "Unmounting pipe file systems: " \ - "Unmounting pipe file systems (retry): " \ - -f - -LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/cgroup|^\/sys\/fs\/cgroup|^\/dev/{next} - $2 ~ /^\/live\//{next} - $3 == "tmpfs" || $3 == "proc" {print $2 ; next} - $3 ~ /(loopfs|autofs|nfs|cifs|smbfs|ncpfs|sysfs)/ {next} - /(^none|^\/dev\/ram|^\/dev\/root$)/ {next} - {print $2}' /proc/mounts \ - "Unmounting file systems: " \ - "Unmounting file systems (retry): " \ - -f - - -update_boot_stage lvm - -# stop crypto devices before lvm, as they can sit on top of LVM -[ -f /etc/crypttab ] && halt_crypto - -if [ -f /etc/lvm/lvm.conf -a -x /sbin/lvm2 ]; then - if grep -q -s 'device-mapper' /proc/devices; then - _vgchange_cmd="/sbin/lvm2 vgchange -a n" - fi -fi - -if [ -z "${_vgscan_cmd}" -a -f /etc/lvmtab -a -e /proc/lvm ] ; then - if [ -x /sbin/lvm1-vgchange ]; then - _vgchange_cmd="/sbin/lvm1-vgchange -a n" - elif [ -x /sbin/vgchange ]; then - _vgchange_cmd="/sbin/vgchange -a n" - fi -fi - -if [ -n "${_vgchange_cmd}" ]; then - action "Shutting down LVM:" ${_vgchange_cmd} -fi - -# for NUT -# do it here to have /proc/usb mounted for UPS on USB -if [ -f /etc/init.d/upsd ]; then - /etc/init.d/upsd powerdown - [ $? == 3 ] && exit 1 -fi - -[ -f /proc/bus/usb/devices ] && $UMOUNT /proc/bus/usb - -# remove the crash indicator flag -rm -f /.autofsck - -update_boot_stage umount_force - -# Try all file systems other than root, essential filesystems and RAM disks, -# one last time. -# eugeni: we should umount the filesystems in reverse order (#53042) -tac /proc/mounts | awk '$2 !~ /\/(|dev|proc|selinux|cgroup|sys)$/ && $2 !~ /^\/live\// && $1 !~ /(^\/dev\/ram|cgroup)/ { print $2 }' | \ - while read line; do - fstab-decode $UMOUNT -f $line -done - -if [ -x /sbin/halt.local ]; then - /sbin/halt.local -fi - -update_boot_stage remount_ro - -# Remount read only anything that's left mounted. -# echo $"Remounting remaining filesystems readonly" -mount | awk '{ print $1,$3 }' | while read dev dir; do - fstab-decode mount -n -o ro,remount $dev $dir -done - -# (bor) it is impossible under systemd and is not required otherwise -# action "Unmounting proc file system: " umount /proc - -# See if this is a powerfail situation. -if [ -f /etc/apcupsd/powerfail ]; then - gprintf "APCUPSD will now power off the UPS!\n" - echo - /etc/apcupsd/apccontrol killpower - echo - gprintf "Please ensure that the UPS has powered off before rebooting\n" - gprintf "Otherwise, the UPS may cut the power during the reboot!!!\n" - echo -fi - -update_boot_stage halt - -# If we left mdmon's running wait for the raidsets to become clean -if [ -n "$OMITARGS" ]; then - mdadm --wait-clean --scan -fi - -# Now halt or reboot. -echo "$message" -if [ -f /fastboot ]; then - gprintf "On the next boot fsck will be skipped.\n" -elif [ -f /forcefsck ]; then - gprintf "On the next boot fsck will be forced.\n" -fi - -# First, try kexec. If that fails, fall back to rebooting the old way. -[ -n "$kexec_command" ] && $kexec_command -e -x >& /dev/null - -HALTARGS="-i -d" -[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p" - -exec $command $HALTARGS diff --git a/rc.d/init.d/killall b/rc.d/init.d/killall deleted file mode 100755 index 574f4f6f..00000000 --- a/rc.d/init.d/killall +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/bash - -# Bring down all unneeded services that are still running (there shouldn't -# be any, so this is just a sanity check) - -case "$1" in - *start) - ;; - *) - gprintf "Usage: %s {start}\n" $0 - exit 1 - ;; -esac - - -for i in /var/lock/subsys/* ; do - # Check if the script is there. - [ -f "$i" ] || continue - - # Get the subsystem name. - subsys=${i#/var/lock/subsys/} - - # Networking could be needed for NFS root. - [ $subsys = network ] && continue - - # Bring the subsystem down. - if [ -f /etc/init.d/$subsys ]; then - /etc/init.d/$subsys stop - elif [ -f /etc/init.d/$subsys.init ]; then - /etc/init.d/$subsys.init stop - else - rm -f "$i" - fi -done -exit 0 diff --git a/rc.d/init.d/netconsole b/rc.d/init.d/netconsole index 14f96d76..63e23897 100644 --- a/rc.d/init.d/netconsole +++ b/rc.d/init.d/netconsole @@ -63,7 +63,7 @@ print_address_info () target=$host fi if [ -z "$SYSLOGMACADDR" ]; then - arp=$(LANG=C /sbin/arping -c 1 -I $DEV $target 2>/dev/null | awk '/ reply from .*[.*]/ { print gensub(".* reply from .* \\[(.*)\\].*","\\1","G"); exit }') + arp=$(LANG=C /sbin/arping -f -c 1 -I $DEV $target 2>/dev/null | awk '/ reply from .*[.*]/ { print gensub(".* reply from .* \\[(.*)\\].*","\\1","G"); exit }') [ -n "$arp" ] && echo "SYSLOGMACADDR=$arp" fi } diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs deleted file mode 100755 index 2a37ce76..00000000 --- a/rc.d/init.d/netfs +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/bash -# -# netfs Mount network filesystems. -# -# Authors: Bill Nottingham <notting@redhat.com> -# AJ Lewis <alewis@redhat.com> -# Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> -# -# chkconfig: 345 25 75 -# description: Mounts and unmounts all Network File System (NFS), \ -# CIFS (Lan Manager/Windows), and NCP (NetWare) mount points. -# -### BEGIN INIT INFO -# Provides: $remote_fs -# Required-Start: $network -# Should-Start: $portmap nfs-common -# Required-Stop: $network -# Should-Stop: $portmap nfs-common -# Default-Start: 3 4 5 -# Short-Description: Mount network filesystems. -# Description: Mounts and unmounts all Network File System (NFS), -# SMB/CIFS (Lan Manager/Windows), and NCP (NetWare) mount points. -### END INIT INFO - -[ -f /etc/sysconfig/network ] || exit 0 -. /etc/init.d/functions -. /etc/sysconfig/network - -NFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab) -CIFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "cifs" && $4 !~ /noauto/ { print $2 }' /etc/fstab) -NCPFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "ncpfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab) -NETDEVFSTAB=$(LC_ALL=C awk '!/^#/ && $4 ~/_netdev/ && $4 !~ /noauto/ { print $1 }' /etc/fstab) - -NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts) -CIFSMTAB=$(LC_ALL=C awk '$3 == "cifs" { print $2 }' /proc/mounts | tac) -NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts | tac) -NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab) - -# See how we were called. -case "$1" in - start) - [ ! -f /var/lock/subsys/network ] && ! nm-online -x >/dev/null 2>&1 && exit 0 - [ "$EUID" != "0" ] && exit 4 - [ -n "$NFSFSTAB" ] && - { - action "Mounting NFS filesystems: " mount -a -t nfs,nfs4 - } - [ -n "$CIFSFSTAB" ] && action "Mounting CIFS filesystems: " mount -a -t cifs - [ -n "$NCPFSTAB" ] && action "Mounting NCP filesystems: " mount -a -t ncpfs - [ -n "$NETDEVFSTAB" ] && - { - if [ -f /etc/mdadm.conf ] && [ -x /sbin/mdadm ]; then - /sbin/mdadm -A -s - fi - if [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then - modprobe dm-multipath >/dev/null 2>&1 - /sbin/multipath -u -v 0 - if [ -x /sbin/kpartx ]; then - /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -u -a -p p" - fi - fi - if [ -x /sbin/lvm ]; then - if /sbin/lvm vgscan > /dev/null 2>&1 ; then - action "Setting up Logical Volume Management:" /sbin/lvm vgchange -a y - fi - fi - - if [ -f /etc/crypttab ]; then - init_crypto 1 - fi - - STRING=`gprintf "Checking network-attached filesystems"` - - echo $STRING - fsck -A -T -R -a -t opts=_netdev - rc=$? - - if [ "$rc" -eq "0" ]; then - success "$STRING" - echo - elif [ "$rc" -eq "1" ]; then - passed "$STRING" - echo - fi - - if [ "$rc" -gt 1 ]; then - if [ -x /bin/plymouth ] && /bin/plymouth --ping ; then - /bin/plymouth --hide-splash - fi - failure "$STRING" - tty >/dev/null 2>&1 || exit 1 - echo - echo - gprintf "*** An error occurred during the file system check.\n" - gprintf "*** Dropping you to a shell; the system will reboot\n" - gprintf "*** when you leave the shell.\n" - - str=`gprintf "(Repair filesystem)"` - PS1="$str \# # "; export PS1 - [ "$SELINUX" = "1" ] && disable_selinux - sulogin - - shutdown -r now - fi - } - touch /var/lock/subsys/netfs - # The 'no' applies to all listed filesystem types. See mount(8). - action $"Mounting other filesystems: " mount -a -t nonfs,nfs4,cifs,ncpfs,gfs2 -O noencrypted - ;; - stop) - # Unmount loopback stuff first - [ "$EUID" != "0" ] && exit 4 - __umount_loopback_loop - if [ -n "$NETDEVMTAB" ]; then - __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \ - /etc/mtab \ - "Unmounting network block filesystems: " \ - "Unmounting network block filesystems (retry): " - fi - if [ -n "$NFSMTAB" ]; then - __umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \ - /proc/mounts \ - "Unmounting NFS filesystems: " \ - "Unmounting NFS filesystems (retry): " \ - "-f -l" - fi - if [ -n "$CIFSMTAB" ]; then - for MNT in $CIFSMTAB; do - action $"Unmounting CIFS filesystem: $MNT" umount "$MNT" - done - fi - if [ -n "$NCPMTAB" ]; then - for MNT in $NCPMTAB; do - action $"Unmounting NCP filesystem: $MNT" umount "$MNT" - done - fi - rm -f /var/lock/subsys/netfs - ;; - status) - if [ -f /proc/mounts ] ; then - [ -n "$NFSFSTAB" ] && { - gprintf "Configured NFS mountpoints: \n" - for fs in $NFSFSTAB; do echo $fs ; done - } - [ -n "$CIFSFSTAB" ] && { - gprintf "Configured CIFS mountpoints: \n" - for fs in $CIFSFSTAB; do echo $fs ; done - } - [ -n "$NCPFSTAB" ] && { - gprintf "Configured NCP mountpoints: \n" - for fs in $NCPFSTAB; do echo $fs ; done - } - [ -n "$NETDEVFSTAB" ] && { - gprintf "Configured network block devices: \n" - for fs in $NETDEVFSTAB; do echo $fs ; done - } - [ -n "$NFSMTAB" ] && { - gprintf "Active NFS mountpoints: \n" - for fs in $NFSMTAB; do echo $fs ; done - } - [ -n "$CIFSMTAB" ] && { - gprintf "Active CIFS mountpoints: \n" - for fs in $CIFSMTAB; do echo $fs ; done - } - [ -n "$NCPMTAB" ] && { - gprintf "Active NCP mountpoints: \n" - for fs in $NCPMTAB; do echo $fs ; done - } - [ -n "$NETDEVMTAB" ] && { - gprintf "Active network block devices: \n" - for fs in $NETDEVMTAB; do echo $fs ; done - } - else - gprintf "/proc filesystem unavailable\n" - fi - [ -r /var/lock/subsys/netfs ] || exit 3 - ;; - restart) - $0 stop - $0 start - exit $? - ;; - reload) - $0 start - exit $? - ;; - *) - gprintf "Usage: %s\n" "$(basename $0) {start|stop|restart|reload|status}" - exit 2 -esac - -exit 0 diff --git a/rc.d/init.d/network b/rc.d/init.d/network index fbe67dd9..0da31c60 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -157,22 +157,6 @@ case "$1" in is_available $i continue fi - # If we're in confirmation mode, get user confirmation. - [ -f /var/run/confirm ] && - { - confirm $i - case $? in - 0) - : - ;; - 2) - CONFIRM= - ;; - *) - continue - ;; - esac - } action "Bringing up interface %s: " $i ./ifup $DEVICE boot [ $? -ne 0 ] && rc=1 done @@ -180,11 +164,6 @@ case "$1" in # Bring up xDSL and VPN interfaces for i in $vlaninterfaces $bridgeinterfaces $xdslinterfaces $vpninterfaces ; do if ! LANG=C grep -EL "^ONBOOT=['\"]?[Nn][Oo]['\"]?" "ifcfg-$i" >/dev/null 2>&1 ; then - # If we're in confirmation mode, get user confirmation. - if [ -f /var/run/confirm ]; then - confirm $i - test $? = 1 && continue - fi action "Bringing up interface %s: " $i ./ifup $i boot [ $? -ne 0 ] && rc=1 fi @@ -192,9 +171,13 @@ case "$1" in # Add non interface-specific static-routes. if [ -f /etc/sysconfig/static-routes ]; then - grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do - /sbin/route add -$args - done + if [ -x /sbin/route ]; then + grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do + /sbin/route add -$args + done + else + net_log $"Legacy static-route support not available: /sbin/route not found" + fi fi # IPv6 hook (post IPv4 start) @@ -220,10 +203,8 @@ case "$1" in # If this is a final shutdown/halt, check for network FS, # and unmount them even if the user didn't turn on netfs if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then - NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ { print $2 }' /proc/mounts) - SMBMTAB=$(LC_ALL=C awk '$3 == "smbfs" { print $2 }' /proc/mounts) - NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts) - if [ -n "$NFSMTAB" -o -n "$SMBMTAB" -o -n "$NCPMTAB" ] ; then + NETMOUNTS=$(findmnt -n -m -t nfs,nfs4,smbfs,ncpfs,cifs 2>/dev/null) + if [ -n "$NETMOUNTS" ] ; then /etc/init.d/netfs stop fi fi diff --git a/rc.d/init.d/single b/rc.d/init.d/single deleted file mode 100755 index 8f37963a..00000000 --- a/rc.d/init.d/single +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# -# rc.single This file is executed by init when it goes into runlevel -# 1, which is the administrative state. It kills all -# deamons and then puts the system into single user mode. -# Note that the file systems are kept mounted. -# -# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> -# Modified for RHS Linux by Damien Neil -# - -. /etc/init.d/functions - -if [ "$1" != "start" ]; then - exit 0 -fi - -# killing splashy (#46169) -update_boot_stage exit - -# Kill all processes. -[ "${BASH+bash}" = bash ] && enable kill - -gprintf "Sending all processes the TERM signal...\n" -kill -15 -1 -sleep 5 -gprintf "Sending all processes the KILL signal..\n" -kill -9 -1 - -# this looks nicer -[ -x /usr/bin/clear ] && /usr/bin/clear - -# Now go to the single user level. -gprintf "Telling INIT to go to single user mode.\n" - -# init hangs if LANG is set -unset LANG - -exec init -t1 S |