clock.lua 640 B

123456789101112131415161718192021222324252627282930313233343536
  1. -- clock
  2. local task={
  3. desc="to set clock and timezone",
  4. start=function()
  5. action("mkdir -p /var/lib/hwclock")
  6. cmd="ln -sf /usr/share/zoneinfo/%s /etc/localtime"
  7. action(cmd:format(loconfig.timezone))
  8. cmd="hwclock --directisa --hctosys --utc"
  9. if loconfig.utc then
  10. action(cmd)
  11. else
  12. cmd="hwclock -s --localtime"
  13. action(cmd)
  14. cmd="hwclock -w --localtime"
  15. action(cmd)
  16. end
  17. result=0
  18. return result
  19. end,
  20. stop=function()
  21. cmd="hwclock --systohc %s"
  22. if loconfig.utc then
  23. utcparam="--utc"
  24. else
  25. utcparam="--localtime"
  26. end
  27. action(cmd:format(utcparam))
  28. result=0
  29. return result
  30. end,
  31. }
  32. return task