#!/bin/bash # change directory cd /home/xxxx/chk-espo-version # get the Espo download page, take out all the html and find the line we want. Put it in a .txt file curl -s https://www.espocrm.com/download/ | html2text | grep 'Latest Release EspoCRM' > from_espocrm.txt # set up two variables we will use in the 'if' statement var_from_espocrm=$( cat from_espocrm.txt ) var_prev_version=$( cat prev_version.txt ) # print out for testing #echo "var_from_espocrm " "$var_from_espocrm" #echo "var_prev_version " "$var_prev_version" # check to see what was in the previous version file with this one if [ "$var_from_espocrm" != "$var_prev_version" ] then # empty out the email.txt file > email.txt # set up our email.txt file for sending echo "From: Saturn Server " >> email.txt echo "To: ANC " >> email.txt echo "Subject: New EspoCRM version" >> email.txt echo "---------- " >> email.txt date >> email.txt echo "---------- " >> email.txt echo "Message: " "$var_from_espocrm " >> email.txt echo " " >> email.txt echo "On Saturn: cd /var/www/html/xxxx.net/public_html/espocrm2 " >> email.txt echo "On Saturn: cd /var/www/html/xxxx.net/public_html/espocrm-bak " >> email.txt echo "sudo -u www-data php command.php upgrade " >> email.txt echo " " >> email.txt echo "On anc1, EspoTest:" >> email.txt echo "cd /usr/home/xxx/public_html/xxx.xxx.com/espotest" >> email.txt echo "php command.php upgrade" >> email.txt echo "---end---" >> email.txt # save the new version into a txt file (that we checked above.) echo "$var_from_espocrm" > prev_version.txt # send the email via curl /usr/sbin/ssmtp ac1@answer123.com < email.txt #********************************************************* # Call the 'write' module to write to the files # The first parm is for the msg1 system which writes # to a .txt file. # # The second parm does a touch to the backup-times folder #********************************************************* source /home/anc1/write-msg.sh "espo version FOUND Sat: espo-version.sh" "espo-version-FOUND-Saturn--espo-version-sh.txt" else #********************************************************* # Call the 'write' module to write to the files # The first parm is for the msg1 system which writes # to a .txt file. # # The second parm does a touch to the backup-times folder #********************************************************* source /home/anc1/write-msg.sh "espo version NOT-FOUND Sat: espo-version.sh" "espo-version-NOT-FOUND-Saturn--espo-version-sh.txt" fi # touch a file showing the time we are done. touch chk-espo-version-time.txt