61 lines
2.0 KiB
Bash
Executable File
61 lines
2.0 KiB
Bash
Executable File
#!/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
|
|
|
|
TOTALSPACE=$(df / | grep / | awk '{ print $2}')
|
|
TOTALSPACE=$(bc <<< "scale=2; $TOTALSPACE/1024/1024")
|
|
THRESHOLDSPACE=$(bc <<< "scale=2; $TOTALSPACE*.8")
|
|
|
|
echo -e "${idsCL[LightCyan]}Root drive size: ${idsCL[LightGreen]}"$TOTALSPACE"GB${idsCL[Default]}"
|
|
echo -e "${idsCL[LightCyan]}Default thresholf of 80%: ${idsCL[LightGreen]}"$THRESHOLDSPACE"GB${idsCL[Default]}"
|
|
|
|
echo -e -n "${idsCL[LightCyan]}What threshold should we set? Default=80: ${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=80
|
|
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 "0 */3 * * * /usr/local/bin/dsmon")| 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 |