diff options
author | Bill Nottingham <notting@redhat.com> | 2001-01-23 19:59:11 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2001-01-23 19:59:11 +0000 |
commit | a4a25465cd2844d72bf518188b813c009450f505 (patch) | |
tree | 25ca5df7db282aa4202813aba3c0e18083927c25 /rc.d/init.d/functions | |
parent | bee84f538da8b1d5885975c119bfd7fd5ae7e9a3 (diff) | |
download | initscripts-a4a25465cd2844d72bf518188b813c009450f505.tar initscripts-a4a25465cd2844d72bf518188b813c009450f505.tar.gz initscripts-a4a25465cd2844d72bf518188b813c009450f505.tar.bz2 initscripts-a4a25465cd2844d72bf518188b813c009450f505.tar.xz initscripts-a4a25465cd2844d72bf518188b813c009450f505.zip |
change i18n stuff around; don't call gettext explicitly, just do echo $"some string"
Diffstat (limited to 'rc.d/init.d/functions')
-rwxr-xr-x | rc.d/init.d/functions | 114 |
1 files changed, 32 insertions, 82 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 03ec4ce5..4638b709 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # functions This file contains functions to be used by most or all # shell scripts in the /etc/init.d directory. @@ -54,49 +54,6 @@ else INITLOG_ARGS= fi -if [ -z "$GP_LANG" -a -f /etc/sysconfig/i18n ]; then - GP_LANG=$(sed -n 's/"//g ; s/^LANG=//p' /etc/sysconfig/i18n ) -fi - -gprintf() { - if [ -x /usr/bin/gettext ]; then - local TEXT=`LC_MESSAGES=$GP_LANG gettext -e --domain=$TEXTDOMAIN "$1"` - 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 checkpid() { while [ "$1" ]; do @@ -115,7 +72,7 @@ daemon() { nicelevel=0 while [ "$1" != "${1##-}" -o "$1" != "${1##+}" ]; do case $1 in - '') gprintf "$0: Usage: daemon [+/-nicelevel] {program}\n" $0 + '') echo $"$0: Usage: daemon [+/-nicelevel] {program}" return 1;; --check) shift @@ -169,7 +126,7 @@ killproc() { RC=0 # Test syntax. if [ $# = 0 ]; then - gprintf "Usage: killproc {program} [signal]\n" + echo $"Usage: killproc {program} [signal]" return 1 fi @@ -241,7 +198,7 @@ pidofproc() { # Test syntax. if [ $# = 0 ] ; then - echo "Usage: pidofproc {program}" + echo $"Usage: pidofproc {program}" return 1 fi @@ -267,14 +224,14 @@ status() { # Test syntax. if [ $# = 0 ] ; then - gprintf "Usage: status {program}\n" + echo $"Usage: status {program}" return 1 fi # First try "pidof" pid=`pidof -o $$ -o $PPID -o %PPID -x ${base}` if [ "$pid" != "" ] ; then - gprintf "%s (pid %s) is running...\n" "${base}" "$pid" + echo $"${base} (pid $pid) is running..." return 0 fi @@ -282,16 +239,16 @@ status() { if [ -f /var/run/${base}.pid ] ; then pid=`cat /var/run/${base}.pid | { read foo ; echo $foo ; }` if [ "$pid" != "" ] ; then - gprintf "%s dead but pid file exists\n" "${base}" + echo $"${base} dead but pid file exists" return 1 fi fi # See if /var/lock/subsys/${base} exists if [ -f /var/lock/subsys/${base} ]; then - gprintf "%s dead but subsys locked\n" "${base}" + echo $"${base} dead but subsys locked" return 2 fi - gprintf "%s is stopped\n" "${base}" + echo $"${base} is stopped" return 3 } @@ -299,7 +256,7 @@ echo_success() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[ " [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS - gprintf "OK" + echo -n $"OK" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n " ]" echo -ne "\r" @@ -310,7 +267,7 @@ echo_failure() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE - gprintf "FAILED" + echo -n $"FAILED" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" @@ -321,7 +278,7 @@ echo_passed() { [ "$BOOTUP" = "color" ] && $MOVE_TO_COL echo -n "[" [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING - gprintf "PASSED" + echo -n $"PASSED" [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL echo -n "]" echo -ne "\r" @@ -330,14 +287,12 @@ echo_passed() { # Log that something succeeded success() { - gprintf_msg_rest "$@" if [ -z "$IN_INITLOG" ]; then - initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 1 + initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 else # silly hack to avoid EPIPE killing rc.sysinit trap "" SIGPIPE -# FIXME? - echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21 + echo $"$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21 trap - SIGPIPE fi [ "$BOOTUP" != "verbose" ] && echo_success @@ -347,12 +302,11 @@ success() { # Log that something failed failure() { rc=$? - gprintf_msg_rest "$@" if [ -z "$IN_INITLOG" ]; then - initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 2 + initlog $INITLOG_ARGS -n $0 -s "$1" -e 2 else trap "" SIGPIPE - echo "-n $0 -s \"$GPRINTF_MSG\" -e 1" >&21 + echo $"$INITLOG_ARGS -n $0 -s \"$1\" -e 2" >&21 trap - SIGPIPE fi [ "$BOOTUP" != "verbose" ] && echo_failure @@ -362,13 +316,11 @@ failure() { # Log that something passed, but may have had errors. Useful for fsck passed() { rc=$? - gprintf_msg_rest "$@" if [ -z "$IN_INITLOG" ]; then - initlog $INITLOG_ARGS -n $0 -s "$GPRINTF_MSG" -e 1 + initlog $INITLOG_ARGS -n $0 -s "$1" -e 1 else trap "" SIGPIPE -#FIXME? - echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21 + echo $"$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21 trap - SIGPIPE fi [ "$BOOTUP" != "verbose" ] && echo_passed @@ -377,9 +329,10 @@ passed() { # Run some action. Log its output. action() { - gprintf_msg_rest "$@" - echo -n "$GPRINTF_MSG " - initlog $INITLOG_ARGS -c "$GPRINTF_REST" && success "$GPRINTF_MSG" || failure "$GPRINTF_MSG" + STRING=$1 + echo -n $"$STRING " + shift + initlog $INITLOG_ARGS -c "$*" && success $"$STRING" || failure $"$STRING" rc=$? echo return $rc @@ -393,23 +346,20 @@ strstr() { return 0 } - # Confirm whether we really want to run this service confirm() { - gprintf "Start service %s (Y)es/(N)o/(C)ontinue? [Y] " $1 - local YES=`gprintf "yY"` - local NOT=`gprintf "nN"` - local CNT=`gprintf "cC"` - + local YES=$"yY" + local NO=$"nN" + local CONT=$"cC" + + echo -n $"Start service $1 (Y)es/(N)o/(C)ontinue? [Y] " read answer - if strstr "$YES" "$answer" || [ "$answer" = "" ] ; then - return 0 - elif strstr "$CNT" "$answer" ; then - return 2 - elif strstr "$NOT" "$answer" ; then - return 1 + return 0 + elif strstr "$CONT" "$answer" ; then + return 2 + elif strstr "$NO" "$answer" ; then + return 1 fi confirm $* - } |