]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/collectd
Fixed some minor errors
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / collectd
CommitLineData
a332b303
CS
1#!/bin/sh
2# Begin $rc_base/init.d/collecd
3
4
5. /etc/sysconfig/rc
6. $rc_functions
7
1c163c04
CS
8eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
9
f6b79dd2
CS
10if [ "$RRDLOG" = '' ]; then
11 RRDLOG=/var/log/rrd
12fi
13
a332b303
CS
14case "$1" in
15 start)
a3f2742f 16 if [ ! -e /etc/sysconfig/lm_sensors ]; then
1c163c04
CS
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
a3f2742f
AF
25 fi
26
1c163c04
CS
27 if [ ! -e $RRDLOG.bak/ ]; then
28 mkdir $RRDLOG.bak/
29 fi
30
31 /etc/init.d/collectd restore
32
a3f2742f 33 boot_mesg -n "Loading Sensor Modules..."
438bdd5b 34 for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
1c163c04
CS
35 modprobe $modul > /dev/null 2>&1;
36 if [ ${?} = 0 ]; then
37 boot_mesg -n "$SUCCESS$modul$NORMAL ";
38 else
39 boot_mesg -n "$FAILURE$modul$NORMAL ";
40 fi
a3f2742f
AF
41 done
42 boot_mesg;
43 echo_ok;
44
a332b303
CS
45 boot_mesg "Starting Collection daemon..."
46 /usr/sbin/collectd -C /etc/collectd.conf
47 evaluate_retval
a332b303 48 ;;
a332b303 49 stop)
1c163c04 50 /etc/init.d/collectd backup
a332b303
CS
51 boot_mesg "Stopping Collection daemon..."
52 killproc /usr/sbin/collectd
53 evaluate_retval
54 ;;
a332b303 55 restart)
1c163c04 56 ${0} stop
a332b303 57 sleep 1
1c163c04
CS
58 ${0} start
59 ;;
60 backup)
61 boot_mesg "Save rrd files from ramd..."
62 cp -pR $RRDLOG/* $RRDLOG.bak/
a332b303 63 evaluate_retval
1c163c04
CS
64 ;;
65 restore)
2d0adb74
CS
66 if [ -e $RRDLOG.bak ];then
67 boot_mesg "Copying rrd files to ramd..."
68 cp -pR $RRDLOG.bak/* $RRDLOG/
69 fi
1c163c04 70 ;;
a332b303
CS
71 status)
72 statusproc /usr/sbin/collectd
73 ;;
74
75 *)
76 echo "Usage: $0 {start|stop|restart|status}"
77 exit 1
78 ;;
79esac
80
81# End $rc_base/init.d/collectd