Ver código fonte

First version, TODO: add auto build predict which is missing in ubuntu 20

pull/131/head
Pascal 3 anos atrás
pai
commit
fb92bd9b8a
9 arquivos alterados com 50 adições e 38 exclusões
  1. +23
    -12
      install.sh
  2. +4
    -4
      receive.sh
  3. +3
    -3
      receive_meteor.sh
  4. +1
    -0
      schedule.sh
  5. +1
    -1
      schedule_iss.sh
  6. +7
    -7
      schedule_meteor.sh
  7. +7
    -7
      schedule_sat.sh
  8. +3
    -3
      sun.py
  9. +1
    -1
      templates/nginx.cfg

+ 23
- 12
install.sh Ver arquivo

@@ -53,12 +53,12 @@ if [ "$raspbian_version" == "stretch" ]; then
fi

sudo apt update -yq
sudo apt install -yq predict \
python-setuptools \
sudo apt install -yq python-setuptools \
ntp \
unzip zip \
cmake \
libusb-1.0 \
sox \
libusb-1.0-0-dev \
sox libsox-fmt-mp3 \
at \
bc \
nginx \
@@ -72,8 +72,8 @@ sudo apt install -yq predict \
libjpeg9 \
libjpeg9-dev \
socat \
php7.2-fpm \
php7.2-sqlite \
php7.4-fpm \
php7.4-sqlite3 \
sqlite3

if [ "$raspbian_version" == "stretch" ]; then
@@ -131,6 +131,12 @@ else
log_done "WxToIMG installed"
fi

### install predict
$orig_dir=$(pwd)
cd software
#todo: Build predict
cd $orig_dir

### Install default config file
if [ -e "$HOME/.noaa.conf" ]; then
log_done "$HOME/.noaa.conf already exists"
@@ -192,23 +198,24 @@ crontab -l | grep -q "raspberry-noaa"
if [ $? -eq 0 ]; then
log_done "Crontab for schedule.sh already exists"
else
cat <(crontab -l) <(echo "1 0 * * * /home/pi/raspberry-noaa/schedule.sh") | crontab -
cat <(crontab -l) <(echo "1 0 * * * $HOME/raspberry-noaa/schedule.sh") | crontab -
log_done "Crontab installed"
fi
set -e

