#!/bin/sh
#
# $Id$
#
# Copyright (C) 2000-2007  The Xastir Group
#
# Updated on 7/5/03 to reflect the new directory structure
# N0VH
#
# Note: Run this script as root in order to write the files into the
# destination directory listed below.
#
XASTIR_BASE=/usr/local/share/xastir
cd /var/tmp
#
#
# Get the FCC database, process it.
#   Download size:  ~71MB
# Final file size: ~101MB
echo "*********************************"
echo "*** Fetching the FCC database ***"
echo "*********************************"
#wget -c --passive-ftp ftp://ftp.fcc.gov/pub/Bureaus/Wireless/Databases/uls/complete/l_amat.zip
wget -c http://www.fcc.gov/Bureaus/Wireless/Databases/uls/complete/l_amat.zip
#
# Get rid of characters "^M^M^J" which are sometimes present, sort
# the file by callsign.
echo "*****************************************************"
echo "*** Filtering/sorting/installing the FCC database ***"
echo "*****************************************************"
if [ -r l_amat.zip ]; then unzip -p l_amat.zip EN.dat \
    | /usr/bin/perl -pe 's/\r\r\n//g;s/\r//g' \
    | sort -k 5,5 -t \| >$XASTIR_BASE/fcc/EN.dat; fi
#    | sort +4 -t \| >$XASTIR_BASE/fcc/EN.dat; fi
#
#
#
# Get the RAC database, process it.
#   Download size:  ~2MB
# Final file size: ~13MB
echo "*********************************"
echo "*** Fetching the RAC database ***"
echo "*********************************"
#wget -c --passive-ftp ftp://ftp.rac.ca/pub/cdncaldb.zip
wget -c http://205.236.99.41/%7Eindicatif/download/amateur.zip
#wget -c ftp://ftp.rac.ca/pub/cdncaldb.zip
#
echo "***********************************"
echo "*** Installing the RAC database ***"
echo "***********************************"
unzip amateur.zip amateur.rpt
mv amateur.rpt $XASTIR_BASE/fcc/AMACALL.LST
#
#
# Remove the original downloads
rm l_amat.zip amateur.zip
echo "*************"
echo "*** Done! ***"
echo "*************"

