setclock 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. # Begin /etc/init.d/setclock
  3. ### BEGIN INIT INFO
  4. # Provides: $time
  5. # Required-Start:
  6. # Should-Start: modules
  7. # Required-Stop:
  8. # Should-Stop: $syslog
  9. # Default-Start: S
  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-Default-Start: S25
  15. # X-LFS-Default-Stop: K46
  16. # X-LFS-Provided-By: LFS BLFS
  17. ### END INIT INFO
  18. . /lib/lsb/init-functions
  19. BIN_FILE="/sbin/hwclock"
  20. CONFIGFILE="/etc/sysconfig/clock"
  21. chk_stat
  22. . "${CONFIGFILE}"
  23. CLOCKPARAMS=
  24. case "${UTC}" in
  25. yes|true|1)
  26. CLOCKPARAMS="${CLOCKPARAMS} --utc"
  27. ;;
  28. no|false|0)
  29. CLOCKPARAMS="${CLOCKPARAMS} --localtime"
  30. ;;
  31. esac
  32. case ${1} in
  33. start)
  34. message="Setting system clock..."
  35. ${BIN_FILE} --hctosys ${CLOCKPARAMS} >/dev/null
  36. evaluate_retval standard
  37. ;;
  38. stop)
  39. message="Setting hardware clock..."
  40. ${BIN_FILE} --systohc ${CLOCKPARAMS} >/dev/null
  41. evaluate_retval standard
  42. ;;
  43. *)
  44. echo "Usage: ${0} {start|stop}"
  45. ;;
  46. esac
  47. # End /etc/init.d/setclock