You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006 OpenWrt.org
  3. START=49
  4. USE_PROCD=1
  5. PROG=/usr/sbin/htpdate
  6. validate_htpdate_section() {
  7. uci_validate_section htpdate htpdate "${1}" \
  8. 'server:list(host)' \
  9. 'proxy_host:host' \
  10. 'proxy_port:port:8080' \
  11. 'debug:bool:0' \
  12. 'sanity_check:bool:1' \
  13. 'option:list(string)' \
  14. 'enabled:bool:1'
  15. }
  16. start_service() {
  17. local server proxy debug sanity_check option enabled
  18. validate_htpdate_section htpdate || {
  19. echo "validation failed"
  20. return 1
  21. }
  22. [ "$enabled" = 0 ] && return
  23. procd_open_instance
  24. procd_set_param command "$PROG" -f
  25. [ -n "$proxy" ] && procd_append_param command -P $proxy:$proxy_port
  26. [ "$debug" = "1" ] && procd_append_param command -d
  27. [ "$sanity_check" = "0" ] && procd_append_param command -t
  28. [ -n "$option" ] && procd_append_param command $option
  29. for peer in $server; do
  30. procd_append_param command $peer
  31. done
  32. procd_set_param stdout 1
  33. procd_set_param stderr 1
  34. procd_set_param respawn
  35. procd_close_instance
  36. }
  37. service_triggers() {
  38. procd_add_reload_trigger "htpdate"
  39. procd_add_validation validate_htpdate_section
  40. }