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.
 
 
 
 
 
 

71 lines
2.5 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. WEB_DIR=/var/www/wx
  12. STEPS=3
  13. echo "
  14. This script is used to sync webpanel updates and provide an easy
  15. way for users to keep their webpanel up to date with new features
  16. that are released - note that the first time you use this to migrate
  17. to the new webpanel contents, your Config.php file (containing locale
  18. settings) will be backed up to the $NOAA_HOME/bak/ directory and a
  19. replacement config.php put in its place. You can reference values you
  20. might have configured in the backup file to update $WEB_DIR/config.php
  21. to your liking.
  22. If you have made significant changes to any of the contents in the webpanel
  23. deployment, they likely WILL be destroyed by running this script as all
  24. files in $WEB_DIR are replaced with the exception of the following, which are
  25. left alone to preserve the captures:
  26. * audio/
  27. * images/
  28. * meteor/
  29. "
  30. read -rp "Are you sure you wish to proceed? (y/N) "
  31. if [[ $REPLY =~ ^[Nn]$ ]]; then
  32. log "Aborting webpanel sync" "ERROR"
  33. exit 0
  34. elif [[ $REPLY =~ ^[Yy]$ ]]; then
  35. log "Webpanel sync proceeding!" "INFO"
  36. else
  37. log "Aborting webpanel sync - unknown option '$REPLY'" "ERROR"
  38. exit 1
  39. fi
  40. log "1/$STEPS: Backing up PHP config file..." "INFO"
  41. if [ -f "$WEB_DIR/config.php" ]; then
  42. log " Found newer-style config file - backing up." "INFO"
  43. cp $WEB_DIR/config.php $NOAA_HOME/bak/config.php.backup
  44. elif [ -f "$WEB_DIR/Config.php" ]; then
  45. log " Found older-style config file - backing up." "INFO"
  46. cp $WEB_DIR/Config.php $NOAA_HOME/bak/Config.php.backup
  47. else
  48. log " Did not find any existing config file - proceeding." "INFO"
  49. fi
  50. log "1/$STEPS: Done backing up PHP config file" "INFO"
  51. log "2/$STEPS: Removing old PHP files (excluding images/audio)..." "INFO"
  52. find $WEB_DIR/ -mindepth 1 -type d -name "images" -prune -o -type d -name "audio" -prune -o -type d -name "meteor" -prune -o -print | xargs rm -rf
  53. log "2/$STEPS: Old PHP files removed" "INFO"
  54. log "3/$STEPS: Copying new PHP files..." "INFO"
  55. sudo cp -rp $NOAA_HOME/templates/webpanel/* $WEB_DIR/
  56. log "3/$STEPS: Done copying new PHP files" "INFO"
  57. log "Your old PHP config file has been copied to the bak/ directory" "INFO"
  58. log "Please update any settings you wish to preserve in $WEB_DIR/config.php" "INFO"
  59. log " including 'lang' and 'timezone' settings for display" "INFO"