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

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

Check we're in the right directory before uploading

  • Property svn:executable set to *
File size: 1.7 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$servers{openstreetmap} = "/home/dsheldon/npetiles/";
11
12# Allow restricting to just one server
13if($ARGV[0] && $servers{$ARGV[0]}) {
14        my $srv = shift @ARGV;
15        print "Restricting to just server $srv\n";
16        my %srvs;
17        $srvs{$srv} = $servers{$srv};
18        %servers = %srvs;
19}
20
21# Process the rest of the arguments
22my $scale = shift @ARGV;
23my @args = @ARGV;
24
25unless($scale && $args[0]) {
26        print "Use:\n";
27        print "  upload.pl <scale> [easting] [easting] [easting....]\n";
28        print "\n";
29        print "Will upload the specified easting directories to all 3 servers\n";
30        exit 1;
31}
32unless($scale == 1 || $scale == 3 || $scale == 6 || $scale eq 'm') {
33        die("Scale must be the 1st argument, and one of 1, 3, 6 or m\n");
34}
35
36# Check they're in the right directory
37my $curdir = `pwd`;
38chomp $curdir;
39print "$curdir\n";
40if($scale eq "m") { $curdir =~ s/meta1$/scaledm/; }
41unless($curdir =~ /scaled$scale$/) {
42    die("Can't upload for scale $scale from directory $curdir\n");
43}
44
45# Report what we're going to do
46print "About to upload ".join(" ",@args)." for scale $scale\n\n";
47
48my $dir = "scaled$scale/";
49if($scale eq 'm') {
50        $dir = "meta1/";
51}
52
53# Upload each in turn
54foreach my $server (reverse sort keys %servers) {
55        my $path = $servers{$server} . $dir;
56
57        my $cmd = "rsync -avc ".join(" ",@args)." $server:$path";
58        print $cmd."\n";
59        print `$cmd 1>&2`;
60}
61print "\n\n";
62
63# Fix permissions on urchin
64my $cmd = "ssh urchin 'cd $servers{urchin}$dir && chown -R .npemap ".join(" ",@args)."'"; 
65print $cmd."\n";
66`$cmd`;
67
68# Done
69print "\n\n";
Note: See TracBrowser for help on using the repository browser.