Inital commit

This commit is contained in:
2021-01-08 11:06:07 +01:00
commit 8f9fb4fd5c
13 changed files with 368 additions and 0 deletions

76
conf.sh Normal file
View File

@@ -0,0 +1,76 @@
mrepo=https://git.ictmaatwerk.com/VPS-scripts/Monit
mbranch=main
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
monitconf=/etc/monit/monitrc
#ServiceDefenition
monitMysqlserv=mysql
monitApachepro=apache
monitPhpSock=/var/run/php/"$phpFPMService".sock
monitPhpPid=/var/run/php/"$phpFPMService".pid
monitPhpPro=$phpFPMService
/var/run/php/PHPSRV.sock
elif [ "$shortdist" = "el8" ]; then
monitconf=/etc/monitrc
rm -rf /etc/monit.d
#ServiceDefenition
monitMysqlserv=mysqld
monitApachepro=httpd
monitPhpSock=/var/opt/remi/php"${phpver//.}"/run/php-fpm/www.sock
monitPhpPid=/var/opt/remi/php"${phpver//.}"/run/php-fpm/php-fpm.pid
monitPhpPro=php-fpm
fi
systemctl stop monit
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/monitrc -o $monitconf
if [ ! -d "/var/lib/monit" ] ; then mkdir -p /var/lib/monit; fi
mkdir -p /etc/monit/conf.d
SysServiceList=$(systemctl list-units --full -all)
#SystemMonitor
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/system.conf -o /etc/monit/conf.d/system.conf
#sshd
if echo "$SysServiceList" | grep -Fq 'sshd'; then
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/sshd.conf -o /etc/monit/conf.d/sshd.conf
fi
#Fail2Ban
if echo "$SysServiceList" | grep -Fq 'fail2ban'; then
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/fail2ban.conf -o /etc/monit/conf.d/fail2ban.conf
fi
if echo "$SysServiceList" | grep -Fq "$monitMysqlserv"; then
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/mysql.conf -o /etc/monit/conf.d/mysql.conf
sed -i "s/MYSQLserv/$monitMysqlservice/g" /etc/monit/conf.d/mysql.conf
fi
if echo "$SysServiceList" | grep -Fq 'nginx'; then
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/nginx.conf -o /etc/monit/conf.d/nginx.conf
fi
if echo "$SysServiceList" | grep -Fq "$phpFPMService" && test ! -z "$phpFPMService"; then
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/php-fpm.conf -o /etc/monit/conf.d/php"$phpver".conf
sed -i "s/PHPpid/$monitPhpPid/g" /etc/monit/conf.d/php"$phpver".conf
sed -i "s/PHPpro/$monitPhpPro/g" /etc/monit/conf.d/php"$phpver".conf
sed -i "s/PHPsrv/$phpFPMService/g" /etc/monit/conf.d/php"$phpver".conf
sed -i "s/PHPsock/$monitPhpSock/g" /etc/monit/conf.d/php"$phpver".conf
fi
if echo "$SysServiceList" | grep -Fq "$apacheService" && test ! -z "$apacheService"; then
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/monit/apache.conf -o /etc/monit/conf.d/apache.conf
sed -i "s/APAserv/$apacheService/g" /etc/monit/conf.d/apache.conf
sed -i "s/APApro/$monitApachepro/g" /etc/monit/conf.d/apache.conf
fi
systemctl enable monit
systemctl start monit
unset monitMysqlserv monitApachepro monitPhpSock monitPhpPid monitPhpPro monitconf