]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/init.d/collectd
Move ramdisk backup/restore to tmpfs initskript
[ipfire-2.x.git] / src / initscripts / init.d / collectd
1 #!/bin/sh
2 # Begin $rc_base/init.d/collecd
3
4
5 . /etc/sysconfig/rc
6 . $rc_functions
7
8 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
9
10 if [ "$RRDLOG" = '' ]; then
11 RRDLOG=/var/log/rrd
12 fi
13
14 case "$1" in
15 start)
16 if [ ! -e /etc/sysconfig/lm_sensors ]; then
17 boot_mesg "Searching for Sensors..."
18 "yes" | /usr/sbin/sensors-detect > /dev/null
19 evaluate_retval
20
21 if [ ! -e /etc/sysconfig/lm_sensors ]; then
22 echo "#No Sensors detected " > /etc/sysconfig/lm_sensors
23 sed -i -e "s|LoadPlugin sensors|#LoadPlugin sensors|g" /etc/collectd.conf
24 fi
25 fi
26
27 boot_mesg -n "Loading Sensor Modules..."
28 for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
29 modprobe $modul > /dev/null 2>&1;
30 if [ ${?} = 0 ]; then
31 boot_mesg -n "$SUCCESS$modul$NORMAL ";
32 else
33 boot_mesg -n "$FAILURE$modul$NORMAL ";
34 fi
35 done
36 boot_mesg;
37 echo_ok;
38
39 boot_mesg "Starting Collection daemon..."
40 /usr/sbin/collectd -C /etc/collectd.conf
41 evaluate_retval
42 ;;
43 stop)
44 # Save the ramdisk at manual stop but not at shutdown
45 if [ "$(basename $0)" == "collectd" ]; then
46 /etc/init.d/tmpfs backup
47 fi
48 boot_mesg "Stopping Collection daemon..."
49 killproc /usr/sbin/collectd
50 evaluate_retval
51 ;;
52 restart)
53 ${0} stop
54 sleep 1
55 ${0} start
56 ;;
57 status)
58 statusproc /usr/sbin/collectd
59 ;;
60
61 *)
62 echo "Usage: $0 {start|stop|restart|status}"
63 exit 1
64 ;;
65 esac
66
67 # End $rc_base/init.d/collectd