Advertisement
Guest User

Untitled

a guest
May 3rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3.  
  4. $deploymentAction = $argv[1];
  5. $verNum= $argv[2];
  6. $ipAdd=$argv[3];
  7.  
  8. if(empty($argv[1] && $argv[2] && $argv[3] ){
  9.  
  10. echo " DEPLOYMENT ACTIONS \n ";
  11. echo "Please Choose a Function followed by Version Number and <IP>\n";
  12.  
  13. echo "----------------------------------------------------\n";
  14. echo " (1)-vpaks: (2)-automatedInstall: (3)-Rollback \n";
  15. echo "----------------------------------------------------\n";
  16. echo " 1.0(Dev) | 2.0(QA) | 3.0(Prod.) \n";
  17. }
  18.  
  19. }
  20.  
  21. function bundleDevPackage($verNum){
  22.  
  23. echo "\nCreating Dev pack\n";
  24. echo "Syncing contents\n";
  25. echo "SCP'ing to <192.168.1.3>\n";
  26.  
  27. shell_exec("
  28. cd ~/
  29. mkdir '$mach'-'$verNum'
  30. rsync -av /var/www/lol.com/public_html/deployment ~/'$mach'-'$verNum'
  31. tar -cvzf $mach'-'$verNum.tar.gz $mach'-'$verNum
  32. scp -r $mach'-'$verNum.tar.gz cmondragon@$ipAdd:
  33.  
  34. ");
  35. }
  36.  
  37. }
  38. function getVerNum(){
  39.  
  40. $servername = "localhost";
  41. $username = "root";
  42. $password = "chemistry";
  43. $dbname = "Versions";
  44.  
  45.  
  46. $conn = new mysqli($servername, $username, $password, $dbname);
  47.  
  48. if ($conn->connect_error)
  49. {
  50. die("Connection failed: " . $conn->connect_error);
  51. }
  52.  
  53. $sql = "SELECT versionNumber FROM Versions LIMIT 1";
  54. $result = $conn->query($sql);
  55.  
  56. if ($result->num_rows > 0){
  57. while($row = $result->fetch_assoc()) {
  58. $rowVersion = $row["versionNumber"];
  59. print "Version Number: " . $rowVersion;
  60. }
  61. } else {
  62. echo "No Version Number\n";
  63. }
  64.  
  65. }
  66.  
  67. //------------------------------------------------------------------
  68. }
  69. switch (true)
  70. {
  71. case "vpaks":
  72. echo "Returning Current Version Number from Database";
  73. getVerNum();
  74. //ideally this would be split into frontend/backend/dmz content
  75. echo "Bundling Contents from ../public_html/deployment";
  76. echo "Sending tar package to $ipAdd";
  77.  
  78. bundleDevPackage()
  79.  
  80. break;
  81. case "automatedInstall":
  82.  
  83. break;
  84. case "rollback":
  85. echo "Rolling Back to a previous version";
  86. break;
  87. }
  88.  
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement