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.

58 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_load_validate htpdate htpdate "$1" "$2" \
  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_htpdate_instance() {
  17. local peer
  18. [ "$2" = 0 ] || {
  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_host" ] && procd_append_param command -P $proxy_host:$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. start_service() {
  38. validate_htpdate_section htpdate start_htpdate_instance
  39. }
  40. service_triggers() {
  41. procd_add_reload_trigger "htpdate"
  42. procd_add_validation validate_htpdate_section
  43. }