#!/usr/bin/perl

my(undef,undef,undef,undef,undef,$year,undef,undef,undef) =
                                                localtime(time);
$year += 1900;
opendir(OLDROOT,"/var/log/bandwidth");
@FILES=readdir(OLDROOT);
closedir(OLDROOT);

foreach $file (@FILES) { 
	if ($file !~ /\./) {
		if ($file =~ /^\d*$/) {
			print "Upgrade has already been done\n";
			exit;
		}
	}
}

if (! -e "/var/log/bandwidth/$year") {
	mkdir("/var/log/bandwidth/$year",0755);
	foreach $file (@FILES) { 
		if ($file !~ /\./) {
			if (-d "/var/log/bandwidth/$file") {
				print "$file->$year/$file\n";
				rename("/var/log/bandwidth/$file","/var/log/bandwidth/$year/$file");
			}
		}
	}
}

print "Upgrade appears to be done ok\n";
