source: packages/utils/bandwidthd/files/bandwidthd.init @ 11149

Last change on this file since 11149 was 11149, checked in by thepeople, 9 years ago

Remove broken patch which was causing the path to be incremented as well as the file name. Add a init script and config file.

File size: 1.5 KB
Line 
1#!/bin/sh /etc/rc.common
2# Copyright (C) 2008 OpenWrt.org
3START=99
4
5config_cb() {
6        local cfg_type="$1"
7        local cfg_name="$2"
8
9        case "$cfg_type" in
10                bandwidthd)
11                        append cfgs "$cfg_name"
12                ;;
13        esac
14}
15
16start() {
17        [ -d /tmp/bandwidthd ] || mkdir -p /tmp/bandwidthd && cp /www/ledgend.gif /tmp/bandwidthd/
18        [ -e /htdocs ] || ln -s /tmp/bandwidthd /htdocs
19        [ -e /www/bandwidthd ] || ln -s /tmp/bandwidthd /www/bandwidthd
20        rm -f /tmp/bandwidthd.conf
21        touch /tmp/bandwidthd.conf
22        [ -e /etc/bandwidthd.conf ] || ln -s /tmp/bandwidthd.conf /etc/bandwidthd.conf
23       
24       
25        config_load bandwidthd
26        for cfg in $cfgs; do
27                config_get interface $cfg interface
28                config_get subnets $cfg interface
29                config_get skip_intervals $cfg skip_intervals
30                config_get graph_cutoff $cfg graph_cutoff
31                config_get promiscuous $cfg promiscuous
32                config_get output_cdf $cfg output_cdf
33                config_get recover_cdf $cfg recover_cdf
34                config_get filter $cfg filter
35                config_get graph $cfg graph
36                config_get meta_refresh $cfg meta_refresh
37                        for subnet in $subnets
38                                echo "subnet $subnet">> /tmp/bandwidthd.conf
39                        done
40                cat >> /tmp/bandwidthd.conf <<EOF
41${interface:+ dev "$interface"}
42${skip_intervals:+ skip_intervals $skip_intervals}
43${graph_cutoff:+ graph_cutoff $graph_cutoff}
44${promiscuous:+ promiscuous $promiscuous}
45${output_cdf:+ output_cdf $output_cdf}
46${recover_cdf:+ recover_cdf $recover_cdf}
47${filter:+ filter $filter}
48${graph:+ graph $graph}
49${meta_refresh:+ meta_refresh $meta_refresh}
50EOF
51        done
52        bandwidthd
53}
54
55stop() {
56        killall bandwidthd
57}
Note: See TracBrowser for help on using the repository browser.