diff --git a/monitoring/altinea_monitoring_request.sh b/monitoring/altinea_monitoring_request.sh old mode 100644 new mode 100755 index 23eb848..575c8c5 --- a/monitoring/altinea_monitoring_request.sh +++ b/monitoring/altinea_monitoring_request.sh @@ -10,11 +10,6 @@ DEBUG() { # Define VPN interface name VPNIF="vpnaltinea" -if ! [ -x "$(command -v sendEmail)" ]; then - echo "sendEmail could not be found, I'll install it for you" - apt install -y sendemail -fi - if ! [ -x "$(command -v jq)" ]; then echo "jq could not be found, I'll install it for you" apt install -y jq @@ -65,28 +60,38 @@ else fi -# Generate first part on the command -COMMAND="sendEmail -f noc@altinea.fr -u Nouvelle demande de monitoring -t support@altinea.fr -m Nouvelle IP à monitorer :\n"`hostname -f`"\n" +#RANDOMNB=`date +%S | grep -o .$ | sed s/0/10/` +#ARTURL="https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/ascii/$RANDOMNB.txt" +#ASCIIART=`curl -s $ARTURL` +ASCIIART="" -# Add IPv4 if found -if [ -z "$IP4" ]; then - DEBUG echo "Sorry we're unable to find a routable IPv4 address, sorry !" -else - COMMAND="$COMMAND IPv4 : $IP4\n" -fi +printf "Password for sendmail@it-nea.eu: " +stty -echo +IFS= read -r mailpassword +stty echo +printf "\n" -# Add IPv6 if found -if [ -z "$IP6" ]; then - DEBUG echo "Sorry we're unable to find a routable IPv6 address, sorry !" -else - COMMAND="$COMMAND IPv6 : $IP6\n" -fi +AUTHLOGIN=`/usr/bin/echo -ne "\0sendmail@it-nea.eu\0$mailpassword"|base64` -COMMAND="$COMMAND -o tls=no -o message-charset=UTF-8 -s zpush.altinea.fr" +# Generate first part on the command +/usr/bin/echo "ehlo `hostname -f` +AUTH PLAIN +$AUTHLOGIN +MAIL FROM: noc@altinea.fr +RCPT TO: support@altinea.fr +DATA +From: noc@altinea.fr +To: support@altinea.fr +Subject: Nouvelle demande de monitoring +Content-Type: text/html; charset=UTF-8 -# And run the request by mail -if [ "$_DRYRUN" = "on" ]; then - echo $COMMAND -else - $COMMAND -fi +Nouvelle IP à monitorer : `hostname -f` +IPv4 : $IP4 +IPv6 : $IP6 + +$ASCIIART +. +quit +" |openssl s_client -connect smtp.it-nea.eu:465 -quiet -verify_quiet > /dev/null || err_exit + +exit 1;