1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2018 Jean-Michel Lacroix
23 config_get_bool _loctmp
"$section" "$option"
24 if [ -n "$_loctmp" ]; then
25 if [ 1 -eq "$_loctmp" ]; then
26 CONFIGSTR
="$CONFIGSTR${_keystr} "
33 chown
$USER:$GROUP $RUN_D
34 .
/lib
/functions
/network.sh
35 config_load
$CONFIGNAME
36 config_foreach build_config_string darkstat
39 build_config_string
() {
41 config_get interface
$cfg interface
42 network_get_device ifname
"$interface"
43 CONFIGSTR
=" -i $ifname "
44 export_bool syslog
$cfg "--syslog"
45 export_bool verbose
$cfg "--verbose"
46 # We need the --no-daemon parameter as with PROCD the process has to run in the background
47 CONFIGSTR
="$CONFIGSTR--no-daemon "
48 export_bool no_promisc
$cfg "--no-promisc"
49 export_bool no_dns
$cfg "--no-dns"
50 export_bool no_macs
$cfg "--no-macs"
51 export_bool no_lastseen
$cfg "--no-lastseen"
52 config_get httpaddr
$cfg httpaddr
53 CONFIGSTR
="$CONFIGSTR${httpaddr:+-b "$httpaddr"} "
54 config_get httpport
$cfg httpport
55 CONFIGSTR
="$CONFIGSTR${httpport:+-p "$httpport"} "
56 config_get network_netmask
$cfg network_netmask
57 CONFIGSTR
="$CONFIGSTR${network_netmask:+-l "$network_netmask"} "
58 export_bool local_only
$cfg "--local-only"
59 config_get hosts_max
$cfg hosts_max
60 CONFIGSTR
="$CONFIGSTR${hosts_max:+--hosts-max "$hosts_max"} "
61 config_get hosts_keep
$cfg hosts_keep
62 CONFIGSTR
="$CONFIGSTR${ports_keep:+--ports-keep "$ports_keep"} "
63 config_get highest_port
$cfg highest_port
64 CONFIGSTR
="$CONFIGSTR${highest_port:+--highest-port "$highest_port"} "
65 config_get export_file
$cfg export_file
66 CONFIGSTR
="$CONFIGSTR${export_file:+--export "$export_file"} "
67 config_get import_file
$cfg import_file
68 CONFIGSTR
="$CONFIGSTR${import_file:+--import "$import_file"} "
69 config_get daylog_file
$cfg daylog_file
70 CONFIGSTR
="$CONFIGSTR${daylog_file:+--daylog "$daylog_file"} "
71 CONFIGSTR
="$CONFIGSTR--chroot $RUN_D --pidfile $PID_F"
72 # Now that we have the configuration string (CONFIGSTR), let us get the filter (FILTERSTR)
73 config_get network_filter
$cfg network_filter
74 FILTERSTR
="${network_filter:+$network_filter}"
78 procd_add_reload_trigger
$CONFIGNAME
84 procd_set_param
command /usr
/sbin
/$APP
85 procd_append_param
command $CONFIGSTR
86 # Let us check if we have a filter string and apply it if we do
87 if [ "$FILTERSTR" != "" ]; then
88 procd_append_param
command "-f" "$FILTERSTR"