|
#!/bin/bash |
|
set -euo pipefail |
|
|
|
|
|
if [ `git --version &> /dev/null; echo $?` -ne '0' ]; then |
|
echo '===> Installing git ...' |
|
|
|
sudo apt install git -y |
|
else |
|
echo '===> Skipping git installation ...' |
|
fi |
|
|
|
echo "'git --version' output:" |
|
git --version |
|
|
|
|
|
|
|
|
|
if [ `curl --version &> /dev/null; echo $?` -ne '0' ]; then |
|
echo '===> Installing curl ...' |
|
|
|
sudo apt install curl -y |
|
else |
|
echo '===> Skipping curl installation ...' |
|
fi |
|
|
|
echo "'curl --version' output:" |
|
curl --version |
|
|
|
|
|
|
|
|
|
if [ `asdf --version &> /dev/null; echo $?` -ne '0' ]; then |
|
echo '===> Installing asdf ...' |
|
|
|
# clone asdf repository from github if it doesn't exist. |
|
[ ! -d ~/.asdf ] && git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1 |
|
|
|
# ~/.asdf.init contains commands to initalize asdf. |
|
echo '. "$HOME"/.asdf/asdf.sh' > ~/.asdf.init |
|
echo '. "$HOME"/.asdf/completions/asdf.bash' >> ~/.asdf.init |
|
|
|
# add call to .asdf.init if it doesn't exist in the .bashrc file |
|
[ `grep -q '.asdf.init' ~/.bashrc; echo $?` -ne '0' ] && echo '. "$HOME"/.asdf.init' >> .bashrc |
|
|
|
. ~/.asdf.init |
|
else |
|
echo '===> Skipping asdf installation ...' |
|
fi |
|
|
|
echo "'asdf --version' output:" |
|
asdf --version |
|
|
|
|
|
|
|
|
|
if [ `ruby --version &> /dev/null; echo $?` -ne '0' ]; then |
|
echo '===> Installing ruby ...' |
|
|
|
echo '...... Installing dependencies ...' |
|
sudo apt install libssl-dev libyaml-dev -y |
|
|
|
echo '...... Installing ruby using asdf ...' |
|
asdf plugin add ruby |
|
asdf install ruby latest |
|
asdf global ruby latest |
|
else |
|
echo '===> Skipping ruby installation ...' |
|
fi |
|
|
|
echo "'ruby --version' output:" |
|
ruby --version |
|
|
|
|
|
|
|
|
|
if [ `sqlite3 --version &> /dev/null; echo $?` -ne '0' ]; then |
|
echo '===> Installing sqlite3 ...' |
|
|
|
sudo apt install sqlite3 -y |
|
else |
|
echo '===> Skipping sqlite3 installation ...' |
|
fi |
|
|
|
echo "'sqlite3 --version' output:" |
|
sqlite3 --version |
|
|
|
|
|
|
|
|
|
if [ `rails --version &> /dev/null; echo $?` -ne '0' ]; then |
|
echo '===> Installing ruby on rails ...' |
|
|
|
gem install rails |
|
gem install foreman |
|
else |
|
echo '===> Skipping ruby on rails installation ...' |
|
fi |
|
|
|
echo "'rails --version' output:" |
|
rails --version |
|
|
|
|
|
|
|
|
|
asdf reshim |
|
echo '===> Done!' |