]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
Add collectd restart to networking/red
authorArne Fitzenreiter <arne_f@ipfire.org>
Mon, 11 May 2009 18:14:40 +0000 (20:14 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Mon, 11 May 2009 18:14:40 +0000 (20:14 +0200)
Change collectd to run modules load only at first start

src/initscripts/init.d/collectd
src/initscripts/init.d/networking/red

index 801db9a4322ecfa476c56148e009cf5244e05e0a..eeaa3860be4cd820331de8e733f45b9b2446c6c7 100644 (file)
@@ -13,6 +13,13 @@ fi
 
 case "$1" in
        start)
+               # If run from init and collectd already started then exit silent
+               if [ "$(basename $0)" != "collectd" ]; then
+                       if [ "$(ps -A | grep " collectd$")" != "" ]; then
+                               exit 0
+                       fi
+               fi
+
                # At first run search for sensors with sensors-detect
                if [ ! -e /etc/sysconfig/lm_sensors ]; then
                        boot_mesg "Searching for Sensors..."
@@ -35,17 +42,21 @@ case "$1" in
                        fi
                fi
 
-               boot_mesg -n "Loading Sensor Modules: "
-               for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
-               modprobe $modul > /dev/null 2>&1;
-                       if [ ${?} = 0 ]; then
-                               boot_mesg -n "$SUCCESS$modul$NORMAL ";
-                       else
-                               boot_mesg -n "$WARNING$modul$NORMAL ";
-                       fi
-               done
-               boot_mesg;
-               echo_ok;
+               # Load sensor modules only first start
+               if [ ! -e /var/lock/sensor_modules ]; then
+                       touch /var/lock/sensor_modules
+                       boot_mesg -n "Loading Sensor Modules: "
+                       for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
+                       modprobe $modul > /dev/null 2>&1;
+                               if [ ${?} = 0 ]; then
+                                       boot_mesg -n "$SUCCESS$modul$NORMAL ";
+                               else
+                                       boot_mesg -n "$WARNING$modul$NORMAL ";
+                               fi
+                       done
+                       boot_mesg;
+                       echo_ok;
+               fi
 
                # Enable sensors plugin if sensors found
                if [ $( sensors 2>&1 | grep "No sensors found!" | wc -l ) == "1" ]; then
index 5843903ebb63abb3e0dbd8621a4d7309eda19454..6f9fcd06457eb7008d1965720ae0e02edb463a9d 100644 (file)
@@ -73,6 +73,10 @@ fi
 
 case "${1}" in
        start)
+               # Stop collectd if running
+               if [ "$(ps -A | grep " collectd$")" != "" ]; then
+                       /etc/rc.d/init.d/collectd stop
+               fi
                if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then
                        boot_mesg "Bringing up the ${DEVICE} interface..."
                        boot_mesg_flush
@@ -87,6 +91,7 @@ case "${1}" in
                        else
                                boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE}
                                echo_failure
+                               /etc/rc.d/init.d/collectd start
                                exit 1
                        fi
                fi
@@ -132,6 +137,7 @@ case "${1}" in
                                else
                                        boot_mesg "dhcpcd already running!" ${WARNING}
                                        echo_warning
+                                       /etc/rc.d/init.d/collectd start
                                        exit 2
                                fi
                        fi
@@ -185,6 +191,7 @@ case "${1}" in
                        if ( ps ax | grep -q [p]ppd ); then 
                            boot_mesg "pppd is still running." ${FAILURE}
                            echo_failure
+                           /etc/init.d/collectd start
                            exit 1
                        fi
                        
@@ -220,6 +227,7 @@ case "${1}" in
                                if [ "$PPP_NIC" == "" ]; then
                                        boot_mesg "No device for red interface given. Check netsetup or dialprofile!" ${FAILURE}
                                        echo_failure
+                                       /etc/rc.d/init.d/collectd start
                                        exit 0
                                fi
                                boot_mesg "Bringing up the $TYPE interface on $PPP_NIC ..."
@@ -357,7 +365,7 @@ case "${1}" in
                        ## Create & Enable vnstat
                        /usr/bin/vnstat -u -i ppp0 -r --enable --force > /dev/null 2>&1
                        /etc/rc.d/init.d/connectd start
-
+                       /etc/rc.d/init.d/collectd start
                fi
                ;;