Rework LuCI build system
[project/luci.git] / applications / luci-app-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 [ -f /etc/config/lucid ] && [ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && \
17 [ "$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)" != "$(uci get lucid.statistics.physical 2>/dev/null)" ]; then
18 uci set lucid.statistics.physical=$(uci get luci_statistics.rrdtool.image_path)
19 uci commit lucid
20 /etc/init.d/lucid restart
21 fi
22
23 ### workaround broken permissions on /tmp
24 chmod 1777 /tmp
25 }
26
27 restart() {
28 ### regenerate config / prepare environment
29 start
30
31 ### restart collectd
32 /etc/init.d/collectd restart
33 }