Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

57 řádky
2.3 KiB

  1. #!/bin/bash
  2. ## import common lib
  3. . "$HOME/.noaa.conf"
  4. . "$HOME/.tweepy.conf"
  5. . "$NOAA_HOME/common.sh"
  6. # TODO: Warn the user
  7. BASEPATH="/var/www/wx/image"
  8. FINALPATH="/var/www/wx/images"
  9. SAT_NAMES="NOAA15 NOAA18 NOAA19 METEOR-M2"
  10. DB_PATH="${NOAA_HOME}/panel.db"
  11. (
  12. cd "${RAMFS_AUDIO}" || exit 1
  13. sqlite3 < "${NOAA_HOME}/panel.sql"
  14. )
  15. cd "$BASEPATH" || exit 1
  16. mkdir -p "$FINALPATH/thumb"
  17. for filename in $(find . -name *.jpg); do
  18. basename="$(echo "$filename" | sed 's~.*/~~')"
  19. for prefix in $SAT_NAMES; do
  20. basedate="$(echo "$basename" | sed -e "s/^$prefix//" | cut -f1,2 -d'-' | sed -e "s/-//")"
  21. if [[ $basename == *"$prefix"* ]]; then
  22. sat_name=$prefix
  23. fi
  24. done
  25. date_normalized=$(echo "$basedate" | sed -e "s/^$sat_name//;s/./&:/12;s/./&:/10;s/./& /8;s/./&\//6;s/./&\//4")
  26. epoch_date=$(date "+%s" -d "$date_normalized")
  27. passname=$(echo "$basename" | cut -f1,2 -d'-')
  28. echo "Migration in progress: $basename"
  29. cp "$BASEPATH/$filename" "$FINALPATH"
  30. convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$filename"
  31. if [[ $basename == *"METEOR"* ]]; then
  32. sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);"
  33. sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);"
  34. sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);"
  35. elif [[ $basename == *"ZA"* ]]; then
  36. sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);"
  37. if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then
  38. sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);"
  39. else
  40. sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);"
  41. fi
  42. fi
  43. mv "${RAMFS_AUDIO}/panel.db" "$DB_PATH"
  44. echo "Done."
  45. echo ""
  46. done