setclock 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # Begin $RC_BASE/init.d/setclock
  3. ### BEGIN INIT INFO
  4. # Provides: hwclock
  5. # Required-Start:
  6. # Should-Start: modules
  7. # Required-Stop:
  8. # Should-Stop: $syslog
  9. # Default-Start:
  10. # Default-Stop:
  11. # Short-Description: Stores and restores time from the hardware clock
  12. # Description: On boot, system time is obtained from hwclock. The
  13. # hardware clock can also be set on shutdown.
  14. # X-LFS-Provided-By: LFS BLFS
  15. ### END INIT INFO
  16. . /lib/lsb/init-functions
  17. BIN_FILE="/sbin/hwclock"
  18. chk_stat
  19. case "${UTC}" in
  20. yes|true|1)
  21. CLOCKPARAMS="${CLOCKPARAMS} --utc"
  22. ;;
  23. no|false|0)
  24. CLOCKPARAMS="${CLOCKPARAMS} --localtime"
  25. ;;
  26. esac
  27. case ${1} in
  28. start)
  29. message="Setting system clock..."
  30. ${BIN_FILE} --hctosys ${CLOCKPARAMS} >/dev/null
  31. evaluate_retval standard
  32. ;;
  33. stop)
  34. message="Setting hardware clock..."
  35. ${BIN_FILE} --systohc ${CLOCKPARAMS} >/dev/null
  36. evaluate_retval standard
  37. ;;
  38. *)
  39. echo "Usage: ${0} {start|stop}"
  40. ;;
  41. esac
  42. # End $RC_BASE/init.d/setclock