#! /bin/csh
#
# gettle      -----      Manfred Bester  14Mar95
#
# This C shell script can be invoked manually or by cron at a specified time.
# It calls up 'archive.afit.af.mil' (129.92.1.66) and gets the most recent 
# files with Keplerian two-line element sets, as used with SatTrack. 
# After placing the files into SatTrack/tle, program 'tlexgen' is invoked. 
# This program generates an extra file 'tlex.dat' with extended two-line 
# element sets. It basically concatenates several tle files into a larger data 
# base which is used in turn as the default data base for SatTrack. Duplicate 
# entries are eliminated by the object number. The tle files that are 
# concatenated are specified in the input file 'tlelist.dat' in SatTrack/data. 
# Finally, program 'selectsat' is invoked to generate an abbreviated list of 
# two-line element sets for a specified satellite group (e.g. am, sci, wx), 
# which may be used for further distribution to users interested in that 
# particular satellite group. 
#
# If SatTrack is not installed in the user's home directory, the variable 
# 'satdir' needs to be changed to the name of the directory that SatTrack is 
# installed under. The variable 'satuser' is the UID of the user who is allowed 
# to write into the system-wide SatTrack directory, i.e. the person in charge 
# of maintaining SatTrack. 
#
#
#
set ftphost=archive.afit.af.mil
set satdir=/usr/local/lib
set satuser=sattrack
#
#
#
set hostdot=`hostname | grep '\.'`
if ("$hostdot" == "") then
    set userid=$USER@`hostname`.`domainname`
else
    set userid=$USER@`hostname`
endif
#
set satdirusr=$satdir
if (! -d $satdirusr/SatTrack/tle) then
    mkdir -p $satdirusr/SatTrack/tle
endif
#
cd $satdirusr/SatTrack/tle
#
if ($1 == -v) then 
    echo $userid
    echo calling $ftphost ...
endif
#
ftp $1 -n $ftphost << !
user anonymous -$userid
cd /pub/space
get tle.new
get gorizont.tle
get other.tle
get tvro.tle
get visual.tle
quit
!
#
if ($1 == -v) then 
    echo saving data files ...
endif
#
"cp" tle.dat tle.bak
"mv" tle.new tle.dat
"mv" gorizont.tle gorizont.dat
"mv" other.tle debris.dat
"mv" tvro.tle tvro.dat
"mv" visual.tle visual.dat
#
if ($1 == -v) then 
    echo running 'maketlex' ...
endif
#
maketlex
#
if ($1 == -v) then 
    echo running 'maketles' ...
endif
#
maketles am
#
if ($1 == -v) then 
    echo running 'satfilter' ...
endif
#
satfilter leoe
satfilter leom
satfilter leop
#
if ($1 == -v) then 
    echo done.
endif
#
