Pārlūkot izejas kodu

add .conf file for global variable, NOT everyone use the shitty bash, so ,,sh'' POSIX is your friend, some sone checks for directories

tags/v1.0
gonzalo pirms 6 gadiem
vecāks
revīzija
6ebe547e22
3 mainītis faili ar 65 papildinājumiem un 23 dzēšanām
  1. +34
    -5
      receive.sh
  2. +14
    -8
      schedule.sh
  3. +17
    -10
      schedule_sat.sh

+ 34
- 5
receive.sh Parādīt failu

@@ -1,20 +1,49 @@
#!/bin/bash
#!/bin/sh

## debug
#set -x

. ~/.noaa.conf

## sane checks
if [ ! -d ${NOAA_HOME} ]; then
mkdir -p ${NOAA_HOME}
fi

if [ ! -d ${NOAA_HOME}audio/ ]; then
mkdir -p ${NOAA_HOME}/audio/
fi

if [ ! -d ${NOAA_HOME}/image/ ]; then
mkdir -p ${NOAA_HOME}/image/
fi

if [ ! -d ${NOAA_HOME}/map/ ]; then
mkdir -p ${NOAA_HOME}/map/
fi

if [ ! -d ${NOAA_HOME}/predict/ ]; then
mkdir -p ${NOAA_HOME}/predict/
fi

if pgrep "rtl_fm" > /dev/null
then
exit 1
fi

# $1 = Satellite Name
# $2 = Frequency
# $3 = FileName base
# $4 = TLE File
# $5 = EPOC start time
# $6 = Time to capture

START_DATE=$(date '+%d-%m-%Y %H:%M')
timeout "${6}" rtl_fm -f "${2}"M -s 60k -g 50 -p 55 -E wav -E deemp -F 9 - | sox -t raw -e signed -c 1 -b 16 -r 60000 - /home/pi/audio/"${3}".wav rate 11025
timeout "${6}" rtl_fm -f "${2}"M -s 60k -g 50 -p 55 -E wav -E deemp -F 9 - | sox -t raw -e signed -c 1 -b 16 -r 60000 - ${NOAA_HOME}/audio/"${3}".wav rate 11025

PASS_START=$("$5" + 90)
/usr/local/bin/wxmap -T "${1}" -H "${4}" -p 0 -l 0 -o "${PASS_START}" /home/pi/map/"${3}"-map.png
/usr/local/bin/wxmap -T "${1}" -H "${4}" -p 0 -l 0 -o "${PASS_START}" ${NOAA_HOME}/map/"${3}"-map.png
for i in ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT; do
/usr/local/bin/wxtoimg -o -m /home/pi/map/"${3}"-map.png -e $i /home/pi/audio/"${3}".wav /home/pi/image/"${3}"-$i.png
/usr/bin/convert /home/pi/image/"${3}"-$i.png -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "$1 $START_DATE" /home/pi/image/"${3}"-$i.png
/usr/local/bin/wxtoimg -o -m ${NOAA_HOME}/map/"${3}"-map.png -e $i ${NOAA_HOME}/audio/"${3}".wav ${NOAA_HOME}/image/"${3}"-$i.png
/usr/bin/convert ${NOAA_HOME}/image/"${3}"-$i.png -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "$1 $START_DATE" ${NOAA_HOME}/image/"${3}"-$i.png
done

+ 14
- 8
schedule.sh Parādīt failu

@@ -1,13 +1,19 @@
#!/bin/bash
#wget -qr https://www.celestrak.com/NORAD/elements/weather.txt -O /home/pi/predict/weather.txt
grep "NOAA 15" /home/pi/predict/weather.txt -A 2 > /home/pi/predict/weather.tle
grep "NOAA 18" /home/pi/predict/weather.txt -A 2 >> /home/pi/predict/weather.tle
grep "NOAA 19" /home/pi/predict/weather.txt -A 2 >> /home/pi/predict/weather.tle
#!/bin/sh

## debug
#set -x

. ~/.noaa.conf

#wget -qr https://www.celestrak.com/NORAD/elements/weather.txt -O "${NOAA_HOME}"/predict/weather.txt
grep "NOAA 15" "${NOAA_HOME}"/predict/weather.txt -A 2 > "${NOAA_HOME}"/predict/weather.tle
grep "NOAA 18" "${NOAA_HOME}"/predict/weather.txt -A 2 >> "${NOAA_HOME}"/predict/weather.tle
grep "NOAA 19" "${NOAA_HOME}"/predict/weather.txt -A 2 >> "${NOAA_HOME}"/predict/weather.tle

#Remove all AT jobs
for i in $(atq | awk '{print $1}');do atrm "$i";done

#Schedule Satellite Passes:
/home/pi/schedule_sat.sh "NOAA 19" 137.1000
/home/pi/schedule_sat.sh "NOAA 18" 137.9125
/home/pi/schedule_sat.sh "NOAA 15" 137.6200
"${NOAA_HOME}"/schedule_sat.sh "NOAA 19" 137.1000
"${NOAA_HOME}"/schedule_sat.sh "NOAA 18" 137.9125
"${NOAA_HOME}"/schedule_sat.sh "NOAA 15" 137.6200

+ 17
- 10
schedule_sat.sh Parādīt failu

@@ -1,10 +1,16 @@
#!/bin/bash
PREDICTION_START=$(/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" | head -1)
PREDICTION_END=$(/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" | tail -1)
#!/bin/sh

var2=$(echo "$PREDICTION_END" | cut -d " " -f 1)
## debug
#set -x

MAXELEV=$(/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}')
. ~/.noaa.conf

PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | head -1)
PREDICTION_END=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | tail -1)

var2=$(echo "${PREDICTION_END}" | cut -d " " -f 1)

MAXELEV=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}')

while [ "$(date --date="@${var2}" +%D)" == "$(date +%D)" ]; do
START_TIME=$(echo "$PREDICTION_START" | cut -d " " -f 3-4)
@@ -15,11 +21,12 @@ while [ "$(date --date="@${var2}" +%D)" == "$(date +%D)" ]; do
if [ "${MAXELEV}" -gt 19 ]
then
echo "${1//" "}""${OUTDATE}" "$MAXELEV"
echo "/home/pi/receive.sh \"${1}\" $2 '${1//" "}'${OUTDATE} /home/pi/predict/weather.tle ${var1} '${TIMER}'" | at "$(date --date="TZ=\"UTC\" '${START_TIME}'" +"%H:%M %D")"
echo "'${NOAA_HOME}'/receive.sh \"${1}\" $2 '${1//" "}'${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \
${var1} '${TIMER}'" | at "$(date --date="TZ=\"UTC\" '${START_TIME}'" +"%H:%M %D")"
fi
nextpredict=$("${var2}" + 60)
PREDICTION_START=$(/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" "${nextpredict}" | head -1)
PREDICTION_END=$(/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" "${nextpredict}" | tail -1)
MAXELEV=$(/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" "${nextpredict}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}')
NEXTPREDICT=$("${var2}" + 60)
PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1)
PREDICTION_END=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | tail -1)
MAXELEV=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}')
var2=$(echo "${PREDICTION_END}" | cut -d " " -f 1)
done

Notiek ielāde…
Atcelt
Saglabāt