4
0

check_last_update.sh 808 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. # LinuxGSM check_last_update.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Checks lock file to see when last update happened.
  6. # Will reboot server if instance not rebooted since update.
  7. if [ -f "${lockdir}/${selfname}-laststart.lock" ]; then
  8. laststart=$(cat "${lockdir}/${selfname}-laststart.lock")
  9. fi
  10. if [ -f "${lockdir}/lastupdate.lock" ]; then
  11. lastupdate=$(cat "${lockdir}/lastupdate.lock")
  12. fi
  13. check_status.sh
  14. if [ -f "${lockdir}/lastupdate.lock" ]&&[ "${status}" != "0" ]; then
  15. if [ ! -f "${lockdir}/${selfname}-laststart.lock" ]||[ "${laststart}" -lt "${lastupdate}" ]; then
  16. fn_print_info "${selfname} has not been restarted since last update"
  17. fn_script_log_info "${selfname} has not been restarted since last update"
  18. command_restart.sh
  19. fi
  20. fi