#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
# Description: up stop restart wall msg
# Author: chengjike

BASIC_LIB_DIR="/UltraPath_NVMe/install/linuxTools/globalLib"
CHECK_LIBFILE="${BASIC_LIB_DIR}/check_lib.sh"
if [ -f "${CHECK_LIBFILE}" ]
then
    . "${CHECK_LIBFILE}"
else
    echo -e "ERROR: not found the lib[${CHECK_LIBFILE}]."
    exit 1
fi

WARN_MSG_FILE="/opt/UltraPath_NVMe/wall_msg"

process=($(ps -ef | grep ".*/up_plus_restart_warn$" | awk -F " " '{print $2}'))
if [ ${#process[@]} -ne 0 ]; then
    for pro in ${process[@]}
    do
        kill -9 ${pro} > /dev/null 2>&1
        if [ $? -ne 0 ]; then
            basic_trace_operate "FAIL" "1396799568" "stop wall msg" "stop restart wall message" "ʾϢ"
            exit 1
        fi
        basic_trace_operate "SUCCESS" "1396799568" "stop wall msg" "stop restart wall message" "ʾϢ"
        exit 0
    done
fi

basic_trace_msg "INFO" "up_plus_restart_warn is not exist." "verbose"
basic_trace_operate "SUCCESS" "1396799568" "stop wall msg" "stop restart wall message" "ʾϢ"
exit 0
