From f27c16301d91e4c94cca6c2cef05959e59499c6c Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 1 Jun 2025 19:57:46 -0500 Subject: [PATCH] Update install-dsmon.sh --- install-dsmon.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/install-dsmon.sh b/install-dsmon.sh index edeb6e6..6977069 100755 --- a/install-dsmon.sh +++ b/install-dsmon.sh @@ -24,7 +24,17 @@ if [ -d "/opt/idssys/dsmon" ]; then esac fi -do_with_root $APTFUNC install wget curl git mailutils mariadb-client bc +[ "$(ip route | awk '/default/ { print $5 }')" == "link" ] && RNIP=$(ip addr show $(ip route | awk '/1 dev eth0/ { print $5; exit }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) || + RNIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) + +if [[ "${RNIP}" == "10.6.1"* ]]; then + mysqlcmd=mysql +else + mysqlcmd=mariadb +fi + + +do_with_root $APTFUNC install wget curl git mailutils bc do_with_root set -eu do_with_root git clone https://git.schroedercity.com/voltron/dsmon.git /opt/idssys/dsmon @@ -154,9 +164,9 @@ if [ "${SET_SERVERMONID}" = "new" ]; then if [ "${mysqlip}" != "" ]; then QRY="USE servermonitor; INSERT INTO hosts (\`host\`,\`hostname\`,\`ip\`,\`limits\`) VALUES ('${ADD_SERVERNAME}','${ADD_SERVERHOSTNAME}','${SERVERIPS// /}','${thresholdlog[@]}');" - mariadb --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}" + ${mysqlcmd} --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}" QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';" - SET_SERVERMONID=`mariadb --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}"` + SET_SERVERMONID=`${mysqlcmd} --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}"` else echo -e "${idsCL[Red]}Could not connect to MySQL${idsCL[Default]}" fi