#!/usr/bin/perl -w
##
# hashcopy.pl, michael@schaarwaechter.de, 2010/07
#
# Erstellt eine Kopie eines Hashes
# Sinnvoll, wenn eine der Dateien, in denen 
# exchange.pl seine Informationen speichert,
# defekt erscheint
# Howto: Ganz unten in dieser Datei

use DB_File;
use Data::Dumper;   

our $filelocation = '.';
our $hashlocation = "$filelocation/files.hash";
our $tanlocation = "$filelocation/tans.hash";
our $statistlocation = "$filelocation/statist.hash";
our $filestatlocation = "$filelocation/filestat.hash";
our $bruteforcelocation ="$filelocation/bruteforce.hash";
our $tanenable = 1;


tie our %filenames, "DB_File", $hashlocation or die "Could not open $hashlocation: $!";
tie our %statistics, "DB_File", $statistlocation or die "Could not open $statistlocation: $!";
tie our %filestats, "DB_File", $filestatlocation or die "Could not open $filestatlocation: $!";
if ($tanenable) {
   tie our %tans, "DB_File", $tanlocation or die "Could not open $tanlocation: $!";
}

# Deklarieren des neuen Hashes
tie our %newhash, "DB_File", "newhash.hash" or die "Could not open newhash.hash: $!";

# print Dumper(\%filenames);
# print Dumper(\%filestats);

# Kopie des alten in den neuen Hash. Hier den zu kopierenden Hash rechts einsetzen!
%newhash = %filestats;

untie %filenames;
untie %newhash;
untie %statistics;
untie %filestats;
untie %tans;

# - Die Zeile %newhash = %filestats; oben anpassen
# - Apache stoppen
# - *.hash aus Produktionsverzeichnis sichern
# - Dieses Programm laufen lassen
# - newhash.hash zu [alterhash.hash] kopieren
# - Rechte an dem Hash so setzen, dass Apache schreiben kann
# - Apache starten und testen

