contrib/package: make luci-app-statistics depend on a few collectd plugins
[project/luci.git] / applications / luci-statistics / root / etc / init.d / luci_statistics
1 #!/bin/sh /etc/rc.common
2 START=79
3
4 start() {
5         ### replace shipped config with symlink
6         if [ ! -L /etc/collectd.conf ]; then
7                 test -f /etc/collectd.conf && mv /etc/collectd.conf /etc/collectd.conf.bak
8                 ln -s /var/etc/collectd.conf /etc/collectd.conf
9         fi
10
11         ### create config
12         mkdir -p /var/etc
13         /usr/bin/stat-genconfig > /var/etc/collectd.conf
14
15         ### prepare rrdimg directory
16         if [ ! -L /www/rrdimg ]; then
17                 imagepath="$(uci get luci_statistics.rrdtool.image_path)"
18                 ln -s ${imagepath:-/tmp/rrdimg}/ /www/rrdimg
19         fi
20
21         ### flush LuCI index cache
22         test -f /var/luci-indexcache && rm /var/luci-indexcache
23
24         ### workaround broken permissions on /tmp
25         chmod 1777 /tmp
26 }
27
28 restart() {
29         ### regenerate config / prepare environment
30         start
31
32         ### restart collectd
33         /etc/init.d/collectd restart
34 }