]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - lib/functions
rename option to RC_UPTIME and add to default config
[projects/rc-scripts.git] / lib / functions
index 6ae814cd4f023a17fbcc3f08a5a356803a97331f..4658d6f08a178fc51c35b1573d5b9972b626a1bf 100644 (file)
@@ -62,6 +62,17 @@ env_upstart=$USE_UPSTART
 [ -r /etc/sysconfig/system ] && . /etc/sysconfig/system
 [ -r /etc/sysconfig/bootsplash ] && . /etc/sysconfig/bootsplash
 
+# if initscript is invoked via bash, enable RedHat/Fedora compatibility
+# RC_FEDORA is "set" if enabled and "unset" when not, but it's "value" is always empty
+# this is useful for inline constructs
+if [ "${BASH_VERSION+set}" = "set" ]; then
+       RC_LOGGING=yes
+       FASTRC=no
+       RC_FEDORA=
+else
+       unset RC_FEDORA || :
+fi
+
 [ "$env_upstart" ] && USE_UPSTART=$env_upstart
 
 if [ -z "$VSERVER" -o "$VSERVER" = "detect" ]; then
@@ -158,7 +169,7 @@ strstr() {
        return 0
 }
 
-if is_yes "$FASTRC" || ! is_no "$IN_SHUTDOWN"; then
+if is_yes "$FASTRC" || is_yes "$IN_SHUTDOWN"; then
        RC_LOGGING=no
 fi
 
@@ -381,12 +392,16 @@ msg_usage() {
 
 # Some functions to handle PLD Linux-style messages
 show() {
-       local text len
+       local text len time
+
+       if is_yes "$RC_UPTIME"; then
+               time=$(awk '{printf("[%8.2f] ", $1)}' /proc/uptime)
+       fi
 
        if is_no "$FASTRC" && is_yes "$GETTEXT"; then
-               text=$(nls -n "$@")
+               text=$time$(nls -n "$@")
        else
-               text=$(printf "$@")
+               text=$time$(printf "$@")
        fi
        len=${#text}
        while [ $((len++)) -lt $INIT_COL ]; do
@@ -424,7 +439,7 @@ busy() {
 }
 
 ok() {
-       echo "$_ok"
+       echo -ne "$_ok${RC_FEDORA+\r}${RC_FEDORA-\n}"
 }
 
 started() {
@@ -432,7 +447,7 @@ started() {
 }
 
 fail() {
-       echo "$_fail"
+       echo -ne "$_fail${RC_FEDORA+\r}${RC_FEDORA-\n}"
        return 1
 }
 
This page took 0.043341 seconds and 4 git commands to generate.