Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to adify to work with minimal OS installations #2

Merged
merged 10 commits into from
Jan 19, 2018
193 changes: 160 additions & 33 deletions adify.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
### PRELUDE ###
# This script is responsible for running all the commands required to setup an ubuntu computer
# for me to work effectively. Hence, it adifies the computer.
#!/usr/bin/env bash

### ABOUT ###
# This script is responsible for running all the commands required to setup an
# Ubuntu/CentOS/MacOS computer for me to work effectively.
# In other words, it "adifies" the computer.
# This script doesn't not include the tools required to do "Work" related stuff

### USAGE ###
# From the terminal:
# $ bash <(wget -qO- https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.sh)
# OR
# $ bash <(curl -s https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.sh)

# TODO: Make it runnable on other OS.
# This Script is setup to run only on Ubuntu computers

Expand All @@ -12,79 +21,197 @@
# - Admin Privilleges of the computer being adified
# - Adi (for credentials)

### PRELUDE ###
# Installing `curl` if not installed already
# Detecting OS
echo """
==========================================================
Detecting OS.........
==========================================================
"""
OS="`uname`"
case $OS in
'Linux')
OS="`nawk -F= '/^NAME/{print $2}' /etc/os-release`"
case $OS in
"\"Ubuntu\"")
echo """
OS is $OS.. Adify is supported for $OS! :)
"""
pm="sudo apt-get"
;;
"\"Centos\"")
echo """
OS is $OS.. Adify is supported for $OS! :)
"""
pm="sudo yum"
;;
esac
;;
'FreeBSD')
OS='FreeBSD'
echo """
OS is FreeBSD.. Adify isn't supported for FreeBSD. :(
"""
exit 1
;;
'WindowsNT')
OS='Windows'
echo """
OS is Windows.. Adify isn't supported for Windows. :(
"""
exit 1
;;
'Darwin')
OS='Mac'
echo """
OS is Mac.. Adify is supported for Mac! :)
"""
pm="brew"
;;
'SunOS')
OS='Solaris'
echo """
OS is Solaris.. Adify isn't supported for Solaris.
"""
exit 1
;;
'AIX')
echo """
OS is AIX.. Adify isn't supported for AIX.
"""
exit 1
;;
*)
;;
esac


echo """
==========================================================
Detecting Shell type.........
==========================================================
"""
case $SHELL in
"/bin/zsh")
shell="zsh"
echo """
Shell is $shell.. Adify is supported for $shell! :)
"""
;;
"/bin/bash")
shell="bash"
echo """
Shell is $shell.. Adify is supported for $shell! :)
"""
;;
esac

### CURL ###
# Install curl, as it's an important tool!!
echo """
==========================================================
Installing Curl.. Can't live without that!
==========================================================
"""
$pm install -y curl


### GIT ###
# Running all three package manager commands.
echo """
==========================================================
Installing Git to get adify.
==========================================================
"""
sudo apt-get install -y git
sudo yum install -y git
brew install git
$pm install -y git

ex_version="1.5.2"
otp_version="20.0"
asdf_version="0.4.0"

if [ ! -d "$HOME/dot-adify" ]; then
if [ ! -d "$HOME/adify" ]; then
echo """
==========================================================
Adifying for the first time....
==========================================================
Adifying for the first time....

This script is responsible for running all the commands required to setup an ubuntu computer
for me to work effectively. Hence, it adifies the computer.
This script doesn't not include the tools required to do 'work' elated stuff by default
==========================================================
This script is responsible for running all the commands required to setup an ubuntu computer
for me to work effectively. Hence, it adifies the computer.
This script doesn't not include the tools required to do 'work' elated stuff by default
==========================================================
"""

echo """
==========================================================
Fetching Adifying files...
==========================================================
==========================================================
Fetching Adifying files...
==========================================================
"""
git clone --depth=1 https://github.com/aditya7iyengar/adify.git "$HOME/dot-adify"
git clone --depth=1 https://github.com/aditya7iyengar/adify.git "$HOME/adify"

cd "$HOME/.adify"
cd "$HOME/adify"
[ "$1" = "ask" ] && export ADIFYASK="true"
[ "$1" = "work" ] && export ADIFYWORK="true"


echo """
==========================================================
Installing Asdf $asdf_version for Elixir and Erlang...
==========================================================
==========================================================
Installing Asdf $asdf_version for Elixir and Erlang...
==========================================================
"""
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v${asdf_version}

case $OS in
'Mac')
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.${shell}rc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.${shell}rc
source ~/.${shell}rc
;;
"\"Ubuntu\"")
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.${shell}rc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.${shell}rc
source ~/.${shell}rc
;;
"\"Centos\"")
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.${shell}rc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.${shell}rc
source ~/.${shell}rc
;;
esac

chmod 777 $HOME/.asdf/asdf.sh
chmod 777 $HOME/.asdf/completions/asdf.bash

. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash

echo """
==========================================================
Installing ERLANG $otp_version to run Adifier app....
==========================================================
==========================================================
Installing ERLANG $otp_version to run Adifier app....
==========================================================
"""
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf install erlang ${otp_version}

echo """
==========================================================
Installing ELIXIR $ex_version to run Adifier app....
==========================================================
==========================================================
Installing ELIXIR $ex_version to run Adifier app....
==========================================================
"""
asdf add-plugin elixir https://github.com/asdf-vm/asdf-elixir.git
asdf install elixir ${ex_version}

echo """
==========================================================
Running Adifier... (mix adify)
==========================================================
==========================================================
Running Adifier... (mix adify)
==========================================================
"""
cd adifier
mix adify
else
echo """
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The system is already Adified.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The system is already Adified.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
"""
fi