Patchwork initscripts: define failure/success/warning/pass functions

login
register
mail settings
Submitter rongqing.li@windriver.com
Date Jan. 22, 2014, 8:57 a.m.
Message ID <1390381058-5640-1-git-send-email-rongqing.li@windriver.com>
Download mbox | patch
Permalink /patch/65509/
State Accepted
Commit 17e6df62d923aa50ae814b737e1b91224b2dd985
Headers show

Comments

rongqing.li@windriver.com - Jan. 22, 2014, 8:57 a.m.
From: Roy Li <rongqing.li@windriver.com>

define failure/success/warning/pass functions, some packages' initscript
need them, and /etc/core-lsb/lsb_log_message from lsb needs them too.

Signed-off-by: Roy Li <rongqing.li@windriver.com>
---
 .../initscripts/initscripts-1.0/functions          |   31 ++++++++++++++++++++
 1 file changed, 31 insertions(+)
 mode change 100644 => 100755 meta/recipes-core/initscripts/initscripts-1.0/functions

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/functions b/meta/recipes-core/initscripts/initscripts-1.0/functions
old mode 100644
new mode 100755
index 8e15762..01ad1ed
--- a/meta/recipes-core/initscripts/initscripts-1.0/functions
+++ b/meta/recipes-core/initscripts/initscripts-1.0/functions
@@ -3,6 +3,14 @@ 
 # functions     This file contains functions to be used by most or all
 #               shell scripts in the /etc/init.d directory.
 #
+
+NORMAL="\\033[0;39m"         # Standard console grey
+SUCCESS="\\033[1;32m"        # Success is green
+WARNING="\\033[1;33m"        # Warnings are yellow
+FAILURE="\\033[1;31m"        # Failures are red
+INFO="\\033[1;36m"           # Information is light cyan
+BRACKET="\\033[1;34m"        # Brackets are blue
+
 # NOTE: The pidofproc () doesn't support the process which is a script unless
 #       the pidof supports "-x" option. If you want to use it for such a
 #       process:
@@ -58,3 +66,26 @@  status() {
     fi
     return 3
 }
+
+success() {
+    echo -n -e "${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
+    return 0
+}
+
+failure() {
+    local rc=$*
+    echo -n -e "${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
+    return $rc
+}
+
+warning() {
+    local rc=$*
+    echo -n -e "${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}"
+    return $rc
+}
+
+passed() {
+    local rc=$*
+    echo -n -e "${BRACKET}[${SUCCESS} PASS ${BRACKET}]${NORMAL}"
+    return $rc
+}