DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-02-18 16:22:38

sm8ps
Member
From: Switzerland
Registered: 2009-12-13
Posts: 13

Script for saving configuration files before upgdrading packages

Dear all,

I have been putting together some instructions for setting up and handling the DNS-323/320 for my students. I use this device for a hands-on project in some introductory computer science class. Therefore any instructions should be "fool-proof" because they are intended for a novice user.

During the initial set-up, we install all packages. When it comes to up-grading packages, I stumbled over the pitfalls mentioned in the tutorial  http://tinyurl.com/funpkg-u-etc.
So I "quickly" hacked together a script that should save all configuration files in /ffp/etc/ that might get over-written by a update (and only these, so not just simply all of /ffp/etc/).
This is has not been tested yet other than by myself and should be considered alpha-quality for the moment. I would be glad if others could have a look at it and test it. The script must be run as user 'root'. Run it with parameter -h to see some usage instructions.

Cheers!
St. Mueller, Switzerland


Attachments:
Attachment Icon save-etc.sh, Size: 3,276 bytes, Downloads: 184

Offline

 

#2 2011-02-18 20:35:49

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Script for saving configuration files before upgdrading packages

I have a slightly different approach. I append a ".save" to both the configuration and the start scripts if they are modified. I then run this "reset" script as part of my nightly maintenance (which also zips and saves all config and scripts using logrotate to keep history). The ".save" version replaces the original in case it has been modified through an update.

Code:

for _f in "addcron" "automatic" "dnsmasq" "kickwebs" "lighttpd" "logrotate" "logrotate2" "ntpd" "telnetd" "transmission"; do
  if [ -f "/ffp/start/${_f}.sh.save" ]; then
    echo "`date` Copying /ffp/start/${_f}.sh.save to /ffp/start/${_f}.sh"
    cp -p /ffp/start/${_f}.sh.save /ffp/start/${_f}.sh
    if [ -f "/ffp/start/${_f}.sh" ]; then
      echo "`date` Marking /ffp/start/${_f}.sh as executable"
      /ffp/bin/chmod +x /ffp/start/${_f}.sh
    else
      echo "`date` WARNING: /ffp/start/${_f}.sh does not exist"
    fi
  fi
  if [ -f "/ffp/etc/${_f}.conf.save" ]; then
    echo "`date` Copying /ffp/etc/${_f}.conf.save to /ffp/etc/${_f}.conf"
    cp -p /ffp/etc/${_f}.conf.save /ffp/etc/${_f}.conf
  fi
done

This also resets the permissions to ensure the scripts run on a restart. I can setup changes in advance that will be enabled on the midnight restart.

This logrotate segment creates an archive of /ffp/etc

Code:

/mnt/usb/archive/FFP_etc.tar.gz {
  weekly
  ifempty
  missingok
  create
  rotate 52
  postrotate
    /ffp/bin/tar -cz -f /mnt/usb/archive/FFP_etc.tar.gz /ffp/etc/*
  endscript
}

Last edited by FunFiler (2011-02-18 20:37:37)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB