summaryrefslogtreecommitdiffstats
path: root/import-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2016-08-17 14:31:25 -0500
committerPatrick Williams <patrick@stwcx.xyz>2016-08-22 16:43:26 +0000
commit60f9d69e016b11c468c98ea75ba0a60c44afbbc4 (patch)
treeecb49581a9e41a37943c22cd9ef3f63451b20ee7 /import-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions
parente18c61205e0234b03697129c20cc69c9b3940efc (diff)
downloadblackbird-openbmc-60f9d69e016b11c468c98ea75ba0a60c44afbbc4.tar.gz
blackbird-openbmc-60f9d69e016b11c468c98ea75ba0a60c44afbbc4.zip
yocto-poky: Move to import-layers subdir
We are going to import additional layers, so create a subdir to hold all of the layers that we import with git-subtree. Change-Id: I6f732153a22be8ca663035c518837e3cc5ec0799 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'import-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions')
-rwxr-xr-ximport-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions91
1 files changed, 91 insertions, 0 deletions
diff --git a/import-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions b/import-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions
new file mode 100755
index 000000000..01ad1edd3
--- /dev/null
+++ b/import-layers/yocto-poky/meta/recipes-core/initscripts/initscripts-1.0/functions
@@ -0,0 +1,91 @@
+# -*-Shell-script-*-
+#
+# 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:
+# 1) If there is no "pidof -x", replace the "pidof $1" with another
+# command like(for core-image-minimal):
+# ps | awk '/'"$1"'/ {print $1}'
+# Or
+# 2) If there is "pidof -x", replace "pidof" with "pidof -x".
+#
+# pidofproc - print the pid of a process
+# $1: the name of the process
+pidofproc () {
+
+ # pidof output null when no program is running, so no "2>/dev/null".
+ pid=`pidof $1`
+ status=$?
+ case $status in
+ 0)
+ echo $pid
+ return 0
+ ;;
+ 127)
+ echo "ERROR: command pidof not found" >&2
+ exit 127
+ ;;
+ *)
+ return $status
+ ;;
+ esac
+}
+
+machine_id() { # return the machine ID
+ awk 'BEGIN { FS=": " } /Hardware/ \
+ { gsub(" ", "_", $2); print tolower($2) } ' </proc/cpuinfo
+}
+
+killproc() { # kill the named process(es)
+ pid=`pidofproc $1` && kill $pid
+}
+
+status() {
+ local pid
+ if [ "$#" = 0 ]; then
+ echo "Usage: status {program}"
+ return 1
+ fi
+ pid=`pidofproc $1`
+ if [ -n "$pid" ]; then
+ echo "$1 (pid $pid) is running..."
+ return 0
+ else
+ echo "$1 is stopped"
+ 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
+}
OpenPOWER on IntegriCloud