diff --git a/install-dsmon.sh b/install-dsmon.sh index 4802e98..05fd3c2 100755 --- a/install-dsmon.sh +++ b/install-dsmon.sh @@ -8,7 +8,7 @@ source /dev/stdin <<< "$(curl -sL http://scity.xyz/defaultinc)" echo "" echo -e "${idsCL[LightGreen]}DiskSpace-Monitor Installation Script${idsCL[Default]}" -do_with_root $APTFUNC -y install wget curl git mailutils +do_with_root $APTFUNC -y install wget curl git mailutils mysql-client do_with_root set -eu do_with_root git clone https://git.schroedercity.com/voltron/dsmon.git /opt/idssys/dsmon @@ -38,10 +38,23 @@ echo -e -n "${idsCL[LightCyan]}Email address to receive alerts: ${idsCL[Default] read SET_ALERTEMAIL echo "" -echo -e -n "${idsCL[LightCyan]}Server Monitor ID (optional): ${idsCL[Default]}" +echo -e -n "${idsCL[LightCyan]}Server Monitor ID (optional, or type 'new'): ${idsCL[Default]}" read SET_SERVERMONID echo "" +if [ "${SET_SERVERMONID}" = "new" ]; then + echo -e -n "${idsCL[LightCyan]}Server Name: ${idsCL[Default]}" + read ADD_SERVERNAME + echo "" + QRY="USE servermonitor; INSERT INTO hosts (\`host\`) VALUES ('${ADD_SERVERNAME}');" + mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert -e "${QRY}" + QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';" + SET_SERVERMONID=`mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert -e "${QRY}"` + echo -e "${idsCL[LightGreen]}Server successfully added, it was given ID# ${SET_SERVERMONID}${idsCL[Default]}" + echo "" + +fi + if [ "${SET_THRESHOLD}" = "" ]; then SET_THRESHOLD=80 fi