setclock 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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-Provided-By: LFS BLFS
  15. ### END INIT INFO
  16. . /lib/lsb/init-functions
  17. BIN_FILE="/sbin/hwclock"
  18. CONFIGFILE="/etc/sysconfig/clock"
  19. chk_stat
  20. . "${CONFIGFILE}"
  21. CLOCKPARAMS=
  22. case "${UTC}" in
  23. yes|true|1)
  24. CLOCKPARAMS="${CLOCKPARAMS} --utc"
  25. ;;
  26. no|false|0)
  27. CLOCKPARAMS="${CLOCKPARAMS} --localtime"
  28. ;;
  29. esac
  30. case ${1} in
  31. start)
  32. message="Setting system clock..."
  33. ${BIN_FILE} --hctosys ${CLOCKPARAMS} >/dev/null
  34. evaluate_retval standard
  35. ;;
  36. stop)
  37. message="Setting hardware clock..."
  38. ${BIN_FILE} --systohc ${CLOCKPARAMS} >/dev/null
  39. evaluate_retval standard
  40. ;;
  41. *)
  42. echo "Usage: ${0} {start|stop}"
  43. ;;
  44. esac
  45. # End /etc/init.d/setclock