This is a brief illustration with regards to the automatic installation of the sofware packages such as NVM, Node, Docker, Docker Compose, Openssl and Git using scripting.
The files for the automation is written in 'Shell Scripting' language. These are installed in Ubuntu Server 16.04 LTS.
Parent script is the master.sh script which internally invokes the other child scripts over ssh onto defined hostnames in order to execute the respective installations.
After launching two servers in ubuntu, we have to establish a connection between these servers. Such that if we run a script in one server it will automatically get installed in another one.
Below are the set of commands for generating the rsa keys of server:
ssh-keygen -t rsa
cd .ssh
cat id_rsa.pubcopy the content of id_rsa.pub in server 2 run the below commands
cd .ssh
vi authorized_keyspaste the copied content in the above
By doing this we can successfully establish the passwordless ssh connection between two servers
test it by executing : ssh username@hostname
we have to give the initials for the installation used in yhe script such as
red="$(tput setaf 1)"
green="$(tput setaf 2)"
blue="$(tput setaf 4)"
reset="$(tput sgr0)"
bold="$(tput bold)"
->Old Version
to uninstall old if it is present then run this command
sudo apt-get remove docker docker-engine docker.io->Update
to update ubuntu after removing the older version (if present)
sudo apt-get update
sudo apt-get libcurl4->Installing
To install a package we have to allow apt to use a repository over HTTPS
sudo apt-get install apt-transport-https ca-certificates curl software-properties-commonwe have to add docker offical GPG key from the offical docker url for ubuntu
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -to verify if the downloaded key is present or not
sudo apt-key fingerprint 0EBFCD88we have to add a repository by using this key for the furthur process
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"Now again update the ubuntu
sudo apt-get updateAfter completion of this finally run the installation command
sudo apt-get install docker-ce
apt-cache madison docker-ceTo define the version of Docker, which has to be installed in ubuntu
sudo apt-get install docker-ce=18.06.0~ce~3-0~ubuntu .Finally check if the Docker is successfully installed or not
docker --versionInitially write "version='1.18.0'" to dowload a particular version package
-> Installing Docker Compose
Install the package using the below link
sudo curl -L https://github.com/docker/compose/releases/download/$version/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose > ~/autom/dockercompose.logAfter installing set the permissions
sudo chmod +x /usr/local/bin/docker-composeto check wether it is installed or not
docker-compose --version-> To install git for ubuntu
By running a single command you can able to install git package
apt-get install git-core-> Check version
verify wether it is installrd or not
git --versionTo download particular version, initially write 'version="1.1.1"'
-> Install Open SSL
to extract run the following command
wget https://www.openssl.org/source/openssl-$version.tar.gzto tar and zip run
tar xvf openssl-$version.tar.gzto open the file run
cd openssl-$versionto explore the file
sudo ./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)'to execute
sudo make
sudo make installTo verify wether it is installed or not
openssl --versionInitially give node & nvm versions to download of a particular version
write 'version=8.12.0"
nvm_version="v0.33.2"
-> Install nvm in a directory
wget https://raw.githubusercontent.com/creationix/nvm/$nvm_version/install.shrun the script
bash install.shExport the command from nvm.log which loads the nvm
----> Node.JS
Node.js version comes default with the NVM package
we have to find the version first locally,if find run locally otherwise run remotely
nvm ls | grep "$version"write 'for loop' condition for above code
Find the version remotely
nvm ls-remote | grep "$version"write 'for loop' condition for above code
If found install Node.JS for $version
nvm install $versionFinally use the Node.JS
nvm use $version