#!/usr/bin/perl
#
# quakemaps scripts
#
# .getmap --crb3 23dec03
#
# fetch in california, NE and US quake maps
# at half-hour cron'd intervals, and build animated gifs
# with them. builds an animated gif per day for
# each map type.
#
# individual files have datimes as 00mon00^000000
#
$gifdelay=50;
$gifloops=10;

sub get_date {
  my $today=&get_datime;
  substr($today,7)="";
  return($today);
}

sub get_datime{
  my $rightnow;
  ($sec,$min,$hour,$mday,$mon,$yr,,,,) = localtime();
  $yr %= 100;
  $amon = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];
  $rightnow = ($mday<10?"0":"")."$mday$amon".($yr<10?"0":"")."$yr";
  $rightnow .= "^";             # best char I could find for this separator
  $rightnow .= ($hour<10?"0":"")."$hour:".($min<10?"0":"")."$min:".($sec<10?"0":"")."$sec";

  $rightnow =~ s/\://g;

  return $rightnow;
}

$gifsicle="/usr/local/bin/gifsicle";
$wget="/usr/bin/wget -q";

chdir "/var/www/html/quakes";

$todaytime=&get_datime;
$today=&get_date;

#20May03^170000
#01234567890123


$usurl="http://earthquake.usgs.gov/recenteqsUS/index.gif";
`$wget -O usmap.$todaytime.gif $usurl`;

#$caurl="http://quake.wr.usgs.gov/recenteqs/index_map.gif";     # --they changed it
$caurl="http://www.data.scec.org/recenteqs/index_map.gif";
`$wget -O calnev.$todaytime.gif $caurl`;

$neurl="http://www.ldeo.columbia.edu/LCSN/recenteqs/index_map.gif";
`$wget -O nemap.$todaytime.gif $neurl`;

# other maps which may be of interest...
# http://www.data.scec.org/recenteqs/Maps/Los_Angeles.gif
# http://www.data.scec.org/recenteqs/Maps/San_Francisco.gif
# http://earthquake.usgs.gov/eqcenter/recenteqsus/Maps/special/Yellowstone.gif

#
# we do our own wildcard-sorting to guarantee an alpha-sort
#
$allcalnev=join(' ',sort(<calnev.$today*gif>));
$allus=join(' ',sort(<usmap.$today*gif>));
$allne=join(' ',sort(<nemap.$today*gif>));
if($include_sece){
  $allsece=join(' ',sort(<sece.$today*gif>));
}
#
# (re)generate today's animated gifs
#
$gifargs="--loop=$gifloops --delay=$gifdelay --optimize=2";


`$gifsicle $gifargs $allcalnev >calnev-$today.gif`;
`$gifsicle $gifargs $allus >usmap-$today.gif`;
`$gifsicle $gifargs $allne >nemap-$today.gif`;

if($include_sece){
  `$gifsicle $gifargs $allsece >sece-$today.gif`;
}


#--------------------cut here------------------------


#!/usr/bin/perl -w
#
# .tarballs     --crb3 23/24may03
# get the discrete gifs out of the way
# cron runs this at 23:55 local

sub get_date {
  my $today=&get_datime;
  substr($today,7)="";
  return($today);
}

sub get_datime{
  my $rightnow;
  ($sec,$min,$hour,$mday,$mon,$yr,,,,) = localtime();
  $yr %= 100;
  $amon = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];
  $rightnow = ($mday<10?"0":"")."$mday$amon".($yr<10?"0":"")."$yr";
  $rightnow .= "^";             # best char I could find for this separator
  $rightnow .= ($hour<10?"0":"")."$hour:".($min<10?"0":"")."$min:".($sec<10?"0":"")."$sec";

  $rightnow =~ s/\://g;

  return $rightnow;
}

chdir "/var/www/html";

$today=&get_date;
$today=$ARGV[0if defined $ARGV[0];

`/bin/tar --remove-files -zcf quakes/tarballs/usmap.$today.tar.gz quakes/usmap.$today*gif`;
`/bin/tar --remove-files -zcf quakes/tarballs/nemap.$today.tar.gz quakes/nemap.$today*gif`;
`/bin/tar --remove-files -zcf quakes/tarballs/calnev.$today.tar.gz quakes/calnev.$today*gif`;

Grab a
gzipped
copy
here
 
Syntax highlighting using Syntax::Highlight::Engine::Kate