From 5e35d373e914444eb7b7cda4c144b7c6024f2f55 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 4 Jul 2023 21:31:03 -0500 Subject: [PATCH] update --- defaults.inc | 6 ++++++ dsmon.sh | 14 +++++++++----- run.sh | 12 ++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/defaults.inc b/defaults.inc index e561474..137e335 100755 --- a/defaults.inc +++ b/defaults.inc @@ -2,6 +2,12 @@ VERS=2.2.10-07042023 +DS_FOLDER=/opt/idssys/dsmon +DS_CRONTAB_FOLDER=/opt/idssys/nodemgmt/crontabs + +[ ! -d ${DS_CRONTAB_FOLDER} ] && mkdir ${DS_CRONTAB_FOLDER} && chmod -Rf 0777 ${DS_CRONTAB_FOLDER} + + SENDNOTICE(){ [ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2} diff --git a/dsmon.sh b/dsmon.sh index 1a1d242..ae1fbc3 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -308,9 +308,13 @@ GETCRONTABS(){ host_name[${hostid}]=$hostname fi done <<< $(MYSQL_PWD="sysmoninsert" mysql -h mysqldb.scity.us -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC") - - read -p "Enter the password for the 'nm_crontab_user' account on MySQL-Manager: " rtpsswd - echo + + if [ "${1}" == "" ]; then + read -p "Enter the password for the 'nm_crontab_user' account on MySQL-Manager: " rtpsswd + echo + else + rtpsswd=${1} + fi for hostid in "${!host_ip[@]}"; do checkhost=$(CHECK_HOST ${host_ip[$hostid]}) @@ -343,14 +347,14 @@ GETCRONTAB(){ nmip= fi - [ "${nmip}" != "" ] && crontab -l | sshpass -p${1} ssh -o 'StrictHostKeyChecking no' nm_crontab_user@${nmip} "cat > /opt/idssys/nodemgmt/crontabs/${hostname}.crontab" + [ "${nmip}" != "" ] && crontab -l | sshpass -p${1} ssh -o 'StrictHostKeyChecking no' nm_crontab_user@${nmip} "cat > ${DS_CRONTAB_FOLDER}/${hostname}.crontab" } case $action in check) CHECK ${2};; setupssh) SETUPSSH;; - get-crontabs) GETCRONTABS;; + get-crontabs) GETCRONTABS ${2};; get-crontab) GETCRONTAB ${2};; run) RUN ${2};; runcmd) RUNCMD ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11};; diff --git a/run.sh b/run.sh index 77513a4..9d3840e 100755 --- a/run.sh +++ b/run.sh @@ -2,8 +2,8 @@ source /opt/idssys/defaults/colors.inc source /opt/idssys/defaults/default.inc -source /opt/idssys/dsmon/config.settings.inc -source /opt/idssys/dsmon/defaults.inc +source ${DS_FOLDER}/config.settings.inc +source ${DS_FOLDER}/defaults.inc if [ "${1}" == "update" ]; then @@ -31,7 +31,7 @@ if [ "${1}" == "update" ]; then git pull >/dev/null 2>&1 git submodule update --remote >/dev/null 2>&1 fi - cd /opt/idssys/dsmon + cd ${DS_FOLDER} if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then if [ "${2}" != "q" ]; then echo -en "\e[1A"; @@ -44,8 +44,8 @@ if [ "${1}" == "update" ]; then git prune >/dev/null 2>&1 git pull >/dev/null 2>&1 git submodule update --remote >/dev/null 2>&1 - /bin/chmod +x /opt/idssys/dsmon/dsmon.sh 2>&1 - source /opt/idssys/dsmon/defaults.inc + /bin/chmod +x ${DS_FOLDER}/dsmon.sh 2>&1 + source ${DS_FOLDER}/defaults.inc if [ "${2}" != "q" ]; then echo -en "\e[1A"; echo -e "\e[0K\r ${idsCL[Green]}Updated to v${VERS}${idsCL[Default]}" @@ -59,7 +59,7 @@ if [ "${1}" == "update" ]; then fi fi -/opt/idssys/dsmon/dsmon.sh "$1" "$2" $3 $4 +${DS_FOLDER}/dsmon.sh "$1" "$2" $3 $4 exit 0