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.

80 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 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. # read configuration:
  20. if [ -r /etc/conf/clockspeed ] ; then
  21. . /etc/conf/clockspeed
  22. else
  23. echo "$0: configuration error: unable to read /etc/conf/clockspeed"
  24. exit 1
  25. fi
  26. # clock_pick function:
  27. clock_pick() {
  28. case "${CLOCK_TYPE}" in
  29. ntp|NTP) D_bindir/sntpclock "${CLOCK_IP}"
  30. ;;
  31. tai|TAI) D_bindir/taiclock "${CLOCK_IP}"
  32. ;;
  33. *)
  34. echo "$0: configuration error: CLOCK_TYPE not recognized"
  35. exit 1
  36. ;;
  37. esac
  38. }
  39. # process command:
  40. case "$1" in
  41. a|atto)
  42. echo "Viewing current attoseconds in hardware tick:"
  43. D_bindir/clockview < /var/state/clockspeed/atto
  44. ;;
  45. m|mark)
  46. echo "Obtaining new calibration mark from master server at ${CLOCK_IP}:"
  47. clock_pick | tee /var/state/clockspeed/adjust | D_bindir/clockview
  48. ;;
  49. s|sync)
  50. echo "Setting system clock with master server at ${CLOCK_IP}:"
  51. clock_pick | D_bindir/clockadd && \
  52. clock_pick | D_bindir/clockview
  53. ;;
  54. v|view)
  55. echo "Checking system clock against master server at ${CLOCK_IP} (clockview):"
  56. clock_pick | D_bindir/clockview
  57. ;;
  58. h|help)
  59. cat <<-EOT
  60. clockspeed control:
  61. atto -- inspect current "attoseconds"
  62. mark -- obtain new calibration mark for clockspeed
  63. sync -- set the system clock with master time server
  64. view -- check system clock against master time server
  65. help -- this screen
  66. EOT
  67. exit 0
  68. ;;
  69. *)
  70. echo "Usage: $0 [ a|atto | m|mark | s|sync | v|view | h|help ]"
  71. exit 1
  72. ;;
  73. esac
  74. ### that's all, folks!