source: trunk/npemap.org.uk/scripts/tile-processing/upload.pl @ 448

Last change on this file since 448 was 448, checked in by Nick Burch, 14 years ago

Support meta upload, and show progress

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/perl
2use strict;
3
4# Path to the scale directory on each server
5my %servers;
6$servers{dev} = "/usr/local/OSGB/";
7$servers{encore} = "/usr/local/maps/OSGB/";
8$servers{urchin} = "/srv/www/tile.npemap.org.uk/html/";
9$servers{bitclean} = "/home/bitclean/public_html/";
10
11# Allow restricting to just one server
12if($ARGV[0] && $servers{$ARGV[0]}) {
13        my $srv = shift @ARGV;
14        print "Restricting to just server $srv\n";
15        my %srvs;
16        $srvs{$srv} = $servers{$srv};
17        %servers = %srvs;
18}
19
20# Process the rest of the arguments
21my $scale = shift @ARGV;
22my @args = @ARGV;
23
24unless($scale && $args[0]) {
25        print "Use:\n";
26        print "  upload.pl <scale> [easting] [easting] [easting....]\n";
27        print "\n";
28        print "Will upload the specified easting directories to all 3 servers\n";
29        exit 1;
30}
31unless($scale == 1 || $scale == 3 || $scale == 6 || $scale eq 'm') {
32        die("Scale must be the 1st argument, and one of 1, 3, 6 or m\n");
33}
34
35# Report what we're going to do
36print "About to upload ".join(" ",@args)." for scale $scale\n\n";
37
38my $dir = "scaled$scale/";
39if($scale eq 'm') {
40        $dir = "meta1/";
41}
42
43# Upload each in turn
44foreach my $server (reverse sort keys %servers) {
45        my $path = $servers{$server} . $dir;
46
47        my $cmd = "rsync -avc ".join(" ",@args)." $server:$path";
48        print $cmd."\n";
49        print `$cmd 1>&2`;
50}
51print "\n\n";
52
53# Fix permissions on urchin
54my $cmd = "ssh urchin 'cd $servers{urchin}$dir && chown -R .npemap ".join(" ",@args)."'"; 
55print $cmd."\n";
56`$cmd`;
57
58# Done
59print "\n\n";
Note: See TracBrowser for help on using the repository browser.