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.

76 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=61
  3. STOP=00
  4. USE_PROCD=1
  5. PROG=/usr/sbin/kresd
  6. CONFIGFILE=/tmp/kresd/kresd.config
  7. ROOTKEYFILE=/etc/knot-resolver/root.keys
  8. DEFAULT_RUNDIR=/tmp/kresd
  9. USERNAME=kresd
  10. GROUP=kresd
  11. init_header() {
  12. {
  13. echo "--Automatically generated file; DO NOT EDIT"
  14. echo "modules = {"
  15. echo " 'hints > iterate'"
  16. echo " , 'policy'"
  17. if [ "$prefetch" \!= 0 ]; then
  18. echo " , 'stats'"
  19. echo " , predict = {"
  20. echo " window = 30 -- 30 minutes sampling window"
  21. echo " , period = 24*(60/30) -- track last 24 hours"
  22. echo " }"
  23. fi
  24. echo "}"
  25. echo "hints.use_nodata(true)"
  26. } > $CONFIGFILE
  27. }
  28. init_rootkey() {
  29. {
  30. echo "trust_anchors.remove('.')"
  31. echo "trust_anchors.add_file('$ROOTKEYFILE', true)"
  32. } >> $CONFIGFILE
  33. }
  34. modify_rundir() {
  35. local rundir
  36. #create rundir
  37. rundir="$DEFAULT_RUNDIR"
  38. if [ ! -d "$rundir" ]; then
  39. mkdir -p "$rundir"
  40. fi
  41. if id "$1" >/dev/null 2>&1; then
  42. chown -R $USERNAME:$GROUP "$rundir"
  43. fi
  44. }
  45. start_service() {
  46. procd_open_instance
  47. procd_set_param file /etc/config/resolver
  48. procd_set_param command "$PROG"
  49. procd_append_param command --noninteractive
  50. procd_set_param respawn
  51. modify_rundir
  52. init_header
  53. init_rootkey
  54. # knot-resolver config
  55. procd_append_param command -c "$CONFIGFILE"
  56. procd_append_param command -a "0.0.0.0#53"
  57. procd_append_param command -a "::0#53"
  58. procd_set_param nice '-5'
  59. procd_close_instance
  60. }
  61. reload_service()
  62. {
  63. stop
  64. start
  65. }