Automatically exported from code.google.com/p/planningalerts
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

84 rader
2.5 KiB

  1. #!/bin/bash
  2. PLANNING_ROOT="/data/vhost/www.planningalerts.com/"
  3. PLANNING_BACKUPS="$PLANNING_ROOT/backups/"
  4. DEPLOYMENT_LOG_DIRECTORY="$PLANNING_ROOT/logs/"
  5. DEPLOYMENT_LOG="$DEPLOYMENT_LOG_DIRECTORY/deployment_log"
  6. BACKUP_DIRECTORY_NAME="planningalerts_backup_`date +%F_%Hh%Mm%Ss`"
  7. # This will be the name of the new backup directory
  8. BACKUP_DIRECTORY=$PLANNING_BACKUPS$BACKUP_DIRECTORY_NAME
  9. # Check to see if the PLANNING_ROOT directory exists and is writable
  10. if ! [ -w $PLANNING_ROOT ];
  11. then
  12. echo "Planning root directory: $PLANNING_ROOT doesn't exist, or isn't writable by this user";
  13. exit 1
  14. fi;
  15. # Check that the PLANNING_BACKUPS directory exists and is writable
  16. if ! [ -w $PLANNING_BACKUPS ];
  17. then
  18. echo "Planning backups directory: $PLANNING_BACKUPS doesn't exist, or isn't writable";
  19. exit 2
  20. fi;
  21. # Check that the DEPLOYMENT_LOG exists and is writable
  22. # FIXME - these checks could be better
  23. if [ ! -w $DEPLOYMENT_LOG -a ! -w $DEPLOYMENT_LOG_DIRECTORY ];
  24. then
  25. echo "Deployment log: $DEPLOYMENT_LOG doesn't exist, or isn't writable";
  26. exit 3
  27. fi;
  28. # Make a the directory to put the backup in
  29. mkdir $BACKUP_DIRECTORY
  30. # Move docs, cgi-bin and tools to the backups area
  31. # Copy data to the backups area
  32. # FIXME - which directories should probably be a variable
  33. echo
  34. echo "Backing up the current deployment to $BACKUP_DIRECTORY"
  35. (cd $PLANNING_ROOT;
  36. mv docs cgi-bin tools $BACKUP_DIRECTORY;
  37. cp -R data $BACKUP_DIRECTORY;
  38. );
  39. echo "Done"
  40. echo
  41. # Copy the new versions of docs, cgi-bin and tools to PLANNING_ROOT
  42. echo "Deploying the new versions of docs, cgi-bin, and tools"
  43. cp -R docs cgi-bin tools $PLANNING_ROOT
  44. # Copy the config files from $PLANNING_BACKUPS to $PLANNING_ROOT
  45. # FIXME - we should have a variable for which files to do here
  46. if [ -a $BACKUP_DIRECTORY/docs/include/config.php ];
  47. then
  48. echo "Copying back config.php";
  49. cp $BACKUP_DIRECTORY/docs/include/config.php $PLANNING_ROOT/docs/include/;
  50. else
  51. echo "No config.php to put back";
  52. fi;
  53. # Sort out .htaccess
  54. if [ -a $BACKUP_DIRECTORY/docs/.htaccess ];
  55. then
  56. echo "Copying back .htaccess";
  57. cp $BACKUP_DIRECTORY/docs/.htaccess $PLANNING_ROOT/docs/;
  58. # FIXME - should we rename the old .htaccess?
  59. else
  60. echo "No .htaccess to put back";
  61. fi;
  62. # Write something in the deployment log
  63. echo
  64. echo "Updating deployment log"
  65. echo "Deployed by $USER on `date`" >> $DEPLOYMENT_LOG
  66. echo
  67. echo "Remember to check that there are no changes needed in:"
  68. echo ".htaccess"
  69. echo "docs/include/config.php"
  70. echo