]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/collectd
Last step in migration 2.3, now testing and debugging
[people/teissler/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
a332b303
CS
10case "$1" in
11 start)
a3f2742f 12 if [ ! -e /etc/sysconfig/lm_sensors ]; then
1c163c04
CS
13 boot_mesg "Searching for Sensors..."
14 "yes" | /usr/sbin/sensors-detect > /dev/null
15 evaluate_retval
16
17 if [ ! -e /etc/sysconfig/lm_sensors ]; then
18 echo "#No Sensors detected " > /etc/sysconfig/lm_sensors
19 sed -i -e "s|LoadPlugin sensors|#LoadPlugin sensors|g" /etc/collectd.conf
20 fi
a3f2742f
AF
21 fi
22
1c163c04
CS
23 if [ ! -e $RRDLOG.bak/ ]; then
24 mkdir $RRDLOG.bak/
25 fi
26
27 /etc/init.d/collectd restore
28
a3f2742f 29 boot_mesg -n "Loading Sensor Modules..."
438bdd5b 30 for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
1c163c04
CS
31 modprobe $modul > /dev/null 2>&1;
32 if [ ${?} = 0 ]; then
33 boot_mesg -n "$SUCCESS$modul$NORMAL ";
34 else
35 boot_mesg -n "$FAILURE$modul$NORMAL ";
36 fi
a3f2742f
AF
37 done
38 boot_mesg;
39 echo_ok;
40
a332b303
CS
41 boot_mesg "Starting Collection daemon..."
42 /usr/sbin/collectd -C /etc/collectd.conf
43 evaluate_retval
a332b303 44 ;;
a332b303 45 stop)
1c163c04 46 /etc/init.d/collectd backup
a332b303
CS
47 boot_mesg "Stopping Collection daemon..."
48 killproc /usr/sbin/collectd
49 evaluate_retval
50 ;;
a332b303 51 restart)
1c163c04 52 ${0} stop
a332b303 53 sleep 1
1c163c04
CS
54 ${0} start
55 ;;
56 backup)
57 boot_mesg "Save rrd files from ramd..."
58 cp -pR $RRDLOG/* $RRDLOG.bak/
a332b303 59 evaluate_retval
1c163c04
CS
60 ;;
61 restore)
62 boot_mesg "Copying rrd files to ramd..."
63 cp -pR $RRDLOG.bak/* $RRDLOG/
64 ;;
a332b303
CS
65 status)
66 statusproc /usr/sbin/collectd
67 ;;
68
69 *)
70 echo "Usage: $0 {start|stop|restart|status}"
71 exit 1
72 ;;
73esac
74
75# End $rc_base/init.d/collectd