summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-statistics/root/etc/init.d/luci_statistics
blob: 936f3a63c37aab08588f7c3966fe296a0ee67ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh /etc/rc.common
START=79

start() {
	### replace shipped config with symlink
	if [ ! -L /etc/collectd.conf ]; then
		test -f /etc/collectd.conf && mv /etc/collectd.conf /etc/collectd.conf.bak
		ln -s /var/etc/collectd.conf /etc/collectd.conf
	fi

	### create config
	mkdir -p /var/etc
	/usr/bin/stat-genconfig > /var/etc/collectd.conf

	### prepare rrdimg directory
	if [ -f /etc/config/lucid ] && [ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && \
	   [ "$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)" != "$(uci get lucid.statistics.physical 2>/dev/null)" ]; then
		uci set lucid.statistics.physical=$(uci get luci_statistics.rrdtool.image_path)
		uci commit lucid
		/etc/init.d/lucid restart
	fi

	### workaround broken permissions on /tmp
	chmod 1777 /tmp
}

restart() {
	### regenerate config / prepare environment
	start

	### restart collectd
	/etc/init.d/collectd restart
}