Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #~!/bin/bash/
- printf "Welcome to the Self service portal!\nChoose an option:\n1: Roll out environment.\n2: Remove environment.\n3: Reroll environment.\n4: Edit environment.\n";
- read option;
- if [ $option == 1 ]; then
- echo "What kind of environment? 'acceptatie','productie' or 'test'";
- read option;
- if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
- dicvar="$option";
- echo "How many webservers? Max 2, min 0.";
- read option;
- if [ $option == 0 ] || [ $option == 1 ] || [ $option == 2 ]; then
- numberweb=$option;
- echo "How many load balancers? Max 1, min 0.";
- read option;
- if [ $option == 0 ] || [ $option == 1 ]; then
- numberlb=$option;
- echo "How many databases? Max 1, min 0.";
- read option;
- if [ $option == 0 ] || [ $option == 1 ]; then
- numberdb=$option;
- 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
- (cd $dicvar && vagrant up);
- echo "Web: $numberweb, Lb: $numberlb, Db: $numberdb. Done making it!";
- exit 1;
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- elif [ $option == 2 ]; then
- echo "What kind of environment? 'acceptatie','productie' or 'test'";
- read option;
- if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
- dicvar="$option";
- (cd $dicvar && vagrant destroy -f);
- echo "Done removing it!!";
- exit 1;
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- elif [ $option == 3 ]; then
- echo "What kind of environment? 'acceptatie','productie' or 'test'";
- read option;
- if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
- dicvar="$option";
- (cd $dicvar && vagrant destroy -f && vagrant up);
- echo "Done rebuilding it!!";
- exit 1;
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- elif [ $option == 4 ]; then
- echo "What kind of environment? 'acceptatie','productie' or 'test'";
- read option;
- if [ "$option" == 'acceptatie' ] || [ "$option" == 'test' ] || [ "$option" == 'productie' ]; then
- dicvar="$option";
- echo "How much ram for the web and load balancer servers? 512 OR 1024.";
- read option;
- if [ $option == 512 ] || [ $option == 1024 ]; then
- numberram=$option;
- echo "How much ram for the database? 512 OR 1024.";
- read option;
- if [ $option == 512 ] || [ $option == 1024 ]; then
- numberramdb=$option;
- sed -i "s/MEMORY = 512/MEMORY = $numberram/g" $dicvar/Vagrantfile
- sed -i "s/MEMORY = 1024/MEMORY = $numberram/g" $dicvar/Vagrantfile
- sed -i "s/MEMORY_DB = 512/MEMORY_DB = $numberramdb/g" $dicvar/Vagrantfile
- sed -i "s/MEMORY_DB = 1024/MEMORY_DB = $numberramdb/g" $dicvar/Vagrantfile
- (cd $dicvar && vagrant reload);
- echo "Normal ram => $numberram, Database ram => $numberramdb. Done editing it!";
- exit 1;
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- else
- echo "Invalid Arg => exit";
- exit 1;
- fi
- else
- echo "Wrong number => exit";
- exit 1;
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement