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

Last change on this file since 711 was 711, checked in by Nick Burch, 11 years ago

Various little tweaks to scripts, plus a new script to output the corner details from osgb grid refs

  • Property svn:executable set to *
File size: 3.1 KB
Line 
1#!/usr/bin/perl
2#
3# Copyright (c) 2006-2007 Nick Burch
4# Permission is hereby granted, free of charge, to any person obtaining a
5# copy of this software and associated documentation files (the "Software"),
6# to deal in the Software without restriction, including without limitation
7# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8# and/or sell copies of the Software, and to permit persons to whom the
9# Software is furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice shall be included in
12# all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20# IN THE SOFTWARE.
21#
22use strict;
23
24# Path to the scale directory on each server
25my %servers;
26#$servers{dev} = "/usr/local/OSGB/";
27#$servers{encore} = "/usr/local/maps/OSGB/";
28$servers{urchin} = "/srv/www/tile.npemap.org.uk/html/";
29#$servers{bitclean} = "/home/bitclean/public_html/";
30#$servers{openstreetmap} = "/home/dsheldon/npetiles/";
31
32# Allow restricting to just one server
33if($ARGV[0] && $servers{$ARGV[0]}) {
34        my $srv = shift @ARGV;
35        print "Restricting to just server $srv\n";
36        my %srvs;
37        $srvs{$srv} = $servers{$srv};
38        %servers = %srvs;
39}
40
41# Process the rest of the arguments
42my $scale = shift @ARGV;
43my @args = @ARGV;
44
45unless($scale && $args[0]) {
46        print "Use:\n";
47        print "  upload.pl <scale> [easting] [easting] [easting....]\n";
48        print "\n";
49        print "Will upload the specified easting directories to all 3 servers\n";
50        exit 1;
51}
52unless($scale == 1 || $scale == 3 || $scale == 6 || $scale eq 'm') {
53        die("Scale must be the 1st argument, and one of 1, 3, 6 or m\n");
54}
55
56# Check they're in the right directory
57my $curdir = `pwd`;
58chomp $curdir;
59print "$curdir\n";
60if($scale eq "m") { $curdir =~ s/meta1$/scaledm/; }
61unless($curdir =~ /scaled$scale$/) {
62    die("Can't upload for scale $scale from directory $curdir\n");
63}
64
65# Do they want to upload to osgb, or osie?
66my $remote_append = "";
67if($curdir =~ /\/ni-maps\//) {
68    print "Detected OS Northern Ireland tiles, uploading to osie\n\n";
69    $remote_append = "osie/";
70}
71
72# Report what we're going to do
73print "About to upload ".join(" ",@args)." for scale $scale\n\n";
74
75my $dir = "scaled$scale/";
76if($scale eq 'm') {
77        $dir = "meta1/";
78}
79
80# Upload each in turn
81foreach my $server (reverse sort keys %servers) {
82        my $path = $servers{$server} . $remote_append . $dir;
83
84        my $cmd = "rsync -avc --bwlimit=96 ".join(" ",@args)." $server:$path";
85        print $cmd."\n";
86        print `$cmd 1>&2`;
87}
88print "\n\n";
89
90# Fix permissions on urchin
91my $cmd = "ssh urchin 'cd $servers{urchin}$remote_append$dir && chown -R .npemap ".join(" ",@args)."'"; 
92print $cmd."\n";
93`$cmd`;
94
95# Done
96print "\n\n";
Note: See TracBrowser for help on using the repository browser.