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.
 
 
 
 
 
 

47 lines
1.4 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. datetime=$(date +"%Y%m%d-%H%M%S")
  12. log "1/3: Backing up database" "INFO"
  13. cp "$NOAA_HOME/panel.db" "$NOAA_HOME/panel.db.bak-$datetime"
  14. log "1/3: Database backup done: panel.db.bak-$datetime" "INFO"
  15. log "2/3: Creating new columns" "INFO"
  16. set +e
  17. sqlite3 "$NOAA_HOME/panel.db" "alter table decoded_passes add column img_count integer;"
  18. sqlite3 "$NOAA_HOME/panel.db" "alter table decoded_passes add column sat_type integer;"
  19. set -e
  20. log "2/3: img_count and sat_type columns created" "INFO"
  21. log "3/3: Migrating is_noaa column" "INFO"
  22. sqlite3 "$NOAA_HOME/panel.db" "update decoded_passes set sat_type = is_noaa;"
  23. log "3/3: is_noaa column migration done" "INFO"
  24. log "4/3: Setting up SCHEDULE_ISS on .noaa.conf" "INFO"
  25. set +e
  26. if ! grep -q SCHEDULE_ISS "$HOME/.noaa.conf"; then
  27. echo "SCHEDULE_ISS=\"false\"" >> "$HOME/.noaa.conf"
  28. log "4/3: SCHEDULE_ISS is set now on .noaa.conf" "INFO"
  29. else
  30. log "4/3: SCHEDULE_ISS was already set on .noaa.conf" "INFO"
  31. fi
  32. set -e
  33. log "3/3: Updating PHP files" "INFO"
  34. sudo cp "$NOAA_HOME/templates/webpanel/Model/Conn.php" "/var/www/wx/Model/Conn.php"
  35. sudo cp "$NOAA_HOME/templates/webpanel/Views/V_viewLastImages.php" "/var/www/wx/Views/V_viewLastImages.php"
  36. log "3/3: PHP files updated" "INFO"