Advertisement
Guest User

Untitled

a guest
May 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. #~!/bin/bash/
  2. printf "Welcome to the Self service portal!\nChoose an option:\n1: Roll out environment.\n2: Remove environment.\n3: Reroll environment.\n4: Edit environment.\n";
  3. read option;
  4. if [ $option == 1 ]; then
  5. echo "What kind of environment? 'acceptatie','productie' or 'test'";
  6. read option;
  7. if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
  8. dicvar="$option";
  9. echo "How many webservers? Max 2, min 0.";
  10. read option;
  11. if [ $option == 0 ] || [ $option == 1 ] || [ $option == 2 ]; then
  12. numberweb=$option;
  13.  
  14. echo "How many load balancers? Max 1, min 0.";
  15. read option;
  16. if [ $option == 0 ] || [ $option == 1 ]; then
  17. numberlb=$option;
  18.  
  19. echo "How many databases? Max 1, min 0.";
  20. read option;
  21.  
  22. if [ $option == 0 ] || [ $option == 1 ]; then
  23. numberdb=$option;
  24.  
  25. printf "# -*- mode: ruby -*-\n# vi: set ft=ruby :\n\nNUMBER_WEBSERVERS = $numberweb\nNUMBER_WEBSERVERS_FOR_LB = $numberweb\nSTART_NUM_WEB = 0\nNUMBER_LB = $numberlb\nNUMBER_DATA = $numberdb\nMEMORY = 512\nMEMORY_DB = 1024\nDIR = '$dicvar'\n" | cat - VagrantfileTemplate > temp && mv temp $dicvar/Vagrantfile
  26. (cd $dicvar && vagrant up);
  27. echo "Web: $numberweb, Lb: $numberlb, Db: $numberdb. Done making it!";
  28. exit 1;
  29. else
  30. echo "Invalid Arg => exit";
  31. exit 1;
  32. fi
  33. else
  34. echo "Invalid Arg => exit";
  35. exit 1;
  36. fi
  37. else
  38. echo "Invalid Arg => exit";
  39. exit 1;
  40. fi
  41. else
  42. echo "Invalid Arg => exit";
  43. exit 1;
  44. fi
  45. elif [ $option == 2 ]; then
  46. echo "What kind of environment? 'acceptatie','productie' or 'test'";
  47. read option;
  48. if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
  49. dicvar="$option";
  50. (cd $dicvar && vagrant destroy -f);
  51. echo "Done removing it!!";
  52. exit 1;
  53. else
  54. echo "Invalid Arg => exit";
  55. exit 1;
  56. fi
  57. elif [ $option == 3 ]; then
  58. echo "What kind of environment? 'acceptatie','productie' or 'test'";
  59. read option;
  60. if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
  61. dicvar="$option";
  62. (cd $dicvar && vagrant destroy -f && vagrant up);
  63.  
  64. echo "Done rebuilding it!!";
  65. exit 1;
  66. else
  67. echo "Invalid Arg => exit";
  68. exit 1;
  69. fi
  70. elif [ $option == 4 ]; then
  71. echo "What kind of environment? 'acceptatie','productie' or 'test'";
  72. read option;
  73. if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
  74. dicvar="$option";
  75. echo "How much ram for the web and load balancer servers? 512 OR 1024.";
  76. read option;
  77.  
  78. if [ $option == 512 ] || [ $option == 1024 ]; then
  79. numberram=$option;
  80.  
  81. echo "How much ram for the database? 512 OR 1024.";
  82. read option;
  83.  
  84. if [ $option == 512 ] || [ $option == 1024 ]; then
  85. numberramdb=$option;
  86.  
  87. sed -i "s/MEMORY = 512/MEMORY = $numberram/g" $dicvar/Vagrantfile
  88. sed -i "s/MEMORY = 1024/MEMORY = $numberram/g" $dicvar/Vagrantfile
  89.  
  90. sed -i "s/MEMORY_DB = 512/MEMORY_DB = $numberramdb/g" $dicvar/Vagrantfile
  91. sed -i "s/MEMORY_DB = 1024/MEMORY_DB = $numberramdb/g" $dicvar/Vagrantfile
  92.  
  93. (cd $dicvar && vagrant reload);
  94. echo "Normal ram => $numberram, Database ram => $numberramdb. Done editing it!";
  95. exit 1;
  96. else
  97. echo "Invalid Arg => exit";
  98. exit 1;
  99. fi
  100. else
  101. echo "Invalid Arg => exit";
  102. exit 1;
  103. fi
  104. else
  105. echo "Invalid Arg => exit";
  106. exit 1;
  107. fi
  108. else
  109. echo "Wrong number => exit";
  110. exit 1;
  111. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement