check_last_update.sh 877 B

123456789101112131415161718192021222324
  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. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. if [ -f "${lockdir}/${selfname}-laststart.lock" ]; then
  9. laststart=$(cat "${lockdir}/${selfname}-laststart.lock")
  10. fi
  11. if [ -f "${lockdir}/lastupdate.lock" ]; then
  12. lastupdate=$(cat "${lockdir}/lastupdate.lock")
  13. fi
  14. check_status.sh
  15. if [ -f "${lockdir}/lastupdate.lock" ]&&[ "${status}" != "0" ]; then
  16. if [ ! -f "${lockdir}/${selfname}-laststart.lock" ]||[ "${laststart}" -lt "${lastupdate}" ]; then
  17. fn_print_info "${selfname} has not been restarted since last update"
  18. fn_script_log_info "${selfname} has not been restarted since last update"
  19. command_restart.sh
  20. fi
  21. fi