OpenSDE Packages Database (without history before r20070)
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.

83 lines
2.1 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../clockspeed/clockctl.sh
  6. # Copyright (C) 2008 - 2010 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. # Based on: http://www.thedjbway.org/clockspeed/clockctl
  16. # interface to djb clockspeed (0.62)
  17. # wcm, 2003.11.26 - 2003.11.26
  18. # ===
  19. die() {
  20. echo "$0: $*" >&2
  21. exit 1
  22. }
  23. # read configuration:
  24. if [ -r /etc/conf/clockspeed ] ; then
  25. . /etc/conf/clockspeed
  26. else
  27. die "configuration error: unable to read /etc/conf/clockspeed"
  28. fi
  29. # clock_pick function:
  30. clock_pick() {
  31. case "${CLOCK_TYPE}" in
  32. ntp|NTP) D_bindir/sntpclock "${CLOCK_IP}"
  33. ;;
  34. tai|TAI) D_bindir/taiclock "${CLOCK_IP}"
  35. ;;
  36. *)
  37. die "configuration error: CLOCK_TYPE not recognized"
  38. ;;
  39. esac
  40. }
  41. # process command:
  42. case "$1" in
  43. a|atto)
  44. echo "Viewing current attoseconds in hardware tick:"
  45. D_bindir/clockview < /var/state/clockspeed/atto
  46. ;;
  47. m|mark)
  48. echo "Obtaining new calibration mark from master server at ${CLOCK_IP}:"
  49. clock_pick | tee /var/state/clockspeed/adjust | D_bindir/clockview
  50. ;;
  51. s|sync)
  52. echo "Setting system clock with master server at ${CLOCK_IP}:"
  53. clock_pick | D_bindir/clockadd && \
  54. clock_pick | D_bindir/clockview
  55. ;;
  56. v|view)
  57. echo "Checking system clock against master server at ${CLOCK_IP} (clockview):"
  58. clock_pick | D_bindir/clockview
  59. ;;
  60. h|help)
  61. cat <<-EOT
  62. clockspeed control:
  63. atto -- inspect current "attoseconds"
  64. mark -- obtain new calibration mark for clockspeed
  65. sync -- set the system clock with master time server
  66. view -- check system clock against master time server
  67. help -- this screen
  68. EOT
  69. exit 0
  70. ;;
  71. *)
  72. echo "Usage: $0 [ a|atto | m|mark | s|sync | v|view | h|help ]"
  73. exit 1
  74. ;;
  75. esac
  76. ### that's all, folks!