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

Last change on this file since 542 was 542, checked in by Nick Burch, 13 years ago

Support NI tiles too (uploaded to /osie/scaled? instead of /scaled?)

  • Property svn:executable set to *
File size: 2.0 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# Do they want to upload to osgb, or osie?
46my $remote_append = "";
47if($curdir =~ /\/ni-maps\//) {
48    print "Detected OS Northern Ireland tiles, uploading to osie\n\n";
49    $remote_append = "osie/";
50}
51
52# Report what we're going to do
53print "About to upload ".join(" ",@args)." for scale $scale\n\n";
54
55my $dir = "scaled$scale/";
56if($scale eq 'm') {
57        $dir = "meta1/";
58}
59
60# Upload each in turn
61foreach my $server (reverse sort keys %servers) {
62        my $path = $servers{$server} . $remote_append . $dir;
63
64        my $cmd = "rsync -avc --bwlimit=96 ".join(" ",@args)." $server:$path";
65        print $cmd."\n";
66        print `$cmd 1>&2`;
67}
68print "\n\n";
69
70# Fix permissions on urchin
71my $cmd = "ssh urchin 'cd $servers{urchin}$dir && chown -R .npemap ".join(" ",@args)."'"; 
72print $cmd."\n";
73`$cmd`;
74
75# Done
76print "\n\n";
Note: See TracBrowser for help on using the repository browser.