forked from vain/asciiworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asciiworld-sat-track
executable file
·63 lines (57 loc) · 1.1 KB
/
asciiworld-sat-track
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
observer=
duration=0
footprint=
raw_args=
while getopts o:d:Fr: name
do
case $name in
o)
observer=$OPTARG
;;
d)
duration=$OPTARG
;;
F)
footprint=-F
;;
r)
raw_args=$OPTARG
;;
esac
done
shift $((OPTIND - 1))
title="Tracking: $@"
[[ -z "$observer" ]] && observer=$(asciiworld-ip-geo)
[[ -z "$observer" ]] && exit 1
tmpdir=$(mktemp -d)
satdir="${XDG_CACHE_HOME:-$HOME/.cache}"/asciiworld-sat-track
mkdir -p "$satdir"
find "$satdir" -type f -mtime +0 -delete
track=()
for i
do
if [[ ! -f "$satdir"/"$i".tle ]]
then
tle=$(asciiworld-sat-get "$i")
(( $? != 0 )) && exit 1
echo "$tle" >"$satdir"/"$i".tle
fi
track+=("$satdir"/"$i".tle)
done
target_time=$(( $(date +%s) + duration ))
tput civis
trap 'tput cnorm; rm -Rf "$tmpdir"' EXIT
while (( duration <= 0 )) || (( $(date +%s) < target_time ))
do
echo -e "points\n$observer" >"$tmpdir"/loc
for i in "${track[@]}"
do
asciiworld-sat-calc "$footprint" <"$i" >>"$tmpdir"/loc
(( $? != 0 )) && exit 1
done
asciiworld -Tosl "$tmpdir"/loc -d ast -t "$title" $raw_args
(( $? != 0 )) && exit 1
sleep 0.5
tput home
done