-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTLE_Meteor_M2-3.sh
56 lines (40 loc) · 1.65 KB
/
TLE_Meteor_M2-3.sh
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
#!/bin/bash
###########################################################
# #
# This script updates tle TLE data for Meteor-M2 3 #
# and writes it into the file ~/.predict/predict.tle #
# #
# The source of the TLE data is Celestrak: #
# https://celestrak.org/NORAD/elements/gp.php?CATNR=57166 #
# #
###########################################################
### CONFIG PART ###
## Automatical update of TLE data ##
# The TLE data of the satellite might change over time,
# so you can choose whether this script should should
# update the TLE data in regular intervals of 24 hours
# Possible values:
# - 0 : No automatical update (just update once)
# - 1 : Automatical update every 24 hours
autoupd=0
### OPERATIONAL PART ###
while true; do
tle=`curl https://celestrak.org/NORAD/elements/gp.php?CATNR=57166`
if [[ -z $(grep "METEOR-M2 3" ~/.predict/predict.tle) ]]; then
echo "$tle" >> ~/.predict/predict.tle
else
sat_name=`sed '1q;d' <<< "$tle"`
tle_line1=`sed '2q;d' <<< "$tle"`
tle_line2=`sed '3q;d' <<< "$tle"`
start_line=`grep -n "METEOR-M2 3" ~/.predict/predict.tle | grep -o -E '[0-9]+' | head -n1`
start_line=$(($start_line + 1))
sed -i "${start_line}s/.*/${tle_line1}/" ~/.predict/predict.tle
start_line=$(($start_line + 1))
sed -i "${start_line}s/.*/${tle_line2}/" ~/.predict/predict.tle
fi
if [[ $autoupd -eq 1 ]]; then
sleep 24h
else
break
fi
done