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

Last change on this file since 5530 was 5530, checked in by joerg, 12 years ago

/planet-mirror.pl: remove @INC lines to reduce modules taken from svn instead of installed system

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