check_last_update.sh 947 B

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