gpt-2741gnac_root_files/_mtdblock3.img.extracted/squashfs-root/bin/shgw_router_reset

106 lines
3.0 KiB
Bash
Executable File

#!/bin/sh
#############################################################################
#
# MCAFEE CONFIDENTIAL
# Copyright ©2018 McAfee, LLC
#
# The source code contained or described herein and all documents related
# to the source code ("Material") are owned by McAfee or its
# suppliers or licensors. Title to the Material remains with McAfee
# or its suppliers and licensors. The Material contains trade
# secrets and proprietary and confidential information of McAfee or its
# suppliers and licensors. The Material is protected by worldwide copyright
# and trade secret laws and treaty provisions. No part of the Material may
# be used, copied, reproduced, modified, published, uploaded, posted,
# transmitted, distributed, or disclosed in any way without McAfee's prior
# express written permission.
#
# No license under any patent, copyright, trade secret or other intellectual
# property right is granted to or conferred upon you by disclosure or
# delivery of the Materials, either expressly, by implication, inducement,
# estoppel or otherwise. Any license under such intellectual property rights
# must be express and approved by McAfee in writing.
#
##############################################################################
. /etc/shgw/shgw.constants
#This script is called after SHGW stop is performed from code
#Do not change this implementation
delete_database() {
${RM} -f ${SHGW_PERSISTANT_DB}
${RM} -f ${TLD_JSON_FILE}
${RM} -f ${BOTNET_FEED_FILE}
${RM} -f ${SHGW_NON_PERSISTANT_DB}
${RM} -f ${SHGW_LOG_FILE}
${RM} -rf ${SHGW_TMPFS_PATH}
${RM} -f ${TEMP_HARD_BLK}
}
delete_shgw_debug_data_files() {
${RM} -f ${SHGW_TMPFS_PATH}/shgw_debug_data*
}
hard_reset() {
delete_database
}
kill_wd_monit_del_db() {
wd_monit_pid=$(${PS} | ${GREP} -i "shgw_wd_monit" | ${GREP} -v "grep" | ${AWK} -v OFS=' ' '{print $1}')
if [ ! -z $wd_monit_pid ]; then
${ECHO} "Stopping monit!"
${KILL} -9 $wd_monit_pid
fi
wd_pid=$(${PS} | ${GREP} -i "shgw_watchdogd" | ${GREP} -v "grep" | ${AWK} -v OFS=' ' '{print $1}')
if [ ! -z $wd_pid ]; then
${ECHO} "Stopping watchdog!"
${KILL} -9 $wd_pid
fi
delete_database
}
soft_reset() {
kill_wd_monit_del_db
${SHGW_STARTUP_SCRIPT} softstart &
}
db_reset() {
kill_wd_monit_del_db
delete_shgw_debug_data_files
#Try to restart N number of times. After that don't restart SHP till reboot
if [ -f ${SHGW_DB_FAIL_COUNT} ]; then
COUNT=`${CAT} ${SHGW_DB_FAIL_COUNT}`
COUNT=$((COUNT+1))
else
COUNT=0
fi
${ECHO} $COUNT > ${SHGW_DB_FAIL_COUNT}
if [ $COUNT -lt $SQL_DB_MAX_FAIL_COUNT ]; then
${SHGW_STARTUP_SCRIPT} db_start &
else
${RM} -f ${SHGW_DB_FAIL_COUNT}
${ECHO} "Max Reset tried. Exit now" && exit 127
fi
}
#Main
reset_type=$1
if [ X"$reset_type" == X"hard" ]; then
${ECHO} "Hard reset called!" >> ${SHGW_STARTUP_STATUS}
hard_reset
elif [ X"$reset_type" == X"soft" ]; then
${ECHO} "Soft reset called!" >> ${SHGW_STARTUP_STATUS}
soft_reset
elif [ X"$reset_type" == X"db_fail" ]; then
${ECHO} "DB reset called!" >> ${SHGW_STARTUP_STATUS}
db_reset
fi