Automatically exported from code.google.com/p/planningalerts
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

104 Zeilen
2.8 KiB

  1. #!/bin/bash
  2. # Check to see if the PLANNING_ROOT directory exists and is writable
  3. if ! [ -w $PLANNING_ROOT ];
  4. then
  5. echo "Planning root directory: $PLANNING_ROOT doesn't exist, or isn't writable by this user";
  6. exit 1
  7. fi;
  8. # Check that the PLANNING_BACKUPS directory exists and is writable
  9. if ! [ -w $PLANNING_BACKUPS ];
  10. then
  11. echo "Planning backups directory: $PLANNING_BACKUPS doesn't exist, or isn't writable";
  12. exit 2
  13. fi;
  14. # Check that the DEPLOYMENT_LOG exists and is writable
  15. # FIXME - these checks could be better
  16. if [ ! -w $DEPLOYMENT_LOG -a ! -w $DEPLOYMENT_LOG_DIRECTORY ];
  17. then
  18. echo "Deployment log: $DEPLOYMENT_LOG doesn't exist, or isn't writable";
  19. exit 3
  20. fi;
  21. # Make a the directory to put the backup in
  22. mkdir $BACKUP_DIRECTORY
  23. # Move docs, cgi-bin and tools to the backups area
  24. # Copy data to the backups area
  25. # FIXME - which directories should probably be a variable
  26. echo
  27. echo "Backing up the current deployment to $BACKUP_DIRECTORY"
  28. (cd $PLANNING_ROOT;
  29. mv docs cgi-bin tools $BACKUP_DIRECTORY;
  30. cp -R data $BACKUP_DIRECTORY;
  31. );
  32. echo "Done"
  33. echo
  34. echo "Enter mysql db name:"
  35. read MYSQL_DB_NAME
  36. echo $MYSQL_DB_NAME
  37. export $MYSQL_DB_NAME
  38. echo "Enter mysql username:"
  39. read MYSQL_USERNAME
  40. export $MYSQL_USERNAME
  41. echo "Enter mysql password:"
  42. read MYSQL_PASSWORD
  43. export $MYSQL_PASSWORD
  44. echo "Generating python scrapers"
  45. # Generate the python cgi files
  46. ./generateCGIScripts.py
  47. echo "Done generating python scrapers"
  48. # Copy the new versions of docs, cgi-bin and tools to PLANNING_ROOT
  49. echo "Deploying the new versions of docs, cgi-bin, and tools"
  50. cp -R docs cgi-bin tools $PLANNING_ROOT
  51. # Copy the config files from $PLANNING_BACKUPS to $PLANNING_ROOT
  52. # FIXME - we should have a variable for which files to do here
  53. if [ -a $BACKUP_DIRECTORY/docs/include/config.php ];
  54. then
  55. echo "Copying back config.php";
  56. cp $BACKUP_DIRECTORY/docs/include/config.php $PLANNING_ROOT/docs/include/;
  57. else
  58. echo "No config.php to put back";
  59. fi;
  60. # Sort out .htaccess
  61. if [ -a $BACKUP_DIRECTORY/docs/.htaccess ];
  62. then
  63. echo "Copying back .htaccess";
  64. cp $BACKUP_DIRECTORY/docs/.htaccess $PLANNING_ROOT/docs/;
  65. # FIXME - should we rename the old .htaccess?
  66. else
  67. echo "No .htaccess to put back";
  68. fi;
  69. # Now make all the files group writable
  70. echo "Making the planningalerts root directory group writable."
  71. chmod -R g+w $PLANNING_ROOT
  72. echo "Enter a reason for deployment:"
  73. read REASON
  74. echo
  75. echo $REASON
  76. # Write something in the deployment log
  77. echo
  78. echo "Updating deployment log"
  79. echo -e "Deployed by $USER on `date`\nReason: $REASON" >> $DEPLOYMENT_LOG
  80. echo
  81. # Email the team
  82. echo "emailing the team"
  83. echo -e "www.planningalerts.com redeployed by $USER on `date`\nReason: $REASON" | mail -s "PlanningAlerts Deployment" $TEAM_EMAIL
  84. echo
  85. echo "Remember to check that there are no changes needed in:"
  86. echo ".htaccess"
  87. echo "docs/include/config.php"
  88. echo