1
0

softflowd.init 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2007-2011 OpenWrt.org
  3. USE_PROCD=1
  4. START=50
  5. append_bool() {
  6. local section="$1"
  7. local option="$2"
  8. local value="$3"
  9. local _val
  10. config_get_bool _val "$section" "$option" '0'
  11. [ "$_val" -gt 0 ] && append args "$3"
  12. }
  13. append_string() {
  14. local section="$1"
  15. local option="$2"
  16. local value="$3"
  17. local _val
  18. config_get _val "$section" "$option"
  19. [ -n "$_val" ] && append args "$3 $_val"
  20. }
  21. start_instance() {
  22. local section="$1"
  23. config_get_bool enabled "$section" 'enabled' '0'
  24. [ $enabled -gt 0 ] || return 1
  25. config_get pid_file "$section" 'pid_file'
  26. args=""
  27. append_string "$section" 'interface' '-i'
  28. append_string "$section" 'pcap_file' '-r'
  29. append_string "$section" 'timeout' '-t'
  30. append_string "$section" 'max_flows' '-m'
  31. append_string "$section" 'host_port' '-n'
  32. append_string "$section" 'pid_file' '-p'
  33. append_string "$section" 'control_socket' '-c'
  34. append_string "$section" 'export_version' '-v'
  35. append_string "$section" 'hoplimit' '-L'
  36. append_string "$section" 'tracking_level' '-T'
  37. append_string "$section" 'sampling_rate' '-s'
  38. append_bool "$section" track_ipv6 '-6'
  39. procd_open_instance
  40. procd_set_param command /usr/sbin/softflowd -d $args${pid_file:+ -p $pid_file}
  41. procd_set_param respawn
  42. procd_close_instance
  43. }
  44. start_service() {
  45. mkdir -m 0755 -p /var/empty
  46. config_load 'softflowd'
  47. config_foreach start_instance 'softflowd'
  48. }