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.

107 lines
3.0 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2014-2016 OpenWrt.org
  3. START=90
  4. STOP=10
  5. USE_PROCD=1
  6. append_arg() {
  7. local cfg="$1"
  8. local var="$2"
  9. local opt="$3"
  10. local def="$4"
  11. local val
  12. config_get val "$cfg" "$var"
  13. if [ -n "$val" ] || [ -n "$def" ]; then
  14. procd_append_param command "$opt" "${val:-$def}"
  15. fi
  16. }
  17. append_bool() {
  18. local cfg="$1"
  19. local var="$2"
  20. local opt="$3"
  21. local def="$4"
  22. local val
  23. config_get_bool val "$cfg" "$var" "$def"
  24. [ "$val" = 1 ] && procd_append_param command "$opt"
  25. }
  26. start_instance() {
  27. local cfg="$1"
  28. local aux
  29. config_get_bool aux "$cfg" 'disabled' '0'
  30. [ "$aux" = 1 ] && return 1
  31. procd_open_instance
  32. procd_set_param command /usr/bin/dump1090
  33. procd_append_param command "--quiet"
  34. append_arg "$cfg" device_index "--device-index"
  35. append_arg "$cfg" gain "--gain"
  36. append_bool "$cfg" enable_agc "--enable-agc"
  37. append_arg "$cfg" freq "--freq"
  38. append_arg "$cfg" ifile "--ifile"
  39. append_arg "$cfg" iformat "--iformat"
  40. append_bool "$cfg" throttle "--throttle"
  41. append_bool "$cfg" raw "--raw"
  42. append_bool "$cfg" net "--net"
  43. append_bool "$cfg" modeac "--modeac"
  44. append_bool "$cfg" net_only "--net-only"
  45. append_arg "$cfg" net_bind_address "--net-bind-address"
  46. append_arg "$cfg" net_ri_port "--net-ri-port"
  47. append_arg "$cfg" net_ro_port "--net-ro-port"
  48. append_arg "$cfg" net_sbs_port "--net-sbs-port"
  49. append_arg "$cfg" net_bi_port "--net-bi-port"
  50. append_arg "$cfg" net_bo_port "--net-bo-port"
  51. append_arg "$cfg" net_ro_size "--net-ro-size"
  52. append_arg "$cfg" net_ro_interval "--net-ro-interval"
  53. append_arg "$cfg" net_heartbeat "--net-heartbeat"
  54. append_arg "$cfg" net_buffer "--net-buffer"
  55. append_bool "$cfg" net_verbatim "--net-verbatim"
  56. append_bool "$cfg" forward_mlat "--forward-mlat"
  57. append_arg "$cfg" lat "--lat"
  58. append_arg "$cfg" lon "--lon"
  59. append_arg "$cfg" max_range "--max-range"
  60. append_bool "$cfg" fix "--fix"
  61. append_bool "$cfg" no_fix "--no-fix"
  62. append_bool "$cfg" no_crc_check "--no-crc-check"
  63. append_bool "$cfg" phase_enhance "--phase-enhance"
  64. append_bool "$cfg" mlat "--mlat"
  65. append_bool "$cfg" stats "--stats"
  66. append_bool "$cfg" stats_range "--stats-range"
  67. append_arg "$cfg" stats_every "--stats-every"
  68. append_bool "$cfg" onlyaddr "--onlyaddr"
  69. append_bool "$cfg" metric "--metric"
  70. append_bool "$cfg" gnss "--gnss"
  71. append_arg "$cfg" snip "--snip"
  72. append_arg "$cfg" debug "--debug"
  73. append_arg "$cfg" ppm "--ppm"
  74. append_arg "$cfg" html_dir "--html-dir"
  75. append_arg "$cfg" write_json "--write-json"
  76. config_get aux "$cfg" "write_json"
  77. [ -n "$aux" ] && mkdir -p "$aux"
  78. append_arg "$cfg" write_json_every "--write-json-every"
  79. append_arg "$cfg" json_location_accuracy "--json-location-accuracy"
  80. append_bool "$cfg" oversample "--oversample"
  81. append_bool "$cfg" dcfilter "--dcfilter"
  82. append_bool "$cfg" measure_noise "--measure-noise"
  83. config_get_bool aux "$cfg" 'respawn' '0'
  84. [ "$aux" = 1 ] && procd_set_param respawn
  85. procd_close_instance
  86. }
  87. service_triggers() {
  88. procd_add_reload_trigger "dump1090"
  89. }
  90. start_service() {
  91. config_load dump1090
  92. config_foreach start_instance dump1090
  93. }