#!/bin/bash # ************************************************************************ # * Flex-integrate detectie en notificatie Ben Makkink 24 juli 2020 * # * Script detecteert nwe flex-80.conf en flex-443.conf bestanden als * # * gevolg van een Webconfig update van de HTTPDconfiguratie. * # * De nwe bestanden worden hernoemd naar flex80.new en flex443.new * # * en vervolgens worden deze samen met de eigen directives in * # * /etc/httpd/conf.d/custom_httpd.inc geintegreerd in het webserver * # * configuratiebestand /etc/httpd/conf.d/custom_httpd.conf * # * Er wordt ook een notificatie naar de webadmin gestuurd. * # * Dit script 'flex-integrate' maakt gebruik van de volgende bestanden: * # * - /etc/httpd/conf.d/custom_httpd.inc * # * - /etc/httpd/conf.d/flex80.new * # * - /etc/httpd/conf.d/flex443.new * # * - /usr/local/bin/flex-mail.txt * # ************************************************************************ # * Verifieer dat de voor script benodigde bestanden aanwezig zijn. if [[ ! -f /etc/httpd/conf.d/custom_httpd.inc || ! -f /usr/local/bin/flex-mail.txt ]] then /usr/sbin/sendmail ben@makkink.eu > /etc/httpd/conf.d/custom_httpd.tmp; # Print inhoud flex80.new tot de regel met '' sed -n '/<\/VirtualHost>/q;p' /etc/httpd/conf.d/flex80.new >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate de inhoud van custom_httpd.inc regels 'START' tot en met 'EINDE' sed -n '/START/,/EINDE/p' /etc/httpd/conf.d/custom_httpd.inc >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate van flex80.new van regel met tot einde bestand. sed -n '/<\/VirtualHost>/,$p' /etc/httpd/conf.d/flex80.new >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate infostring printf "\n$str9 \n$str10 \n$str8 \n$str9 \n" >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate inhoud flex443.new tot de regel met 'SSLEngine' sed -n '/SSLEngine/q;p' /etc/httpd/conf.d/flex443.new >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate de inhoud van custom_httpd.inc regels 'START' tot en met 'EINDE' sed -n '/START/,/EINDE/p' /etc/httpd/conf.d/custom_httpd.inc >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate inhoud flex443.new de regel met 'SSLEngine' tot einde bestand sed -n '/SSLEngine/,$p' /etc/httpd/conf.d/flex443.new >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate infostring printf "\n$str9 \n" >> /etc/httpd/conf.d/custom_httpd.tmp; # Concatenate de inhoud van custom_httpd.inc regels 'Eigen HTTPD Directives' tot einde bestand sed -n '/Eigen HTTPD Directives/,$p' /etc/httpd/conf.d/custom_httpd.inc >> /etc/httpd/conf.d/custom_httpd.tmp; # Hernoem custom_httpd.tmp naar custom_httpd.conf en herstart de webserver met de nwe custom_httpd.conf # ----------------------------------------------------------------------------------------------------- mv /etc/httpd/conf.d/custom_httpd.tmp /etc/httpd/conf.d/custom_httpd.conf service httpd restart # stuur notificatie naar de admin met de inhoud van flex-mail.txt # -------------------------------------------------------------- /usr/sbin/sendmail ben@makkink.eu