#!/bin/bash

# This is the script that I use to send me a daily report of satellites.
# It can and should be customized for an individual user

# The email address to send predictions to.
EMAIL='Tom Rothamel <tom-dailypredicts@onegeek.org>'

# The minimum magnitude of the passes to show.
MAG=3.5

# The place to put temporary files. Please change this if you have
# untrusted users on your system.
TMP=/tmp

# The times to start and end prediction.
START="noon today"
END="noon tomorrow"

# The minimum sun elevation.
SUNEL=-6

# Source a file with the current site's configuration.
. /home/tom/code/sattool/scripts/northport.sh

#######################################################################

DATE=`date +%Y-%m-%d`

tlefile=$TMP/mccants.tle
tleurl=ftp://ftp.fc.net/pub/users/mikem/mccants.tle
passlist=$TMP/$DATE.passlist
filtered=$TMP/$DATE.filtered

# Get the latest version of the tle file off the web.
wget -q -O $tlefile $tleurl

cat <<EOF
From: Sattool Predictions <>
To: $EMAIL
Subject: $DATE Sattool Predictions

EOF

# Predict passes from start to end.
sattool predict -qvti $tlefile "$START" "$END" -o $passlist

# Filter the passlist.
sattool filter -i $passlist -o $filtered -- minmag lt $MAG and \
    sunel lt $SUNEL and lit
  
# Summarize the passlist.

cat <<EOF
Norad Desig                    Name Date  Time   El Mag

EOF

sattool summary -i $filtered

cat <<EOF


Norad Desig    Name                           (Age)
        Date     Time      Azimuth   El   Mag  Range    

EOF

sattool step -i $filtered 30 mag lt 4.5 