1
0

dump1090.init 3.0 KB

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