You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
804 B

  1. #!/bin/sh
  2. # ntp hotplug script for travelmate
  3. # Copyright (c) 2020 Dirk Brenken (dev@brenken.org)
  4. # This is free software, licensed under the GNU General Public License v3.
  5. # set (s)hellcheck exceptions
  6. # shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188
  7. trm_init="/etc/init.d/travelmate"
  8. trm_ntpfile="/var/state/travelmate.ntp"
  9. trm_logger="$(command -v logger)"
  10. f_log()
  11. {
  12. local class="${1}" log_msg="${2}"
  13. if [ -x "${trm_logger}" ]
  14. then
  15. "${trm_logger}" -p "${class}" -t "trm-ntp [${$}]" "${log_msg}"
  16. else
  17. printf "%s %s %s\\n" "${class}" "trm-ntp [${$}]" "${log_msg}"
  18. fi
  19. }
  20. if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && \
  21. [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ]
  22. then
  23. > "${trm_ntpfile}"
  24. f_log "info" "get ntp time sync"
  25. "${trm_init}" restart
  26. fi