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