Create install-dsmon.sh

This commit is contained in:
2021-10-03 09:36:02 -05:00
parent 62211abe59
commit 32529246e7

53
install-dsmon.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Wrapper script for install, for easier execution via URL.
source /dev/stdin <<< "$(curl -sL http://scity.xyz/colorsinc)"
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 mailutil
do_with_root set -eu
do_with_root git clone https://git.schroedercity.com/voltron/dsmon.git /opt/idssys/dsmon
do_with_root ln -s /opt/idssys/dsmon/run.sh /usr/local/bin/dsmon
if [ ! -d "/opt/idssys/defaults" ]; then
do_with_root set -eu
do_with_root git clone https://git.schroedercity.com/voltron/iDS-Defaults.git /opt/idssys/defaults
fi
if [ ! -d "/opt/idssys/settings" ]; then
do_with_root mkdir /opt/idssys/settings
fi
echo -e -n "${idsCL[LightCyan]}What threshold should we set? (Default=90(%)): ${idsCL[Default]}"
read SET_THRESHOLD
echo ""
echo -e -n "${idsCL[LightCyan]}Email address to receive alerts: ${idsCL[Default]}"
read SET_ALERTEMAIL
echo ""
if [ "${SET_THRESHOLD}" = "" ]; then
SET_THRESHOLD=90
fi
echo -e "${idsCL[Yellow]}Sending test Alert... ${idsCL[Default]}"
echo "Test Alert" | mail -r DSMon-$(hostname -s)@scity.us -s "Test" $SET_ALERTEMAIL
echo -e "${idsCL[Yellow]}Adding task to crontab... ${idsCL[Default]}"
(crontab -l ; echo "* */3 * * * /opt/idssys/dsmon/diskspace.sh")| crontab -
echo -e "THRESHOLD=$SET_THRESHOLD
ALERT_EMAIL=$SET_ALERTEMAIL
" > /opt/idssys/settings/dsmon.conf
echo ""
echo -e "${idsCL[Yellow]}DiskSpace-Monitor has been Installed. Please make sure this system can send emails using the mail command.${idsCL[Default]}"
echo ""
exit 0