mirror of
https://git.yoctoproject.org/poky
synced 2026-07-02 11:17:21 +00:00
f587cfcb8a
* add function log_success_msg/log_failure_msg/log_warning_msg, some packages still use these functions, like mariadb, refer [1], without these function, with sysV init manager, mariadb will report error: root@qemux86-64:~# /etc/init.d/mysqld status /etc/init.d/mysqld: line 383: log_success_msg: command not found * remove RCONFLICTS with lsbinitscripts, LSB support already remove in [2] [1] https://github.com/MariaDB/server/blob/main/support-files/mysql.server.sh#L104 [2] https://git.openembedded.org/openembedded-core/commit/?id=fb064356af615d67d85b65942103bf943d84d290 [3] https://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html (From OE-Core rev: 90cf409ba74c4bb398199667ea2819759a720373) Signed-off-by: Changqing Li <changqing.li@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
116 lines
2.3 KiB
Bash
Executable File
116 lines
2.3 KiB
Bash
Executable File
# -*-Shell-script-*-
|
|
#
|
|
# functions This file contains functions to be used by most or all
|
|
# shell scripts in the /etc/init.d directory.
|
|
#
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
|
|
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
|
|
}
|
|
|
|
log_success_msg()
|
|
{
|
|
echo -n $@
|
|
success
|
|
echo
|
|
}
|
|
|
|
log_failure_msg()
|
|
{
|
|
echo -n $@
|
|
failure
|
|
echo
|
|
}
|
|
|
|
log_warning_msg()
|
|
{
|
|
echo -n $@
|
|
warning
|
|
echo
|
|
}
|