diff options
Diffstat (limited to 'rc.d/init.d')
-rwxr-xr-x[-rw-r--r--] | rc.d/init.d/functions | 78 | ||||
-rw-r--r-- | rc.d/init.d/netconsole | 23 | ||||
-rwxr-xr-x | rc.d/init.d/network | 16 |
3 files changed, 99 insertions, 18 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 2e3da964..b8bd20bc 100644..100755 --- 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 @@ -55,8 +62,6 @@ systemctl_redirect () { action "$s" /bin/systemctl $options $command "$prog.service" } -# Get a sane screen width -[ -z "${COLUMNS:-}" ] && COLUMNS=80 if [ -z "${CONSOLETYPE:-}" ]; then if [ -c "/dev/stderr" ] && [ -r "/dev/stderr" ]; then @@ -66,6 +71,10 @@ if [ -z "${CONSOLETYPE:-}" ]; then 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 + if [ -z "${NOLOCALE:-}" ] && [ -z "${LANGSH_SOURCED:-}" ] && \ [ -f /etc/sysconfig/i18n -o -f /etc/locale.conf ] ; then . /etc/profile.d/lang.sh 2>/dev/null @@ -108,6 +117,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" +} + + # Check if any of $pid (could be plural) are running checkpid() { local i @@ -579,6 +642,7 @@ update_boot_stage() { # Log that something succeeded success() { + gprintf_msg_rest "$@" [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success return 0 } @@ -586,6 +650,7 @@ success() { # Log that something failed failure() { local rc=$? + gprintf_msg_rest "$@" [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure [ -x /bin/plymouth ] && /bin/plymouth --details return $rc @@ -594,6 +659,7 @@ failure() { # Log that something passed, but may have had errors. Useful for fsck passed() { local rc=$? + gprintf_msg_rest "$@" [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_passed return $rc } @@ -601,6 +667,7 @@ passed() { # Log a warning warning() { local rc=$? + gprintf_msg_rest "$@" [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_warning return $rc } @@ -608,11 +675,10 @@ warning() { # Run some action. Log its output. action() { local STRING 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 diff --git a/rc.d/init.d/netconsole b/rc.d/init.d/netconsole index ad51bd22..f471837a 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 } @@ -90,13 +99,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 @@ -105,7 +114,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 @@ -115,7 +124,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 @@ -125,10 +134,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/network b/rc.d/init.d/network index 92da47db..bae7b9b0 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -5,18 +5,23 @@ # chkconfig: - 10 90 # description: Activates/Deactivates all network interfaces configured to \ # start at boot time. +# probe: false # ### BEGIN INIT INFO -# Provides: $network -# Should-Start: iptables ip6tables NetworkManager-wait-online NetworkManager $network-pre +# Provides: network +# Should-Start: irda resolvconf iptables ip6tables NetworkManager-wait-online NetworkManager +# Should-Stop: irda resolvconf +# Default-Start: 2 3 4 5 # Short-Description: Bring up/down networking -# Description: Bring up/down networking +# Description: Activates/Deactivates all network interfaces configured to +# start at boot time. ### END INIT INFO # Source function library. . /etc/init.d/functions if [ ! -f /etc/sysconfig/network ]; then + echo "NETWORKING=no" > /etc/sysconfig/network exit 6 fi @@ -44,9 +49,10 @@ cd /etc/sysconfig/network-scripts 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 grep -v '^ifcfg-' | \ LC_ALL=C sort -k 1,1 -k 2n | \ - LC_ALL=C sed 's/ //') + LC_ALL=C sed -e 's/ \([0-9]\)/\1/') rc=0 # See how we were called. |