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.

74 lines
1.7 KiB

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