diff --git a/etc/rc.d/rc.cgconfig b/etc/rc.d/rc.cgconfig index ad75f2057..46f5a1777 100644 --- a/etc/rc.d/rc.cgconfig +++ b/etc/rc.d/rc.cgconfig @@ -24,7 +24,7 @@ ### END INIT INFO # get correct location of binaries from configure -sbindir=${exec_prefix}/sbin +sbindir=/usr/sbin CGCONFIGPARSER_BIN=$sbindir/cgconfigparser CONFIG_FILE=/etc/cgconfig.conf CONFIG_DIR=/etc/cgconfig.d @@ -32,6 +32,25 @@ servicename=cgconfig lockfile=/run/lock/subsys/$servicename +# +# 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 the config CREATE_DEFAULT=yes @@ -50,8 +69,8 @@ create_default_groups() { read -r user ctrl defaultcgroup <<< \ "$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)" if [[ ( -n "$defaultcgroup" ) && ( "$defaultcgroup" = "*" ) ]]; then - echo "/etc/cgrules.conf incorrect" - echo "Overriding it" + log_warning_msg "/etc/cgrules.conf incorrect" + log_warning_msg "Overriding it" defaultcgroup= fi fi @@ -94,19 +113,19 @@ create_default_groups() { start() { printf "Starting %s service: " "$servicename" if [[ -f "$lockfile" ]]; then - echo "lock file already exists" + log_warning_msg "lock file already exists" return 0 fi if [[ ! -s "$CONFIG_FILE" ]]; then - echo $CONFIG_FILE "is not configured" + log_failure_msg $CONFIG_FILE "is not configured" return 6 fi if ! "$CGCONFIGPARSER_BIN" -l "$CONFIG_FILE" -L "$CONFIG_DIR" then - echo "Failed to parse " "$CONFIG_FILE" "or" "$CONFIG_DIR"'/*' + log_failure_msg "Failed to parse " "$CONFIG_FILE" "or" "$CONFIG_DIR"'/*' return 1 fi @@ -115,22 +134,22 @@ start() { fi if ! mkdir -p "$lockfiledir" ; then - echo "Failed to mkdir $lockfiledir directory" + log_failure_msg "Failed to mkdir $lockfiledir directory" return 1 fi if ! touch "$lockfile" ; then - echo "Failed to touch $lockfile" + log_failure_msg "Failed to touch $lockfile" return 1 fi - echo "Started $servicename" + log_success_msg "Started $servicename" return 0 } stop() { printf "Stopping %s service is not supported!: " "$servicename" - echo "Failed to stop $servicename" + log_failure_msg "Failed to stop $servicename" return 1 } diff --git a/etc/rc.d/rc.cgred b/etc/rc.d/rc.cgred index 6df2a6315..437da5418 100644 --- a/etc/rc.d/rc.cgred +++ b/etc/rc.d/rc.cgred @@ -26,7 +26,7 @@ # cgroups to classify processes ### END INIT INFO -sbindir=${exec_prefix}/sbin +sbindir=/usr/sbin CGRED_BIN=$sbindir/cgrulesengd # Sanity checks @@ -35,7 +35,7 @@ CGRED_BIN=$sbindir/cgrulesengd # # Source LSB routines # -SYSLIBFILE=/etc/rc.d/init.d/functions +SYSLIBFILE=/lib/lsb/init-functions OLDSYSLIBFILE=/etc/init.d/functions if [[ -x $SYSLIBFILE ]] ; then # shellcheck disable=SC1090 @@ -53,9 +53,9 @@ else fi # Read in configuration options. -if [[ -f "/etc/cgred.conf" ]] ; then +if [[ -f "/etc/sysconfig/cgred.conf" ]] ; then # shellcheck disable=SC1091 - source /etc/cgred.conf + source /etc/sysconfig/cgred.conf OPTIONS="$NODAEMON $LOG" if [[ -n "$LOG_FILE" ]]; then OPTIONS="$OPTIONS --logfile=$LOG_FILE" @@ -80,13 +80,13 @@ start() { echo -n $"Starting CGroup Rules Engine Daemon: " if [[ -f "$lockfile" ]]; then - echo "$servicename is already running with PID $(cat ${pidfile})" + log_failure_msg "$servicename is already running with PID $(cat ${pidfile})" return 0 fi num=$(grep "cgroup" /proc/mounts | awk '$3=="cgroup"' | wc -l) if [[ "$num" -eq 0 ]]; then echo - echo $"Cannot find cgroups, is cgconfig service running?" + log_failure_msg $"Cannot find cgroups, is cgconfig service running?" return 1 fi daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS @@ -106,7 +106,7 @@ stop() { echo -n $"Stopping CGroup Rules Engine Daemon..." if [[ ! -f $pidfile ]]; then - #log_success_msg + log_success_msg return 0 fi killproc -p $pidfile -TERM "$processname" @@ -152,13 +152,13 @@ case "$1" in echo $"Reloading rules configuration..." kill -s 12 "$(cat ${pidfile})" RETVAL=$? - #if [[ $RETVAL -eq 0 ]] ; then - # log_success_msg "" - #else - # log_failure_msg "" - #fi + if [[ $RETVAL -eq 0 ]] ; then + log_success_msg "" + else + log_failure_msg "" + fi else - echo "$servicename is not running." + log_failure_msg "$servicename is not running." fi ;; *) diff --git a/etc/rc.d/rc.font b/etc/rc.d/rc.font index be204a10f..4008e4247 100644 --- a/etc/rc.d/rc.font +++ b/etc/rc.d/rc.font @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # This selects your default screen font from among the ones in # /usr/share/kbd/consolefonts.