You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
2.7 KiB

  1. #!/bin/bash
  2. ### Run as a normal user
  3. if [ $EUID -eq 0 ]; then
  4. echo "This script shouldn't be run as root."
  5. exit 1
  6. fi
  7. ## import common lib
  8. . "$HOME/.noaa.conf"
  9. . "$HOME/.tweepy.conf"
  10. . "$NOAA_HOME/common.sh"
  11. if pgrep "rtl_fm" > /dev/null
  12. then
  13. log "There is an already running rtl_fm instance but I dont care for now, I prefer this pass" "INFO"
  14. pkill -9 -f rtl_fm
  15. fi
  16. # $1 = Satellite Name
  17. # $2 = Frequency
  18. # $3 = FileName base
  19. # $4 = TLE File
  20. # $5 = EPOC start time
  21. # $6 = Time to capture
  22. # $7 = Satellite max elevation
  23. log "Starting rtl_fm record" "INFO"
  24. timeout "${6}" /usr/local/bin/rtl_fm ${BIAS_TEE} -M fm -f ${2}M -s 48k $GAIN -E dc -E wav -E deemp -F 9 - | sox -t raw -r 48k -c 1 -b 16 -e s - -t wav "${NOAA_OUTPUT}/audio/${3}.wav" rate 11025
  25. if [ -f "$NOAA_HOME/demod.py" ]; then
  26. log "Decoding ISS pass" "INFO"
  27. python3 "$NOAA_HOME/demod.py" "${NOAA_OUTPUT}/audio/${3}.wav" "${NOAA_OUTPUT}/images/"
  28. decoded_pictures="$(find ${NOAA_OUTPUT}/images/ -iname "${3}*png")"
  29. img_count=0
  30. for image in $decoded_pictures; do
  31. log "Decoded image: $image" "INFO"
  32. ((img_count++))
  33. done
  34. if [ "$img_count" -gt 0 ]; then
  35. /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-0.png" "${NOAA_OUTPUT}/images/thumb/${3}-0.png"
  36. sqlite3 "$NOAA_HOME/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, sat_type, img_count) values ($5,\"$3\",1,2,$img_count);"
  37. pass_id=$(sqlite3 "$NOAA_HOME/panel.db" "select id from decoded_passes order by id desc limit 1;")
  38. if [ -n "$CONSUMER_KEY" ]; then
  39. log "Posting to Twitter" "INFO"
  40. if [ "$img_count" -eq 1 ]; then
  41. 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}-0.png"
  42. elif [ "$img_count" -eq 2 ]; then
  43. /usr/bin/convert -thumbnail 300 "${NOAA_OUTPUT}/images/${3}-1.png" "${NOAA_OUTPUT}/images/thumb/${3}-1.png"
  44. python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE} Mas imagenes: https://weather.reyni.co/detail.php?id=$pass_id" "$7" "${NOAA_OUTPUT}/images/${3}-0.png" "${NOAA_OUTPUT}/images/${3}-1.png"
  45. fi
  46. fi
  47. sqlite3 "$NOAA_HOME/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);"
  48. else
  49. log "Did not receive any images from ISS" ERROR
  50. sqlite3 "$NOAA_HOME/panel.db" "update predict_passes set is_active = 0 where predict_passes.pass_start = $5;"
  51. fi
  52. fi