init-functions | 87 +++++++++++++++------------------------------------------- 1 file changed, 22 insertions(+), 65 deletions(-) diff --git a/init-functions b/init-functions index 4d99df0..e5e2fa1 100644 --- a/init-functions +++ b/init-functions @@ -173,47 +173,40 @@ status_of_proc () { status="0" pidofproc $pidfile $daemon >/dev/null || status="$?" if [ "$status" = 0 ]; then - log_success_msg "$name is running" + echo "$name is running" return 0 else - log_failure_msg "$name is not running" + echo "$name is not running" return $status fi } -log_use_fancy_output () { - TPUT=/usr/bin/tput - EXPR=/usr/bin/expr - if [ -t 1 ] && [ "x$TERM" != "" ] && [ "x$TERM" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then - [ -z $FANCYTTY ] && FANCYTTY=1 || true +alt_lsb_log_message() { + + if [ $# -lt 2 ]; then + return 0 + fi + + if [ -x "/etc/altlinux-lsb/lsb_log_message" ]; then + /etc/altlinux-lsb/lsb_log_message "$@" else - FANCYTTY=0 + shift + echo "$@" fi - case "$FANCYTTY" in - 1|Y|yes|true) true;; - *) false;; - esac + + return 0 } log_success_msg () { - if [ -n "${1:-}" ]; then - log_begin_msg $@ - fi - log_end_msg 0 + alt_lsb_log_message success "$@" } log_failure_msg () { - if [ -n "${1:-}" ]; then - log_begin_msg $@ - fi - log_end_msg 1 || true + alt_lsb_log_message failure "$@" } log_warning_msg () { - if [ -n "${1:-}" ]; then - log_begin_msg $@ - fi - log_end_msg 255 || true + alt_lsb_log_message warning "$@" } # @@ -255,7 +248,6 @@ log_daemon_msg () { if [ -z "${1:-}" ]; then return 1 fi - log_daemon_msg_pre "$@" if [ -z "${2:-}" ]; then echo -n "$1:" @@ -263,7 +255,6 @@ log_daemon_msg () { fi echo -n "$1: $2" - log_daemon_msg_post "$@" } # #319739 @@ -298,28 +289,13 @@ log_end_msg () { retval=$1 - log_end_msg_pre "$@" - - # Only do the fancy stuff if we have an appropriate terminal - # and if /usr is already mounted - if log_use_fancy_output; then - RED=`$TPUT setaf 1` - YELLOW=`$TPUT setaf 3` - NORMAL=`$TPUT op` - else - RED='' - YELLOW='' - NORMAL='' - fi - if [ $1 -eq 0 ]; then - echo "." + alt_lsb_log_message success "." elif [ $1 -eq 255 ]; then - /bin/echo -e " ${YELLOW}(warning).${NORMAL}" + alt_lsb_log_message warning "." else - /bin/echo -e " ${RED}failed!${NORMAL}" + alt_lsb_log_message failure "." fi - log_end_msg_post "$@" return $retval } @@ -336,7 +312,6 @@ log_action_cont_msg () { } log_action_end_msg () { - log_action_end_msg_pre "$@" if [ -z "${2:-}" ]; then end="." else @@ -344,26 +319,8 @@ log_action_end_msg () { fi if [ $1 -eq 0 ]; then - echo "done${end}" + alt_lsb_log_message success "${end}" else - if log_use_fancy_output; then - RED=`$TPUT setaf 1` - NORMAL=`$TPUT op` - /bin/echo -e "${RED}failed${end}${NORMAL}" - else - echo "failed${end}" - fi + alt_lsb_log_message failure "${end}" fi - log_action_end_msg_post "$@" } - -# Hooks for /etc/lsb-base-logging.sh -log_daemon_msg_pre () { :; } -log_daemon_msg_post () { :; } -log_end_msg_pre () { :; } -log_end_msg_post () { :; } -log_action_end_msg_pre () { :; } -log_action_end_msg_post () { :; } - -FANCYTTY= -[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true