]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/initscripts/init.d/collectd
ramdisk: Backup ramdisks once a night
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / collectd
index 96bd12676cec3e0aed41344556a4249bdd720e91..761e9c3f862e23860f599ce1b1af764eed028812 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/sh
 # Begin $rc_base/init.d/collecd
 
-
 . /etc/sysconfig/rc
 . $rc_functions
 
@@ -13,6 +12,12 @@ fi
 
 case "$1" in
        start)
+               if use_ramdisk; then
+                       boot_mesg "Mounting RRD ramdisk..."
+                       mount_ramdisk "${RRDLOG}"
+                       evaluate_retval
+               fi
+
                # If run from init and collectd alrady started then exit silent
                if [ "$(basename $0)" != "collectd" ]; then
                        if [ "$(ps -A | grep " collectd$")" != "" ]; then
@@ -106,12 +111,9 @@ case "$1" in
                boot_mesg "Stopping Collection daemon..."
                killproc /usr/sbin/collectd
                evaluate_retval
-               # Save the ramdisk at manual stop but not at shutdown
-               if [ "$(basename $0)" == "collectd" ]; then
-                   /etc/init.d/tmpfs backup
-               fi
-               # sync after backup...
-               sync
+
+               # Umount the ramdisk (if any)
+               umount_ramdisk "${RRDLOG}"
                ;;
        restart)
                ${0} stop
@@ -122,8 +124,15 @@ case "$1" in
                statusproc /usr/sbin/collectd
                ;;
 
+       backup)
+               # Backup all data if ramdisk is used
+               if mountpoint "${RRDLOG}" &>/dev/null; then
+                       ${0} restart
+               fi
+               ;;
+
        *)
-               echo "Usage: $0 {start|stop|restart|status}"
+               echo "Usage: $0 {start|stop|restart|status|backup}"
                exit 1
                ;;
 esac