### Setup Nginx
log_running "Setting up Nginx..."
usr=$(whoami)
sudo cp templates/nginx.cfg /etc/nginx/sites-enabled/default
(
sudo mkdir -p /var/www/wx/images
sudo chown -R pi:pi /var/www/wx
sudo usermod -a -G www-data pi
sudo chown -R $usr:$usr /var/www/wx
sudo usermod -a -G www-data $usr
sudo chmod 775 /var/www/wx
)
sudo systemctl restart nginx
sudo cp -rp templates/webpanel/* /var/www/wx/
sed -i -e "s/pi/${usr}/g" "/var/www/wx/Model/Conn.php"
log_done "Nginx configured"

### Setup ramFS
@@ -298,7 +305,7 @@ read -rp "Enter your longitude (West values are negative): "
read -rp "Enter your timezone offset (ex: -3 for Argentina time): "
tzoffset=$REPLY

sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.noaa.conf"
sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/pi/${usr}/g" "$HOME/.noaa.conf"
sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.wxtoimgrc"
sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/$(echo "$lon * -1" | bc)/g" "$HOME/.predict/predict.qth"
sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/change_tz/$(echo "$tzoffset * -1" | bc)/g" "sun.py"
@@ -315,4 +322,8 @@ set +e
### Running WXTOIMG to have the user accept the licensing agreement
wxtoimg

sudo reboot
read -rp "reboot now? (Y/n)"
doreboot=$REPLY

[ ! -z "$doreboot" ] || sudo reboot
[ "$doreboot" == "y" ] && sudo reboot

+ 4
- 4
receive.sh Ver arquivo

@@ -53,12 +53,12 @@ done
rm "${NOAA_HOME}/map/${3}-map.png"

if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type) values ($5,\"$3\", 1,1);"
sqlite3 $HOME/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type) values ($5,\"$3\", 1,1);"
else
sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type) values ($5,\"$3\", 0,1);"
sqlite3 $HOME/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type) values ($5,\"$3\", 0,1);"
fi

pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")
pass_id=$(sqlite3 $HOME/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")

if [ -n "$CONSUMER_KEY" ]; then
log "Posting to Twitter" "INFO"
@@ -69,7 +69,7 @@ if [ -n "$CONSUMER_KEY" ]; then
fi
fi

sqlite3 /home/pi/raspberry-noaa/panel.db "update predict_passes set is_active = 0 where (predict_passes.pass_start) in (select predict_passes.pass_start from predict_passes inner join decoded_passes on predict_passes.pass_start = decoded_passes.pass_start where decoded_passes.id = $pass_id);"
sqlite3 $HOME/raspberry-noaa/panel.db "update predict_passes set is_active = 0 where (predict_passes.pass_start) in (select predict_passes.pass_start from predict_passes inner join decoded_passes on predict_passes.pass_start = decoded_passes.pass_start where decoded_passes.id = $pass_id);"

if [ "$DELETE_AUDIO" = true ]; then
log "Deleting audio files" "INFO"


+ 3
- 3
receive_meteor.sh Ver arquivo

@@ -82,13 +82,13 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then
rm "${METEOR_OUTPUT}/${3}.bmp"
rm "${METEOR_OUTPUT}/${3}.dec"

sqlite3 /home/pi/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type) values ($5,\"$3\", 1,0);"
pass_id=$(sqlite3 /home/pi/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")
sqlite3 $HOME/raspberry-noaa/panel.db "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type) values ($5,\"$3\", 1,0);"
pass_id=$(sqlite3 $HOME/raspberry-noaa/panel.db "select id from decoded_passes order by id desc limit 1;")
if [ -n "$CONSUMER_KEY" ]; then
log "Posting to Twitter" "INFO"
python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Resolución completa: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/${3}-122-rectified.jpg"
fi
sqlite3 /home/pi/raspberry-noaa/panel.db "update predict_passes set is_active = 0 where (predict_passes.pass_start) in (select predict_passes.pass_start from predict_passes inner join decoded_passes on predict_passes.pass_start = decoded_passes.pass_start where decoded_passes.id = $pass_id);"
sqlite3 $HOME/raspberry-noaa/panel.db "update predict_passes set is_active = 0 where (predict_passes.pass_start) in (select predict_passes.pass_start from predict_passes inner join decoded_passes on predict_passes.pass_start = decoded_passes.pass_start where decoded_passes.id = $pass_id);"
else
log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR"
fi

+ 1
- 0
schedule.sh Ver arquivo

@@ -28,6 +28,7 @@ if [ "$SCHEDULE_ISS" == "true" ]; then
"${NOAA_HOME}"/schedule_iss.sh "ISS (ZARYA)" 145.8000
fi
"${NOAA_HOME}"/schedule_meteor.sh "METEOR-M 2" 137.1000
"${NOAA_HOME}"/schedule_meteor.sh "METEOR-M2 2" 137.9000
"${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

+ 1
- 1
schedule_iss.sh Ver arquivo

@@ -31,7 +31,7 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do
echo ${SATNAME} "${OUTDATE}" "$MAXELEV"
echo "${NOAA_HOME}/receive_iss.sh \"${1}\" $2 ISS${OUTDATE} "${NOAA_HOME}"/predict/amateur.tle \
${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")"
sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);"
sqlite3 $HOME/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);"
fi
NEXTPREDICT=$(expr "${var2}" + 60)
PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/amateur.tle -p "${1}" "${NEXTPREDICT}" | head -1)


+ 7
- 7
schedule_meteor.sh Ver arquivo

@@ -10,12 +10,12 @@ fi
. "$HOME/.noaa.conf"
. "$NOAA_HOME/common.sh"

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)
PREDICTION_START=$(predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | head -1)
PREDICTION_END=$(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}')
MAXELEV=$(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
log "Pass prediction in progress" "INFO"
@@ -31,12 +31,12 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do
echo "${SATNAME}" "${OUTDATE}" "$MAXELEV"
echo "${NOAA_HOME}/receive_meteor.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \
${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")"
sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);"
sqlite3 $HOME/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV,1);"
fi
NEXTPREDICT=$(expr "${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}')
PREDICTION_START=$(predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1)
PREDICTION_END=$(predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | tail -1)
MAXELEV=$(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


+ 7
- 7
schedule_sat.sh Ver arquivo

@@ -18,12 +18,12 @@ fi
# $6 = Time to capture
# $7 = Satellite max elevation

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)
PREDICTION_START=$(predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | head -1)
PREDICTION_END=$(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}')
MAXELEV=$(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)
@@ -37,12 +37,12 @@ while [ "$(date --date="@${var2}" +%D)" = "$(date +%D)" ]; do
echo "${SATNAME}" "${OUTDATE}" "$MAXELEV"
echo "${NOAA_HOME}/receive.sh \"${1}\" $2 ${SATNAME}${OUTDATE} "${NOAA_HOME}"/predict/weather.tle \
${var1} ${TIMER} ${MAXELEV}" | at "$(date --date="TZ=\"UTC\" ${START_TIME}" +"%H:%M %D")"
sqlite3 /home/pi/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV, 1);"
sqlite3 $HOME/raspberry-noaa/panel.db "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active) values (\"$SATNAME\",$var1,$var2,$MAXELEV, 1);"
fi
NEXTPREDICT=$(expr "${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}')
PREDICTION_START=$(predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | head -1)
PREDICTION_END=$(predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" "${NEXTPREDICT}" | tail -1)
MAXELEV=$(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


+ 3
- 3
sun.py Ver arquivo

@@ -2,12 +2,12 @@
import ephem
import time
import sys
timezone = change_tz + time.localtime().tm_isdst
timezone = 1 + time.localtime().tm_isdst
date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1])-(timezone*60*60)))

obs=ephem.Observer()
obs.lat='change_latitude'
obs.long='change_longitude'
obs.lat='53.06272'
obs.long='8.86'
obs.date = date

sun = ephem.Sun(obs)


+ 1
- 1
templates/nginx.cfg Ver arquivo

@@ -12,7 +12,7 @@ server {

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}

# Rewrite the old path yyyy/mm/dd/ to /images/


Carregando…
Cancelar
Salvar