4
0

check_last_update.sh 988 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # LinuxGSM check_last_update.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Checks Lockfile to see when last update happened.
  7. # Will reboot server if instance not rebooted since update.
  8. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. if [ -f "${lockdir}/${selfname}-last-started.lock" ]; then
  10. laststart=$(cat "${lockdir}/${selfname}-last-started.lock")
  11. fi
  12. if [ -f "${lockdir}/last-updated.lock" ]; then
  13. lastupdate=$(cat "${lockdir}/last-updated.lock")
  14. fi
  15. check_status.sh
  16. if [ -f "${lockdir}/last-updated.lock" ] && [ "${status}" != "0" ]; then
  17. if [ ! -f "${lockdir}/${selfname}-last-started.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. alert="update"
  21. alert.sh
  22. command_restart.sh
  23. fn_firstcommand_reset
  24. fi
  25. fi