File: //scripts/checkMailServer.sh
#!/bin/bash
URL="https://mail.karmanye.in:8443/sso/login"
keyword="Mailu-Admin"
if curl -sSf --max-time 5 "$URL" | grep "$keyword"
then
# if the keyword is in the content
echo "Mail Server is working fine"
else
echo "Resolving Mail Server Issue"
cd /extra/mailu
/usr/local/bin/docker-compose down
/usr/sbin/service docker restart
/usr/local/bin/docker-compose up -d --build --remove-orphans
curl --location --request POST 'https://marketing.wp.karmanye.in/api/Karmanye/send-message' --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header 'Authorization: Bearer $2b$10$f7yAQHm3Y1eOxs92aiEJ9eohJ0AdUQ2YwXxUARzk3sVLgKIVw0k2q' -d '{ "phone": "919033595842", "message": "*Mail Server not working, Restarting Service*"}'
fi