setclock 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin setclock
  4. #
  5. # Description : Setting Linux Clock
  6. #
  7. # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
  8. # DJ Lucas - dj@linuxfromscratch.org
  9. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  10. #
  11. # Version : LFS 7.0
  12. #
  13. ########################################################################
  14. ### BEGIN INIT INFO
  15. # Provides:
  16. # Required-Start:
  17. # Should-Start: modules
  18. # Required-Stop:
  19. # Should-Stop: $syslog
  20. # Default-Start: S
  21. # Default-Stop:
  22. # Short-Description: Stores and restores time from the hardware clock
  23. # Description: On boot, system time is obtained from hwclock. The
  24. # hardware clock can also be set on shutdown.
  25. # X-LFS-Provided-By: LFS BLFS
  26. ### END INIT INFO
  27. . /lib/lsb/init-functions
  28. [ -r /etc/sysconfig/clock ] && . /etc/sysconfig/clock
  29. case "${UTC}" in
  30. yes|true|1)
  31. CLOCKPARAMS="${CLOCKPARAMS} --utc"
  32. ;;
  33. no|false|0)
  34. CLOCKPARAMS="${CLOCKPARAMS} --localtime"
  35. ;;
  36. esac
  37. case ${1} in
  38. start)
  39. hwclock --hctosys ${CLOCKPARAMS} >/dev/null
  40. ;;
  41. stop)
  42. log_info_msg "Setting hardware clock..."
  43. hwclock --systohc ${CLOCKPARAMS} >/dev/null
  44. evaluate_retval
  45. ;;
  46. *)
  47. echo "Usage: ${0} {start|stop}"
  48. exit 1
  49. ;;
  50. esac
  51. exit 0