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.
 
 
 
 
 
 

69 lines
2.1 KiB

  1. #!/bin/bash
  2. set -e
  3. ### Run as a normal user
  4. if [ $EUID -eq 0 ]; then
  5. echo "This script shouldn't be run as root."
  6. exit 1
  7. fi
  8. ## import common lib
  9. . "$HOME/.noaa.conf"
  10. . "$NOAA_HOME/common.sh"
  11. if [ -f "$NOAA_HOME/panel.db" ]; then
  12. die "Seems like there's no panel.db database in your project folder"
  13. fi
  14. STEPS="6"
  15. datetime=$(date +"%Y%m%d-%H%M%S")
  16. log "1/$STEPS: Backing up database" "INFO"
  17. cp "$NOAA_HOME/panel.db" "$NOAA_HOME/panel.db.bak-$datetime"
  18. log "1/$STEPS: Database backup done: panel.db.bak-$datetime" "INFO"
  19. log "2/$STEPS: Creating new columns" "INFO"
  20. set +e
  21. sqlite3 "$NOAA_HOME/panel.db" "alter table decoded_passes add column img_count integer;"
  22. sqlite3 "$NOAA_HOME/panel.db" "alter table decoded_passes add column sat_type integer;"
  23. set -e
  24. log "2/$STEPS: img_count and sat_type columns created" "INFO"
  25. log "3/$STEPS: Migrating is_noaa column" "INFO"
  26. sqlite3 "$NOAA_HOME/panel.db" "update decoded_passes set sat_type = is_noaa;"
  27. log "3/$STEPS: is_noaa column migration done" "INFO"
  28. log "4/$STEPS: Setting up SCHEDULE_ISS on .noaa.conf" "INFO"
  29. set +e
  30. if ! grep -q SCHEDULE_ISS "$HOME/.noaa.conf"; then
  31. echo "SCHEDULE_ISS=\"false\"" >> "$HOME/.noaa.conf"
  32. log "4/$STEPS: SCHEDULE_ISS is set now on .noaa.conf" "INFO"
  33. else
  34. log "4/$STEPS: SCHEDULE_ISS was already set on .noaa.conf" "INFO"
  35. fi
  36. set -e
  37. log "5/$STEPS: Updating PHP files" "INFO"
  38. sudo cp "$NOAA_HOME/templates/webpanel/Model/Conn.php" "/var/www/wx/Model/Conn.php"
  39. sudo cp "$NOAA_HOME/templates/webpanel/Views/V_viewLastImages.php" "/var/www/wx/Views/V_viewLastImages.php"
  40. log "5/$STEPS: PHP files updated" "INFO"
  41. log "6/$STEPS: Installing pd120_decoder" "INFO"
  42. if [ -f "$NOAA_HOME/demod.py" ]; then
  43. log "6/$STEPS: pd120_decoder already installed" "INFO"
  44. else
  45. wget -qr https://github.com/reynico/pd120_decoder/archive/master.zip -O /tmp/master.zip
  46. (
  47. cd /tmp
  48. unzip master.zip
  49. cd pd120_decoder-master/pd120_decoder/
  50. pip3 install --user -r requirements.txt
  51. cp "{demod.py,utils.py}" "$NOAA_HOME"
  52. )
  53. log "6/$STEPS: pd120_decoder installed" "INFO"
  54. fi