source: subversion/applications/utils/planet-mirror/planet-mirror.pl @ 4320

Last change on this file since 4320 was 3898, checked in by joerg, 13 years ago

adapt planet fetching back to .bz2

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1#!/usr/bin/perl
2
3BEGIN {
4    unshift(@INC,"../perl_lib");
5    unshift(@INC,"~/svn.openstreetmap.org/applications/utils/perl_lib");
6    unshift(@INC,"$ENV{HOME}/svn.openstreetmap.org/applications/utils/perl_lib");
7}
8
9
10use strict;
11use warnings;
12
13use Data::Dumper;
14use Getopt::Long;
15
16use Geo::OSM::Planet;
17use Utils::Debug;
18use Utils::LWP::Utils;
19use Pod::Usage;
20
21my ($man,$help);
22
23use strict;
24use warnings;
25
26my $do_print_filename=0;
27my $planet_dir='';
28my $no_symlink=0;
29# ------------------------------------------------------------------
30# Set defaults and get options from command line
31Getopt::Long::Configure('no_ignore_case');
32GetOptions ( 
33             'debug:+'    => \$DEBUG,     
34             'd:+'        => \$DEBUG,     
35             'verbose:+'  => \$VERBOSE,
36             'v:+'        => \$VERBOSE,
37             'MAN'        => \$man, 
38             'man'        => \$man, 
39             'h|help|x'   => \$help, 
40
41             'no-mirror'  => \$Utils::LWP::Utils::NO_MIRROR,
42             'proxy=s'    => \$Utils::LWP::Utils::PROXY,
43
44             'print-filename'  => \$do_print_filename,
45             'no-symlink'      => \$no_symlink,
46             'planet-dir:s'    => \$planet_dir,
47             )
48    or pod2usage(1);
49
50pod2usage(1) if $help;
51pod2usage(-verbose=>2) if $man;
52
53Geo::OSM::Planet::planet_dir($planet_dir)
54    if $planet_dir;
55
56my $new_filename = mirror_planet();
57
58if ( !  $new_filename ) {
59    print "ERROR: No new File found\n";
60    exit -1;
61}
62
63if ( ! $no_symlink ) {
64    my $planet_filename =  $new_filename;
65    $planet_filename =~ s/(planet)-\d+(\.osm\..+)$/$1$2/;
66    if ( -e $planet_filename ) {
67        unlink($planet_filename);
68    }
69    symlink($new_filename,$planet_filename)
70        or warn "cannot symlink $new_filename ==> $planet_filename: $@\n";
71   
72}
73
74if ( $do_print_filename ) {
75    print "$new_filename\n";
76}
77
78
79
80##################################################################
81# Usage/manual
82
83__END__
84
85=head1 NAME
86
87B<planet-mirror.pl> Version 0.1
88
89=head1 DESCRIPTION
90
91B<planet-mirror.pl> is a program download the current planet.osm
92
93This program will have a look at http://planet.openstreetmap.org/
94and see if there is a newer planet-xx.osm.7z File to download.
95If ther is it will download it to ~/osm/planet/
96After this it will Sanitize the File and write the result to
97planet-xx-a.osm.7z
98If you want your planet File to always be up to date you can i
99add the following line to your crontab
100 01 9 * * * /home/<yourname>/svn.openstreetmap.org/utils/planet-mirror/planet-mirror.pl
101
102=head1 SYNOPSIS
103
104B<Common usages:>
105
106planet-mirror.pl [--man] [-d] [-v] [-h] [--no-proxy] [--no-mirror]
107
108planet-mirror.pl -v
109
110 Download the most current planet-xxxxxx.osm.bz and tell what's going on
111
112=head1 OPTIONS
113
114=over 2
115
116=item B<--man> Complete documentation
117
118This shows the Complete documentation
119
120
121=item B<--no-mirror>
122
123Do not try mirroring the files from the original Server. Only use
124files found on local Filesystem.
125
126
127=item B<--proxy>
128
129use proxy for download
130
131=item B<--planet-dir=[path-to-planet-files]>
132
133The ddirectory to put and check the planet Files.
134Default is ~/osm/planet/
135
136=item B<--no-symlink>
137
138normally the current planet file is symlinked to
139a file named planet.osm.* in the smae directory.
140If this option is set this will not be done.
141
142=item B<--print-filename>
143
144print the filename of the mirrored osm file
145
146
147=item B<-v>
148
149Print out what the programm is doing.
150
151If used twice (-v -v ) you get status updates even while
152downloading the File.
153
154=back
155
156
157=head1 COPYRIGHT
158
159Copyright 2006, Jörg Ostertag
160
161This program is free software; you can redistribute it and/or
162modify it under the terms of the GNU General Public License
163as published by the Free Software Foundation; either version 2
164of the License, or (at your option) any later version.
165
166This program is distributed in the hope that it will be useful,
167but WITHOUT ANY WARRANTY; without even the implied warranty of
168MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
169GNU General Public License for more details.
170
171You should have received a copy of the GNU General Public License
172along with this program; if not, write to the Free Software
173Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
174
175=head1 AUTHOR
176
177Jörg Ostertag (planet-count-for-openstreetmap@ostertag.name)
178
179=head1 SEE ALSO
180
181http://www.openstreetmap.org/
182
183=cut
Note: See TracBrowser for help on using the repository browser.