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.
 
 
 
 
 
 

43 lines
1.9 KiB

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