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.
 
 
 
 
 
 

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