vallumd.init 649 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh /etc/rc.common
  2. START=99
  3. USE_PROCD=1
  4. PROG=/usr/sbin/vallumd
  5. add_topic() {
  6. procd_append_param command -t "$1"
  7. }
  8. start_service() {
  9. local enabled
  10. local mqtt_host
  11. local mqtt_port
  12. config_load "vallumd"
  13. config_get_bool enabled "mqtt" "enabled" 1
  14. [ "$enabled" -gt 0 ] || return 1
  15. config_get mqtt_host "mqtt" "host"
  16. config_get mqtt_port "mqtt" "port"
  17. procd_open_instance
  18. procd_set_param command $PROG
  19. [ -n "$mqtt_host" ] && procd_append_param command -h "$mqtt_host"
  20. [ -n "$mqtt_port" ] && procd_append_param command -p "$mqtt_port"
  21. config_list_foreach mqtt topics add_topic
  22. procd_set_param respawn
  23. procd_close_instance
  24. }