From 1bc535b6c65eeca5415fbe59920a6fff3a3a87af Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Thu, 2 Oct 2008 07:41:52 +0200 Subject: [PATCH] Move ramdisk backup/restore to tmpfs initskript --- config/cron/crontab | 2 +- config/rootfiles/updater/update.sh | 2 +- src/initscripts/init.d/collectd | 13 +------------ src/initscripts/init.d/tmpfs | 20 ++++++++++++++++---- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/config/cron/crontab b/config/cron/crontab index 2d7552bedb..82d2e078fc 100644 --- a/config/cron/crontab +++ b/config/cron/crontab @@ -22,7 +22,7 @@ HOME=/ # Make some nice graphs */5 * * * * /usr/local/bin/makegraphs >/dev/null -* 05 * * * /etc/init.d/collectd backup >/dev/null +* 05 * * * /etc/init.d/tmpfs backup >/dev/null # Force update the dynamic dns registration once a week # Force update even if IP has not changed once a month if 'minimize update' selected in GUI diff --git a/config/rootfiles/updater/update.sh b/config/rootfiles/updater/update.sh index cfa6962f5e..95de204577 100755 --- a/config/rootfiles/updater/update.sh +++ b/config/rootfiles/updater/update.sh @@ -172,7 +172,7 @@ echo \\n running on \\s \\r \\m >> /etc/issue # grep -v "ipacsum" /var/spool/cron/root.orig | grep -v "hddshutdown" > /tmp/root.orig.tmp echo "# Backup collectd files" >> /tmp/root.orig.tmp -echo "* 05 * * * /etc/init.d/collectd backup >/dev/null" >> /tmp/root.orig.tmp +echo "* 05 * * * /etc/init.d/tmpfs backup >/dev/null" >> /tmp/root.orig.tmp echo "# hddshutdown" >> /tmp/root.orig.tmp echo "*/30 * * * * /usr/local/bin/hddshutdown >/dev/null" >> /tmp/root.orig.tmp mv /tmp/root.orig.tmp /var/spool/cron/root.orig diff --git a/src/initscripts/init.d/collectd b/src/initscripts/init.d/collectd index a64114fb38..2a0cd16663 100644 --- a/src/initscripts/init.d/collectd +++ b/src/initscripts/init.d/collectd @@ -43,7 +43,7 @@ case "$1" in stop) # Save the ramdisk at manual stop but not at shutdown if [ "$(basename $0)" == "collectd" ]; then - /etc/init.d/collectd backup + /etc/init.d/tmpfs backup fi boot_mesg "Stopping Collection daemon..." killproc /usr/sbin/collectd @@ -54,17 +54,6 @@ case "$1" in sleep 1 ${0} start ;; - backup) - boot_mesg "Save rrd files from ramd..." - cp -pR $RRDLOG/* $RRDLOG.bak/ - evaluate_retval - ;; - restore) - if [ -e $RRDLOG.bak ];then - boot_mesg "Copying rrd files to ramd..." - cp -pR $RRDLOG.bak/* $RRDLOG/ - fi - ;; status) statusproc /usr/sbin/collectd ;; diff --git a/src/initscripts/init.d/tmpfs b/src/initscripts/init.d/tmpfs index 4a1ae15cad..d274176286 100644 --- a/src/initscripts/init.d/tmpfs +++ b/src/initscripts/init.d/tmpfs @@ -1,7 +1,6 @@ #!/bin/sh # Begin $rc_base/init.d/tmpfs - . /etc/sysconfig/rc . $rc_functions @@ -13,17 +12,30 @@ fi case "$1" in start) - /etc/init.d/collectd restore + $0 restore if [ ! -e $RRDLOG.bak/vnstat ]; then mkdir -p $RRDLOG.bak/vnstat fi ;; stop) - /etc/init.d/collectd backup + $0 backup + ;; + + backup) + boot_mesg "Save ramdisk..." + cp -pR $RRDLOG/* $RRDLOG.bak/ + evaluate_retval ;; + restore) + if [ -e $RRDLOG.bak ];then + boot_mesg "Restore ramdisk..." + cp -pR $RRDLOG.bak/* $RRDLOG/ + fi + ;; + *) - echo "Usage: $0 {start|stop}" + echo "Usage: $0 {start|stop|backup}" exit 1 ;; esac -- 2.39.2