From 64ac94d0fe2e0fcee3532d98fd414e1c22d24669 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 19:13:05 -0500 Subject: [PATCH 01/10] Update main adify script --- adify.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/adify.sh b/adify.sh index ce5984d..1e91c6e 100644 --- a/adify.sh +++ b/adify.sh @@ -1,8 +1,13 @@ ### 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. +# 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: +# $ wget -0 - https://github.com/aditya7iyengar/adify/blob/master/adify.sh | bash + # TODO: Make it runnable on other OS. # This Script is setup to run only on Ubuntu computers @@ -19,6 +24,7 @@ echo """ Installing Git to get adify. ========================================================== """ +# TODO: Use "uname" command or "$OSTYPE" env sudo apt-get install -y git sudo yum install -y git brew install git From 56d3497de8162ab1d165722ae92459bd0fcd7c38 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 19:52:35 -0500 Subject: [PATCH 02/10] Updates to adify script: - Format strings to properly show stuff - Add OS detection to adify.sh - Add dynamic pm to adify.sh for git --- adify.sh | 122 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 30 deletions(-) mode change 100644 => 100755 adify.sh diff --git a/adify.sh b/adify.sh old mode 100644 new mode 100755 index 1e91c6e..1734a50 --- a/adify.sh +++ b/adify.sh @@ -1,4 +1,6 @@ -### PRELUDE ### +#!/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. @@ -7,6 +9,8 @@ ### USAGE ### # From the terminal: # $ wget -0 - https://github.com/aditya7iyengar/adify/blob/master/adify.sh | bash +# OR +# $ curl -s https://github.com/aditya7iyengar/adify/blob/master/adify.sh | bash # TODO: Make it runnable on other OS. # This Script is setup to run only on Ubuntu computers @@ -17,6 +21,66 @@ # - Admin Privilleges of the computer being adified # - Adi (for credentials) +### PRELUDE ### +# Installing `curl` if not installed already +# 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 + ### GIT ### # Running all three package manager commands. echo """ @@ -25,31 +89,29 @@ Installing Git to get adify. ========================================================== """ # TODO: Use "uname" command or "$OSTYPE" env -sudo apt-get install -y git -sudo yum install -y git -brew install git +$pm apt-get 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" [ "$1" = "ask" ] && export ADIFYASK="true" @@ -57,40 +119,40 @@ if [ ! -d "$HOME/dot-adify" ]; then 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} 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) +========================================================== """ mix adify else echo """ - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - The system is already Adified. - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +The system is already Adified. +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX """ fi From e9bef3803bac80c124258690040990bf8b87e197 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 19:57:06 -0500 Subject: [PATCH 03/10] Add curl installation to adify --- adify.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/adify.sh b/adify.sh index 1734a50..4174663 100755 --- a/adify.sh +++ b/adify.sh @@ -81,6 +81,16 @@ OS is AIX.. Adify isn't supported for AIX. ;; esac +### CURL ### +# Install curl, as it's an important tool!! +echo """ +========================================================== +Installing Curl.. Can't live without that! +========================================================== +""" +$pm install curl + + ### GIT ### # Running all three package manager commands. echo """ @@ -147,6 +157,7 @@ Installing ELIXIR $ex_version to run Adifier app.... Running Adifier... (mix adify) ========================================================== """ + cd adifier mix adify else echo """ From 5eaaf406fba985c2702f2697d1a5ed774d46b959 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:13:39 -0500 Subject: [PATCH 04/10] Updates to usage command --- adify.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adify.sh b/adify.sh index 4174663..9950896 100755 --- a/adify.sh +++ b/adify.sh @@ -8,9 +8,9 @@ ### USAGE ### # From the terminal: -# $ wget -0 - https://github.com/aditya7iyengar/adify/blob/master/adify.sh | bash +# $ wget https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.s | bash # OR -# $ curl -s https://github.com/aditya7iyengar/adify/blob/master/adify.sh | bash +# $ curl -s https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.s | bash # TODO: Make it runnable on other OS. # This Script is setup to run only on Ubuntu computers @@ -88,7 +88,7 @@ echo """ Installing Curl.. Can't live without that! ========================================================== """ -$pm install curl +$pm install -y curl ### GIT ### From 6749a25f6564e82b4e9e9d61215a876b233b2b45 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:15:14 -0500 Subject: [PATCH 05/10] Fix type in GIT --- adify.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adify.sh b/adify.sh index 9950896..a73deb6 100755 --- a/adify.sh +++ b/adify.sh @@ -98,8 +98,7 @@ echo """ Installing Git to get adify. ========================================================== """ -# TODO: Use "uname" command or "$OSTYPE" env -$pm apt-get install -y git +$pm install -y git ex_version="1.5.2" otp_version="20.0" From 2f1e5b20cd5d5fda31263c79bfbe2ec931ca4c02 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:27:37 -0500 Subject: [PATCH 06/10] Add shell detection and resourcing to adify --- adify.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/adify.sh b/adify.sh index a73deb6..5b431bc 100755 --- a/adify.sh +++ b/adify.sh @@ -24,6 +24,11 @@ ### PRELUDE ### # Installing `curl` if not installed already # Detecting OS +echo """ +========================================================== +Detecting OS......... +========================================================== +""" OS="`uname`" case $OS in 'Linux') @@ -81,6 +86,27 @@ OS is AIX.. Adify isn't supported for AIX. ;; 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 """ @@ -134,6 +160,23 @@ 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 echo """ ========================================================== From 0b76b78185789297de759b85570c4198d7e68ef9 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:38:59 -0500 Subject: [PATCH 07/10] Updates to commands called on host --- adify.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adify.sh b/adify.sh index 5b431bc..a4c4412 100755 --- a/adify.sh +++ b/adify.sh @@ -8,9 +8,9 @@ ### USAGE ### # From the terminal: -# $ wget https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.s | bash +# $ bash <(wget -qO- https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.sh) # OR -# $ curl -s https://raw.githubusercontent.com/aditya7iyengar/adify/master/adify.s | bash +# $ 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 @@ -183,16 +183,16 @@ Installing Asdf $asdf_version for Elixir and Erlang... 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} + ~/.asdf/asdf.sh plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git + ~/.asdf/asdf.sh install erlang ${otp_version} echo """ ========================================================== 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} + ~/.asdf/asdf.sh add-plugin elixir https://github.com/asdf-vm/asdf-elixir.git + ~/.asdf/asdf.sh install elixir ${ex_version} echo """ ========================================================== From 27c71af457e5f6cd68561c69738238bf3ebdb1d3 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:39:46 -0500 Subject: [PATCH 08/10] Fix typo on cd --- adify.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adify.sh b/adify.sh index a4c4412..af8a4ca 100755 --- a/adify.sh +++ b/adify.sh @@ -148,7 +148,7 @@ Fetching Adifying files... """ 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" From 5b311cf0e1205a4626802cf74f6c2e6684cf2775 Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:45:10 -0500 Subject: [PATCH 09/10] Updates to adify to source asdf --- adify.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/adify.sh b/adify.sh index af8a4ca..86152f2 100755 --- a/adify.sh +++ b/adify.sh @@ -178,21 +178,24 @@ Installing Asdf $asdf_version for Elixir and Erlang... ;; esac + . $HOME/.asdf/asdf.sh + . $HOME/.asdf/completions/asdf.bash + echo """ ========================================================== Installing ERLANG $otp_version to run Adifier app.... ========================================================== """ - ~/.asdf/asdf.sh plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git - ~/.asdf/asdf.sh install erlang ${otp_version} + 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.... ========================================================== """ - ~/.asdf/asdf.sh add-plugin elixir https://github.com/asdf-vm/asdf-elixir.git - ~/.asdf/asdf.sh install elixir ${ex_version} + asdf add-plugin elixir https://github.com/asdf-vm/asdf-elixir.git + asdf install elixir ${ex_version} echo """ ========================================================== From 7b5dfe8cca5ab27c6db2ecefd500cdfa6e48c5ca Mon Sep 17 00:00:00 2001 From: Adi Date: Thu, 18 Jan 2018 20:47:46 -0500 Subject: [PATCH 10/10] Change permissions --- adify.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adify.sh b/adify.sh index 86152f2..d62c534 100755 --- a/adify.sh +++ b/adify.sh @@ -178,6 +178,9 @@ Installing Asdf $asdf_version for Elixir and Erlang... ;; esac + chmod 777 $HOME/.asdf/asdf.sh + chmod 777 $HOME/.asdf/completions/asdf.bash + . $HOME/.asdf/asdf.sh . $HOME/.asdf/completions/asdf.bash