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.

77 lines
2.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2016 OpenWrt.org
  3. START=98
  4. STOP=20
  5. PROG=/usr/bin/knxd
  6. USE_PROCD=1
  7. append_bool() {
  8. local section="$1"
  9. local option="$2"
  10. local value="$3"
  11. local _loctmp
  12. local default="$4"
  13. config_get_bool _loctmp "$section" "$option"
  14. [ -z "$_loctmp" ] && _loctmp="$default"
  15. [ "$_loctmp" -gt 0 ] && append params "--$value"
  16. }
  17. append_parm() {
  18. local section="$1"
  19. local option="$2"
  20. local switch="$3"
  21. local _loctmp
  22. local default="$4"
  23. config_get _loctmp "$section" "$option"
  24. [ -z "$_loctmp" ] && _loctmp="$default"
  25. [ -z "$_loctmp" ] && return 0
  26. append params "--$switch=$_loctmp"
  27. }
  28. start_service() {
  29. local options url
  30. config_load knxd
  31. append_parm args eibaddr "eibaddr" "0.0.1"
  32. append_parm args client_addrs "client-addrs" "0.0.2:10"
  33. append_parm args layer2 "layer2"
  34. append_bool args GroupCache "GroupCache" 0
  35. #append_parm args daemon "daemon" "/var/log/knxd.log"
  36. append_parm args error "error" # "5"
  37. append_parm args listen_tcp "listen-tcp" "6720"
  38. append_parm args Interface "Interface" # "eth0"
  39. append_parm args send_delay "send-delay" # "50"
  40. append_parm args Name "Name" "OpenWrt"
  41. append_bool args no_monitor "no-monitor" 0
  42. append_bool args Routing "Routing" 0
  43. append_bool args tpuarts_ack_all_group "tpuarts-ack-all-group" 0
  44. append_bool args tpuarts_ack_all_individual "tpuarts-ack-all-individual" 0
  45. append_bool args tpuarts_disch_reset "tpuarts-disch-reset" 0
  46. append_bool args Tunnelling "Tunnelling" 1
  47. append_bool args Discovery "Discovery" 1
  48. append_parm args Server "Server" "224.0.23.12"
  49. append_parm args listen_local "listen-local" "/var/run/knxd"
  50. append_parm args trace "trace" # "7"
  51. config_get url args url
  52. if [ "$url" == "usb:" ] ; then
  53. url="usb:""$(findknxusb | tail -n1 | sed -e 's/device: \([0-9]:[0-9]:[0-9]\):[0-9].*/\1/')"
  54. fi
  55. echo "/usr/lib/knxd_args $params -b $url"
  56. /usr/lib/knxd_args $params -b $url > /tmp/etc/knxd.ini
  57. procd_open_instance
  58. procd_set_param command $PROG "/tmp/etc/knxd.ini"
  59. procd_set_param respawn
  60. procd_set_param stdout 1
  61. procd_set_param stderr 1
  62. procd_close_instance
  63. }
  64. reload_service()
  65. {
  66. restart
  67. }
  68. service_triggers()
  69. {
  70. procd_add_reload_trigger knxd
  71. }