]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
scripts/init.d/cgred.in: add fallback logging on non-lsb systems
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 25 Mar 2022 06:06:19 +0000 (11:36 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 29 Mar 2022 21:11:09 +0000 (15:11 -0600)
Add support for fallback logging on non-lsb system, this logic is
borrowed from the commit 63a8972bac45 ("Modernise cgconfig initscript").

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
scripts/init.d/cgred.in

index 75377636f6002cb98a5c655ef05118c6dea838b9..3374dafeb5bc6354c1a6a00c9711dd9d577d518a 100644 (file)
@@ -32,11 +32,25 @@ CGRED_BIN=$sbindir/cgrulesengd
 # Sanity checks
 [[ -x $CGRED_BIN ]] || exit 1
 
-# Source function library & LSB routines
-# shellcheck disable=SC1091
-source /etc/rc.d/init.d/functions
-# shellcheck disable=SC1091
-source /lib/lsb/init-functions
+#
+# Source LSB routines
+#
+SYSLIBFILE=/lib/lsb/init-functions
+OLDSYSLIBFILE=/etc/init.d/functions
+if [[ -x  $SYSLIBFILE ]] ; then
+  # shellcheck disable=SC1090
+  source $SYSLIBFILE
+elif  [[ -x $OLDSYSLIBFILE ]] ; then
+  # shellcheck disable=SC1090
+  source $OLDSYSLIBFILE
+  log_warning_msg() ( warning "$@" ; printf "\n" 1>&2 ; )
+  log_failure_msg() ( failure "$@" ; printf "\n" 1>&2 ; )
+  log_success_msg() ( success "$@" ; printf "\n" 1>&2 ; )
+else
+  log_warning_msg() ( printf "warning:%s\n" "$@" 1>&2 ;)
+  log_failure_msg() ( printf "failure:%s\n" "$@" 1>&2 ;)
+  log_success_msg() ( printf "success:%s\n" "$@" 1>&2 ;)
+fi
 
 # Read in configuration options.
 if [[ -f "/etc/sysconfig/cgred.conf" ]] ; then
@@ -139,9 +153,9 @@ case "$1" in
                        kill -s 12 "$(cat ${pidfile})"
                        RETVAL=$?
                        if [[ $RETVAL -eq 0 ]] ; then
-                               log_success_msg
+                               log_success_msg ""
                        else
-                               log_failure_msg
+                               log_failure_msg ""
                        fi
                else
                        log_failure_msg "$servicename is not running."