#! /bin/bash # script checks ES Sync Control Script . /usr/src/k_framework/main.sh k_config_details # ---- VARS ----- VERSION="1.1.0" SCRIPT_NAME="ES Sync Control Script Check" TEST=0 # 1 - do not execute changes # ---- FUNCTIONS ----- # ---- MAIN ----- k_start if [ "$TEST" == "1" ]; then report "***** TEST MODE ON. Changes will not be applied *****" 8 fi if [ "$SYSTEM_CONFIG_DIR" == "m2" ]; then ES_SRC_DIR=/usr/src/m2/elasticsearch else ES_SRC_DIR=/usr/src/mor/sh_scripts/elasticsearch fi SETTING="ES_PRESENT"; if [[ ${!SETTING} == "" ]]; then report "$SETTING is empty" 1; EXIT_CODE=1; fi ES_SYNC_CONTROL=`sed 's/ //g' $SYSTEM_CONFIG | grep es_sync_control | awk -F"=" '{print $2}' | xargs`; if [[ $ES_SYNC_CONTROL == "" ]]; then report "es_sync_control not active in $SYSTEM_CONFIG" 1 report " Put: es_sync_control = 1 (or 0 if you want to disable it)" 1 EXIT_CODE=1 elif [[ $ES_SYNC_CONTROL == "0" ]]; then report "es_sync_control disabled. Really you want like this?" 2 k_exit 0 fi ES_SYNC_CHECK_PERIOD=`sed 's/ //g' $SYSTEM_CONFIG | grep es_sync_check_period | awk -F"=" '{print $2}' | xargs`; if [[ $ES_SYNC_CHECK_PERIOD == "" ]]; then report "es_sync_check_period not active in $SYSTEM_CONFIG" 1 report " Put: es_sync_check_period = 31" 1 EXIT_CODE=1 else if [[ $ES_SYNC_CHECK_PERIOD != 31 ]]; then report "es_sync_check_period [$ES_SYNC_CHECK_PERIOD] != 31 in $SYSTEM_CONFIG" 2 fi fi if [ ! -f /usr/local/$SYSTEM_CONFIG_DIR/es_sync_control.sh ]; then report "/usr/local/$SYSTEM_CONFIG_DIR/es_sync_control.sh missing" 1 report " $ES_SRC_DIR/es_sync_control_install.sh" fix EXIT_CODE=1 fi if [ ! -f /etc/cron.d/${SYSTEM_CONFIG_DIR}_es_sync_control ]; then report "/etc/cron.d/${SYSTEM_CONFIG_DIR}_es_sync_control missing" 1 report " $ES_SRC_DIR/es_sync_control_install.sh" fix EXIT_CODE=1 fi if [ ! -f /usr/local/$SYSTEM_CONFIG_DIR/es_sync_control_hourly.sh ]; then report "/usr/local/$SYSTEM_CONFIG_DIR/es_sync_control_hourly.sh missing" 1 report " $ES_SRC_DIR/es_sync_control_install.sh" fix EXIT_CODE=1 fi if [ ! -f /etc/cron.d/${SYSTEM_CONFIG_DIR}_es_sync_control_hourly ]; then report "/etc/cron.d/${SYSTEM_CONFIG_DIR}_es_sync_control_hourly missing" 1 report " $ES_SRC_DIR/es_sync_control_install.sh" fix EXIT_CODE=1 fi k_exit $EXIT_CODE