[ previous ] [ next ] [ threads ]
 From:  Andreas Ferrari <aferrari at stasoft dot ch>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  Quick and dirty script for mass-backup of m0n0walls
 Date:  Thu, 27 Jul 2006 17:03:03 +0200
maybe someone find it useful:

use strict;

my %conf;
$conf{proto}="https";#should be ok
$conf{user}="admin"; #edit here if needed
$conf{rm}="/bin/rm -rf";
$conf{curl}="/usr/bin/curl -k -s -o";
#ok I know -k is not very god but its quick and dirty
$conf{args}="-F Submit=download -u $conf{user}:";
$conf{base}="/home/afe/m0n0bak"; #change this
#put all your m0n0s in here!
#in this example COSTUMER1 is the name of my costumer
#host01 is DNS name
#last the ip and the password seperated by a ':'
#Wondering why I use IP and DNS?
#somtimes it could happen that dns does not work...

#here is a more complex example
#              {
#               COSTUMER1=>{
#			    host01=>''
#			    host02=>''
#			    host03=>''
#			    host04=>''
#			    host05=>''
#			   },
#		COSTUMER2=>{host01=>''},
#              };

system("$conf{rm} $conf{base}");
system("$conf{mkdir} $conf{base}");
chdir $conf{global}{base};
for(sort keys %{$conf{conf}}){
   my $costumer=$_;
   print " Doing backup for costumer:$costumer\n";
   system("/bin/mkdir $conf{base}/$costumer");
   chdir "$conf{base}/$costumer";
   for(sort keys %{$conf{conf}{$costumer}}){
     my $host=$_;
     my ($ip,$pw)=split /:/,$conf{conf}{$costumer}{$host};
     print "Donwloading config from host:$host\/ip:$ip\n";
     my $filename ="config-$host.xml";
     my $uri="$conf{proto}://$ip/diag_backup.php";
     system("$conf{curl} $filename $conf{args}:$pw $uri\n");
     print "Download of configfile $filename complete..\n";

         -CA handling for curl



P: +41 61 726 80 70
F: +41 61 726 80 79