setclock 1.4 KB

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