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