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.

79 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 $url"
  56. /usr/lib/knxd_args $params $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_close_instance
  61. }
  62. stop_service() {
  63. killall knxd
  64. }
  65. reload_service()
  66. {
  67. restart
  68. }
  69. service_triggers()
  70. {
  71. procd_add_reload_trigger knxd
  72. }