diff options
Diffstat (limited to 'rc.d/init.d')
| -rw-r--r-- | rc.d/init.d/functions | 342 | ||||
| -rwxr-xr-x | rc.d/init.d/halt | 181 | ||||
| -rwxr-xr-x | rc.d/init.d/killall | 2 | ||||
| -rw-r--r-- | rc.d/init.d/netconsole | 23 | ||||
| -rwxr-xr-x | rc.d/init.d/netfs | 60 | ||||
| -rwxr-xr-x | rc.d/init.d/network | 92 | ||||
| -rwxr-xr-x | rc.d/init.d/single | 18 |
7 files changed, 532 insertions, 186 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 1437b252..43b3abe4 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -5,6 +5,13 @@ # TEXTDOMAIN=initscripts +TEXTDOMAINDIR=/etc/locale +LOCPATH=/etc/locale +export TEXTDOMAINDIR LOCPATH + +TMP=/tmp +TMPDIR=/tmp +export TMP TMPDIR # Make sure umask is sane umask 022 @@ -50,22 +57,41 @@ systemctl_redirect () { action "$s" /bin/systemctl $options $command "$prog.service" } -# Get a sane screen width + +[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype <&2)" +# 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 -if [ -z "${CONSOLETYPE:-}" ]; then - if [ -c "/dev/stderr" ]; then - CONSOLETYPE="$(/sbin/consoletype < /dev/stderr 2>/dev/null)" - else - CONSOLETYPE="serial" - fi -fi +function load_i18_settings() { + if [ -f /etc/sysconfig/i18n -o -f /etc/locale.conf ]; then + if [ -z "$NOLOCALE" ]; then + if [ -f /etc/locale.conf ]; then + . /etc/locale.conf + else + . /etc/sysconfig/i18n + fi + if [ "$CONSOLETYPE" != "pty" ]; then + [ "$CONSOLE_NOT_LOCALIZED" = "yes" ] && GP_LANG=C + [ "$CONSOLE_NOT_LOCALIZED" = "yes" ] && GP_LANGUAGE=C + fi + if [ -z "$GP_LANG" ]; then + [ -n "$LC_CTYPE" ] && GP_LANG=$LC_CTYPE || GP_LANG=$LC_MESSAGES + fi + if [ -z "$GP_LANGUAGE" ]; then + [ -n "$LANGUAGE" ] && GP_LANGUAGE=$LANGUAGE || GP_LANGUAGE=$GP_LANG + fi + fi + fi +} -if [ -z "${NOLOCALE:-}" ] && [ -z "${LANGSH_SOURCED:-}" ] && [ -f /etc/sysconfig/i18n -o -f /etc/locale.conf ] ; then - . /etc/profile.d/lang.sh 2>/dev/null - # avoid propagating LANGSH_SOURCED any further - unset LANGSH_SOURCED -fi +function reset_i18_settings() { + local CONSOLE_NOT_LOCALIZED=yes + LC_ALL=C + load_i18_settings +} + +load_i18_settings # Read in our configuration if [ -z "${BOOTUP:-}" ]; then @@ -75,7 +101,7 @@ if [ -z "${BOOTUP:-}" ]; then # This all seem confusing? Look in /etc/sysconfig/init, # or in /usr/share/doc/initscripts-*/sysconfig.txt BOOTUP=color - RES_COL=60 + RES_COL=$((COLUMNS - 15)) MOVE_TO_COL="echo -en \\033[${RES_COL}G" SETCOLOR_SUCCESS="echo -en \\033[1;32m" SETCOLOR_FAILURE="echo -en \\033[1;31m" @@ -93,6 +119,60 @@ if [ -z "${BOOTUP:-}" ]; then fi fi +gprintf() { + if [ -x /bin/gettext -a -n "$1" ]; then + if [ -n "$GP_LANG" ]; then + local TEXT=`LC_ALL=$GP_LANG LANGUAGE=$GP_LANGUAGE gettext -e --domain=$TEXTDOMAIN -- "$1"` + else + local TEXT=`gettext -e --domain=$TEXTDOMAIN -- "$1"` + fi + else + local TEXT=$1 + fi + [ "${1#*\\n}" ] || TEXT="$TEXT\n" + + shift + printf -- "$TEXT" "$@" +} + +# Frontend to gprintf (support up to 4 %s in format string) +# returns the message transleted in GPRINTF_MSG and +# the resting parms in GPRINTF_REST +# This simplifies a lot the call of functions like action, +# now with i18n support +gprintf_msg_rest() { +case "$1" in + *%s*%s*%s*%s*) + GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4" "$5") + shift 5;; + *%s*%s*%s*) + GPRINTF_MSG=$(gprintf "$1" "$2" "$3" "$4") + shift 4;; + *%s*%s*) + GPRINTF_MSG=$(gprintf "$1" "$2" "$3") + shift 3;; + *%s*) + GPRINTF_MSG=$(gprintf "$1" "$2") + shift 2;; + *) + GPRINTF_MSG=$(gprintf "$1") + shift;; +esac +GPRINTF_REST="$@" +} + +# Check if $pid (could be plural) are running with +# the same root as this script +inmyroot() { + local i r + + for i in $* ; do + [ "/proc/$i/root" -ef "/proc/$$/root" ] && r="$r $i" + done + echo "$r" +} + + # Interpret escape sequences in an fstab entry fstab_decode_str() { fstab-decode echo "$1" @@ -159,23 +239,23 @@ __umount_loopback_loop() { local remaining devremaining sig=-15 local retry=3 - remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts) - devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts) + 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: " \ + action "Unmounting loopback filesystems: " \ fstab-decode umount $remaining else - action $"Unmounting loopback filesystems (retry):" \ + 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 $dev: " \ + action "Detaching loopback device %s: " $dev \ losetup -d $dev done - remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts) - devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts) + 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 @@ -229,7 +309,7 @@ daemon() { nicelevel=0 while [ "$1" != "${1##[-+]}" ]; do case $1 in - '') echo $"$0: Usage: daemon [+/-nicelevel] {program}" + '') gprintf "%s: Usage: daemon [+/-nicelevel] {program}\n" $0 return 1;; --check) base=$2 @@ -265,7 +345,7 @@ daemon() { nice="nice -n $1" shift ;; - *) echo $"$0: Usage: daemon [+/-nicelevel] {program}" + *) gprintf "%s: Usage: daemon [+/-nicelevel] {program}\n" $0 return 1;; esac done @@ -304,10 +384,11 @@ daemon() { if [ -z "$user" ]; then $cgroup $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*" else - $cgroup $nice runuser -s /bin/bash $user -c "$corelimit >/dev/null 2>&1 ; $*" + $cgroup $nice su -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*" fi - - [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup" + rc=$? + [ $rc = 0 ] && success "%s startup" $base || failure "%s startup" $base + return $rc } # A function to stop a program. @@ -317,7 +398,7 @@ killproc() { RC=0; delay=3 # Test syntax. if [ "$#" -eq 0 ]; then - echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" + gprintf "Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" return 1 fi if [ "$1" = "-p" ]; then @@ -347,6 +428,9 @@ killproc() { fi fi + # Avoid killing processes not running in the same root + [ -n "$pid" ] && pid="`inmyroot $pid`" + # Kill it. if [ -n "$pid" ] ; then [ "$BOOTUP" = "verbose" -a -z "${LSB:-}" ] && echo -n "$base " @@ -370,14 +454,14 @@ killproc() { fi checkpid $pid RC=$? - [ "$RC" -eq 0 ] && failure $"$base shutdown" || success $"$base shutdown" + [ "$RC" -eq 0 ] && failure "%s shutdown" $base || success "%s shutdown" $base RC=$((! $RC)) # use specified level only else if checkpid $pid; then kill $killlevel $pid >/dev/null 2>&1 RC=$? - [ "$RC" -eq 0 ] && success $"$base $killlevel" || failure $"$base $killlevel" + [ "$RC" -eq 0 ] && success "%s %s" $base $killlevel || failure "%s %s" $base $killlevel elif [ -n "${LSB:-}" ]; then RC=7 # Program is not running fi @@ -386,7 +470,7 @@ killproc() { if [ -n "${LSB:-}" -a -n "$killlevel" ]; then RC=7 # Program is not running else - failure $"$base shutdown" + failure "%s shutdown" $base RC=0 fi fi @@ -403,8 +487,8 @@ pidfileofproc() { local pid # Test syntax. - if [ "$#" = 0 ] ; then - echo $"Usage: pidfileofproc {program}" + if [ "$#" -eq 0 ] ; then + gprintf "Usage: pidfileofproc {program}\n" return 1 fi @@ -419,7 +503,7 @@ pidofproc() { # Test syntax. if [ "$#" = 0 ]; then - echo $"Usage: pidofproc [-p pidfile] {program}" + gprintf "Usage: pidofproc [-p pidfile] {program}\n" return 1 fi if [ "$1" = "-p" ]; then @@ -445,7 +529,7 @@ status() { # Test syntax. if [ "$#" = 0 ] ; then - echo $"Usage: status [-p pidfile] {program}" + gprintf "Usage: status [-p pidfile] {program}\n" return 1 fi if [ "$1" = "-p" ]; then @@ -470,21 +554,21 @@ status() { pid="$(__pids_pidof "$1")" fi if [ -n "$pid" ]; then - echo $"${base} (pid $pid) is running..." + gprintf "%s (pid %s) is running...\n" ${base} "$pid" return 0 fi case "$RC" in 0) - echo $"${base} (pid $pid) is running..." + gprintf "%s (pid %s) is running...\n" ${base} "$pid" return 0 ;; 1) - echo $"${base} dead but pid file exists" + gprintf "%s dead but pid file exists\n" ${base} return 1 ;; 4) - echo $"${base} status unknown due to insufficient privileges." + gprintf "%s status unknown due to insufficient privileges." ${base} return 4 ;; esac @@ -493,10 +577,10 @@ status() { fi # See if /var/lock/subsys/${lock_file} exists if [ -f /var/lock/subsys/${lock_file} ]; then - echo $"${base} dead but subsys locked" + gprintf "%s dead but subsys locked\n" ${base} return 2 fi - echo $"${base} is stopped" + gprintf "%s is stopped\n" ${base} return 3 } @@ -504,7 +588,7 @@ echo_success() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS - echo -n $" OK " + gprintf " OK " [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" @@ -515,7 +599,7 @@ echo_failure() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE - echo -n $"FAILED" + gprintf "FAILED" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" @@ -526,7 +610,7 @@ echo_passed() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING - echo -n $"PASSED" + gprintf "PASSED" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" @@ -537,7 +621,7 @@ echo_warning() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING - echo -n $"WARNING" + gprintf "WARNING" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" @@ -546,14 +630,15 @@ echo_warning() { # Inform the graphical boot of our current state update_boot_stage() { - if [ -x /bin/plymouth ]; then - /bin/plymouth --update="$1" - fi - return 0 + rc_splash "$1" } # Log that something succeeded success() { + gprintf_msg_rest "$@" + #if [ -z "${IN_INITLOG:-}" ]; then + # initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 1 + #fi [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success return 0 } @@ -561,14 +646,21 @@ success() { # Log that something failed failure() { local rc=$? + gprintf_msg_rest "$@" + #if [ -z "${IN_INITLOG:-}" ]; then + # initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 2 + #fi [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure - [ -x /bin/plymouth ] && /bin/plymouth --details return $rc } # Log that something passed, but may have had errors. Useful for fsck passed() { local rc=$? + gprintf_msg_rest "$@" + #if [ -z "${IN_INITLOG:-}" ]; then + # initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 1 + #fi [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_passed return $rc } @@ -576,18 +668,21 @@ passed() { # Log a warning warning() { local rc=$? + gprintf_msg_rest "$@" + #if [ -z "${IN_INITLOG:-}" ]; then + # initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 + #fi [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_warning return $rc } # Run some action. Log its output. action() { - local STRING rc + local rc + gprintf_msg_rest "$@" + echo -n "$GPRINTF_MSG " - STRING=$1 - echo -n "$STRING " - shift - "$@" && success $"$STRING" || failure $"$STRING" + $GPRINTF_REST && success "$GPRINTF_MSG" || failure "$GPRINTF_MSG" rc=$? echo return $rc @@ -599,22 +694,108 @@ strstr() { return 0 } + # Confirm whether we really want to run this service confirm() { - [ -x /bin/plymouth ] && /bin/plymouth --hide-splash - while : ; do - echo -n $"Start service $1 (Y)es/(N)o/(C)ontinue? [Y] " - read answer - if strstr $"yY" "$answer" || [ "$answer" = "" ] ; then - return 0 - elif strstr $"cC" "$answer" ; then - rm -f /var/run/confirm - [ -x /bin/plymouth ] && /bin/plymouth --show-splash - return 2 - elif strstr $"nN" "$answer" ; then - return 1 - fi - done + 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 @@ -703,14 +884,14 @@ init_crypto() { if ! key_is_random "$key"; then lsl=$(ls -l "$key") if [ "${lsl:4:6}" != "------" ]; then - echo $"INSECURE MODE FOR $key" + gprintf "INSECURE MODE FOR %s\n" $key fi fi if [ "$owner" != root ]; then - echo $"INSECURE OWNER FOR $key" + gprintf "INSECURE OWNER FOR %s\n" $key fi else - echo $"Key file for $dst not found, skipping" + gprintf "Key file for %s not found, skipping\n" $dst ret=1 continue fi @@ -748,21 +929,21 @@ init_crypto() { cipher) params="$params -c $value" if [ -z "$value" ]; then - echo $"$dst: no value for cipher option, skipping" + gprintf "%s: no value for cipher option, skipping\n" $dst skip="yes" fi ;; size) params="$params -s $value" if [ -z "$value" ]; then - echo $"$dst: no value for size option, skipping" + gprintf "%s: no value for size option, skipping\n" $dst skip="yes" fi ;; hash) params="$params -h $value" if [ -z "$value" ]; then - echo $"$dst: no value for hash option, skipping" + gprintf "%s: no value for hash option, skipping\n" $dst skip="yes" fi ;; @@ -785,7 +966,7 @@ init_crypto() { fi if [ -z "$makeswap" ] && cryptsetup isLuks "$src" 2>/dev/null ; then if key_is_random "$key"; then - echo $"$dst: LUKS requires non-random key, skipping" + gprintf "%s: LUKS requires non-random key, skipping\n" $dst ret=1 continue fi @@ -800,8 +981,15 @@ init_crypto() { 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 luksOpen -T1 $src $dst" <&1 - rc=$? + 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 diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt index 267a7c83..80deb629 100755 --- a/rc.d/init.d/halt +++ b/rc.d/init.d/halt @@ -20,7 +20,7 @@ halt_crypto() { [ -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 $dst" /sbin/cryptsetup remove "$dst" + action "Stopping disk encryption for %s" $dst /sbin/cryptsetup remove "$dst" else fnval=1 fi @@ -30,36 +30,27 @@ halt_crypto() { } kill_all() { - local STRING rc - - STRING=$1 - echo -n "$STRING " - shift /sbin/killall5 "$@" rc=$? - # Retval: 0: success 1: error 2: no processes found to kill if [ "$rc" == 1 ]; then - failure $"$STRING" - else - success $"$STRING" + return 1 fi - echo - return $rc + return 0 } # See how we were called. case "$0" in *halt) - message=$"Halting system..." + message=`gprintf "Halting system..."` command="/sbin/halt" ;; *reboot) - message=$"Please stand by while rebooting the system..." + message=`gprintf "Please stand by while rebooting the system..."` command="/sbin/reboot" kexec_command="/sbin/kexec" ;; *) - echo $"$0: call me as 'halt' or 'reboot' please!" + gprintf "%s: call me as 'halt' or 'reboot' please!\n" $0 exit 1 ;; esac @@ -67,44 +58,87 @@ case "$1" in *start) ;; *) - echo $"Usage: $0 {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/md/*.pid; do - if [ ! -r "$i" ]; then +for i in /dev/.mdadm/*.pid; do + if [ "$i" = "mdadm.pid" -o ! -r "$i" ]; then continue fi OMITARGS="$OMITARGS -o $(cat $i)" done -kill_all $"Sending all processes the TERM signal..." -15 $OMITARGS + +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 [ "$?" == 0 ]; then - sleep 2 - kill_all $"Sending all processes the KILL signal..." -9 $OMITARGS +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 [ -s /etc/alsa/alsactl.conf ] && [ -x /sbin/alsactl ] && [ -w /etc/asound.state ]; then - action $"Saving mixer settings" /sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --ignore store +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 +action "Saving random seed: " dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null -[ -x /sbin/hwclock ] && action $"Syncing hardware clock to system time" /sbin/hwclock --systohc +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; } @@ -114,7 +148,7 @@ tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; } # 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 + action "Turning off swap: " swapoff $SWAPS for dst in $SWAPS; do if [[ "$dst" == /dev/mapper* ]] \ && [ "$(dmsetup status "$dst" | cut -d ' ' -f 3)" = crypt ]; then @@ -125,7 +159,14 @@ if [ -n "$SWAPS" ]; then done fi -[ -x /sbin/quotaoff ] && action $"Turning off quotas: " /sbin/quotaoff -aug +[ -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 @@ -134,30 +175,62 @@ __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): " \ + "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): " \ + "Unmounting file systems: " \ + "Unmounting file systems (retry): " \ -f -[ -f /proc/bus/usb/devices ] && $UMOUNT /proc/bus/usb +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. -awk '$2 !~ /\/(|dev|proc|selinux|cgroup|sys)$/ && $1 !~ /(^\/dev\/ram|cgroup)/ { print $2 }' \ - /proc/mounts | sort -r | \ +# 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 @@ -166,8 +239,7 @@ if [ -x /sbin/halt.local ]; then /sbin/halt.local fi -# Tell init to re-exec itself. -kill -TERM 1 +update_boot_stage remount_ro # Remount read only anything that's left mounted. # echo $"Remounting remaining filesystems readonly" @@ -175,34 +247,39 @@ 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" +echo "$message" if [ -f /fastboot ]; then - echo $"On the next boot fsck will be skipped." + gprintf "On the next boot fsck will be skipped.\n" elif [ -f /forcefsck ]; then - echo $"On the next boot fsck will be forced." -fi - -# Shutdown UPS drivers -if [ "$command" = /sbin/halt ] && [ -f /etc/sysconfig/ups ]; then - . /etc/sysconfig/ups - if [ -z $POWERDOWNFLAG ]; then - POWERDOWNFLAG=/etc/killpower - fi - if [ "$SERVER" = "yes" ] && [ -f $POWERDOWNFLAG ]; then - /sbin/upsdrvctl shutdown - fi + 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="-d" +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 index 4405879c..574f4f6f 100755 --- a/rc.d/init.d/killall +++ b/rc.d/init.d/killall @@ -7,7 +7,7 @@ case "$1" in *start) ;; *) - echo $"Usage: $0 {start}" + gprintf "Usage: %s {start}\n" $0 exit 1 ;; esac diff --git a/rc.d/init.d/netconsole b/rc.d/init.d/netconsole index 42733de0..14f96d76 100644 --- a/rc.d/init.d/netconsole +++ b/rc.d/init.d/netconsole @@ -6,6 +6,15 @@ # description: Initializes network console logging # config: /etc/sysconfig/netconsole # +### BEGIN INIT INFO +# Provides: netconsole +# Required-Start: $network +# Required-Stop: $network +# Short-Description: Initializes network console logging +# Description: By starting this service you allow a remote syslog daemon +# to record console output from this system. +### END INIT INFO + # Copyright 2002 Red Hat, Inc. # # Based in part on a shell script by @@ -33,7 +42,7 @@ kernel=$(uname -r | cut -d. -f1-2) usage () { - echo $"Usage: $0 {start|stop|status|restart|condrestart}" 1>&2 + gprintf "Usage: %s {start|stop|status|restart|condrestart}\n" $0 1>&2 RETVAL=2 } @@ -73,13 +82,13 @@ start () fi fi if [ -z "$SYSLOGADDR" ] ; then - echo $"Server address not specified in /etc/sysconfig/netconsole" 1>&2 + gprintf "Server address not specified in /etc/sysconfig/netconsole\n" 1>&2 exit 6 fi eval $(print_address_info $SYSLOGADDR) if [ -z "$SYSLOGMACADDR" ]; then - echo $"netconsole: can't resolve MAC address of $SYSLOGADDR" 1>&2 + gprintf "netconsole: can't resolve MAC address of %s\n" $SYSLOGADDR 1>&2 exit 1 fi @@ -88,7 +97,7 @@ start () /usr/bin/logger -p daemon.info -t netconsole: inserting netconsole module with arguments \ $SYSLOGOPTS if [ -n "$SYSLOGOPTS" ]; then - action $"Initializing netconsole" modprobe netconsole \ + action "Initializing netconsole" modprobe netconsole \ $SYSLOGOPTS [ "$?" != "0" ] && RETVAL=1 fi @@ -98,7 +107,7 @@ start () stop () { if /sbin/lsmod | grep netconsole >/dev/null 2>&1 ; then - action $"Disabling netconsole" rmmod netconsole; + action "Disabling netconsole" rmmod netconsole; [ "$?" != "0" ] && RETVAL=1 fi @@ -108,10 +117,10 @@ stop () status () { if /sbin/lsmod | grep netconsole >/dev/null 2>&1 ; then - echo $"netconsole module loaded" + gprintf "netconsole module loaded\n" RETVAL=0 else - echo $"netconsole module not loaded" + gprintf "netconsole module not loaded\n" RETVAL=3 fi } diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs index 3633284b..2a37ce76 100755 --- a/rc.d/init.d/netfs +++ b/rc.d/init.d/netfs @@ -9,10 +9,17 @@ # 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 -# Short-Description: Mount and unmount network filesystems. -# Description: Mount and unmount network filesystems. +# 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 @@ -36,11 +43,10 @@ case "$1" in [ "$EUID" != "0" ] && exit 4 [ -n "$NFSFSTAB" ] && { - [ ! -f /var/lock/subsys/rpcbind ] && service rpcbind start - action $"Mounting NFS filesystems: " mount -a -t nfs,nfs4 + 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 "$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 @@ -55,7 +61,7 @@ case "$1" in 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 + action "Setting up Logical Volume Management:" /sbin/lvm vgchange -a y fi fi @@ -63,7 +69,7 @@ case "$1" in init_crypto 1 fi - STRING=$"Checking network-attached filesystems" + STRING=`gprintf "Checking network-attached filesystems"` echo $STRING fsck -A -T -R -a -t opts=_netdev @@ -85,11 +91,11 @@ case "$1" in tty >/dev/null 2>&1 || exit 1 echo echo - echo $"*** An error occurred during the file system check." - echo $"*** Dropping you to a shell; the system will reboot" - echo $"*** when you leave the shell." + 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=$"(Repair filesystem)" + str=`gprintf "(Repair filesystem)"` PS1="$str \# # "; export PS1 [ "$SELINUX" = "1" ] && disable_selinux sulogin @@ -99,7 +105,7 @@ case "$1" in } 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 + action $"Mounting other filesystems: " mount -a -t nonfs,nfs4,cifs,ncpfs,gfs2 -O noencrypted ;; stop) # Unmount loopback stuff first @@ -108,14 +114,14 @@ case "$1" in if [ -n "$NETDEVMTAB" ]; then __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \ /etc/mtab \ - $"Unmounting network block filesystems: " \ - $"Unmounting network block filesystems (retry): " + "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): " \ + "Unmounting NFS filesystems: " \ + "Unmounting NFS filesystems (retry): " \ "-f -l" fi if [ -n "$CIFSMTAB" ]; then @@ -133,39 +139,39 @@ case "$1" in status) if [ -f /proc/mounts ] ; then [ -n "$NFSFSTAB" ] && { - echo $"Configured NFS mountpoints: " + gprintf "Configured NFS mountpoints: \n" for fs in $NFSFSTAB; do echo $fs ; done } [ -n "$CIFSFSTAB" ] && { - echo $"Configured CIFS mountpoints: " + gprintf "Configured CIFS mountpoints: \n" for fs in $CIFSFSTAB; do echo $fs ; done } [ -n "$NCPFSTAB" ] && { - echo $"Configured NCP mountpoints: " + gprintf "Configured NCP mountpoints: \n" for fs in $NCPFSTAB; do echo $fs ; done } [ -n "$NETDEVFSTAB" ] && { - echo $"Configured network block devices: " + gprintf "Configured network block devices: \n" for fs in $NETDEVFSTAB; do echo $fs ; done } [ -n "$NFSMTAB" ] && { - echo $"Active NFS mountpoints: " + gprintf "Active NFS mountpoints: \n" for fs in $NFSMTAB; do echo $fs ; done } [ -n "$CIFSMTAB" ] && { - echo $"Active CIFS mountpoints: " + gprintf "Active CIFS mountpoints: \n" for fs in $CIFSMTAB; do echo $fs ; done } [ -n "$NCPMTAB" ] && { - echo $"Active NCP mountpoints: " + gprintf "Active NCP mountpoints: \n" for fs in $NCPMTAB; do echo $fs ; done } [ -n "$NETDEVMTAB" ] && { - echo $"Active network block devices: " + gprintf "Active network block devices: \n" for fs in $NETDEVMTAB; do echo $fs ; done } else - echo $"/proc filesystem unavailable" + gprintf "/proc filesystem unavailable\n" fi [ -r /var/lock/subsys/netfs ] || exit 3 ;; @@ -179,7 +185,7 @@ case "$1" in exit $? ;; *) - echo $"Usage: $0 {start|stop|restart|reload|status}" + gprintf "Usage: %s\n" "$(basename $0) {start|stop|restart|reload|status}" exit 2 esac diff --git a/rc.d/init.d/network b/rc.d/init.d/network index c6b86c37..9b86aa70 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -5,9 +5,16 @@ # chkconfig: - 10 90 # description: Activates/Deactivates all network interfaces configured to \ # start at boot time. +# probe: false # ### BEGIN INIT INFO -# Provides: $network +# Provides: network +# Should-Start: harddrake irda resolvconf slmodemd +# Should-Stop: irda resolvconf slmodemd +# Default-Start: 2 3 4 5 +# Short-Description: Bring up/down networking +# Description: Activates/Deactivates all network interfaces configured to +# start at boot time. # Should-Start: iptables ip6tables # Short-Description: Bring up/down networking # Description: Bring up/down networking @@ -17,6 +24,7 @@ . /etc/init.d/functions if [ ! -f /etc/sysconfig/network ]; then + echo "NETWORKING=no" > /etc/sysconfig/network exit 6 fi @@ -43,10 +51,10 @@ cd /etc/sysconfig/network-scripts # find all the interfaces besides loopback. # ignore aliases, alternative configurations, and editor backup files -interfaces=$(ls ifcfg-* | \ +interfaces=$(ls ifcfg* | \ LC_ALL=C sed -e "$__sed_discard_ignored_files" \ -e '/\(ifcfg-lo$\|:\|ifcfg-.*-range\)/d' \ - -e '{ s/^ifcfg-//g;s/[0-9]/ &/}' | \ + -e '/ifcfg-[A-Za-z0-9#\._-]\+$/ { s/^ifcfg-//g;s/[0-9]/ &/}' | \ LC_ALL=C sort -k 1,1 -k 2n | \ LC_ALL=C sed 's/ //') rc=0 @@ -63,8 +71,12 @@ case "$1" in apply_sysctl + if [ -r /etc/ethers -a -x /sbin/arp ]; then + action "Storing ARP mapping" /sbin/arp -f /etc/ethers + fi + # bring up loopback interface - action $"Bringing up loopback interface: " ./ifup ifcfg-lo + action "Bringing up loopback interface: " ./ifup ifcfg-lo case "$IPX" in yes|true) @@ -75,11 +87,16 @@ case "$1" in fi ;; esac + # depreciated but we still use it. + if [ -f /proc/sys/net/ipv4/ip_forward ] && [[ "$FORWARD_IPV4" = "yes" || "$FORWARD_IPV4" = "true" ]]; + then + action "Enabling IPv4 packet forwarding" sysctl -w net.ipv4.ip_forward=1 + fi case "$VLAN" in yes) if [ ! -d /proc/net/vlan ] && ! modprobe 8021q >/dev/null 2>&1 ; then - net_log $"No 802.1Q VLAN support available in kernel." + gprintf "No 802.1Q VLAN support available in kernel.\n" fi ;; esac @@ -89,6 +106,14 @@ case "$1" in xdslinterfaces="" bridgeinterfaces="" + # do we have wireless cards? + iwconfig 2>/dev/null | grep IEEE > /dev/null + has_wifi=$? + # configure CRDA domain + if [ -n "${CRDA_DOMAIN}" -a -x /sbin/iw -a "$has_wifi" == 0 ]; then + action "Configuring wireless regulatory domain " /sbin/iw reg set ${CRDA_DOMAIN} + fi + # bring up all other interfaces configured to come up at boot time for i in $interfaces; do unset DEVICE TYPE SLAVE @@ -106,7 +131,7 @@ case "$1" in vpninterfaces="$vpninterfaces $i" continue fi - if [ "$TYPE" = "xDSL" ]; then + if [ "$TYPE" = "xDSL" -o "$TYPE" = "ADSL" ]; then xdslinterfaces="$xdslinterfaces $i" continue fi @@ -131,11 +156,22 @@ case "$1" in continue fi # 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 $i: " ./ifup $i boot + [ -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 @@ -147,7 +183,7 @@ case "$1" in confirm $i test $? = 1 && continue fi - action $"Bringing up interface $i: " ./ifup $i boot + action "Bringing up interface %s: " $i ./ifup $i boot [ $? -ne 0 ] && rc=1 fi done @@ -167,8 +203,6 @@ case "$1" in apply_sysctl touch /var/lock/subsys/network - - [ -n "${NETWORKDELAY}" ] && /bin/sleep ${NETWORKDELAY} ;; stop) [ "$EUID" != "0" ] && exit 4 @@ -219,7 +253,7 @@ case "$1" in bridgeinterfaces="$bridgeinterfaces $i" continue fi - if [ "$TYPE" = "xDSL" ]; then + if [ "$TYPE" = "xDSL" -o "$TYPE" = "ADSL" ]; then xdslinterfaces="$xdslinterfaces $i" continue fi @@ -236,7 +270,7 @@ case "$1" in if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi if ! check_device_down $DEVICE; then - action $"Shutting down interface $i: " ./ifdown $i boot + action "Shutting down interface %s: " $i ./ifdown $i boot [ $? -ne 0 ] && rc=1 fi ) @@ -250,9 +284,25 @@ case "$1" in ;; esac - action $"Shutting down loopback interface: " ./ifdown ifcfg-lo + action "Shutting down loopback interface: " ./ifdown ifcfg-lo - sysctl -w net.ipv4.ip_forward=0 > /dev/null 2>&1 + if [ -d /proc/sys/net/ipv4 ]; then + if [ -f /proc/sys/net/ipv4/ip_forward ]; then + if [ $(cat /proc/sys/net/ipv4/ip_forward) != 0 ]; then + action "Disabling IPv4 packet forwarding: " sysctl -w net.ipv4.ip_forward=0 + fi + fi + if [ -f /proc/sys/net/ipv4/ip_always_defrag ]; then + if [ $(cat /proc/sys/net/ipv4/ip_always_defrag) != 0 ]; then + action "Disabling IPv4 automatic defragmentation: " sysctl -w net.ipv4.ip_always_defrag=0 + fi + fi + fi + if [ -f /proc/sys/net/ipv4/tcp_syncookies ];then + if [ `cat /proc/sys/net/ipv4/tcp_syncookies` != 0 ]; then + sysctl -w net.ipv4.tcp_syncookies=0 + fi + fi # IPv6 hook (post IPv4 stop) if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then @@ -262,10 +312,10 @@ case "$1" in rm -f /var/lock/subsys/network ;; status) - echo $"Configured devices:" + gprintf "Configured devices:\n" echo lo $interfaces - echo $"Currently active devices:" + gprintf "Currently active devices:\n" echo $(/sbin/ip -o link show up | awk -F ": " '{ print $2 }') ;; restart|reload|force-reload) @@ -275,7 +325,7 @@ case "$1" in rc=$? ;; *) - echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" + gprintf "Usage: %s\n" "$(basename $0) {start|stop|restart|reload|status}" exit 2 esac diff --git a/rc.d/init.d/single b/rc.d/init.d/single index 0ae9268e..8f37963a 100755 --- a/rc.d/init.d/single +++ b/rc.d/init.d/single @@ -16,9 +16,25 @@ 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. -echo $"Telling INIT to go to single user mode." +gprintf "Telling INIT to go to single user mode.\n" + +# init hangs if LANG is set +unset LANG + exec init -t1 S |
