Skip to content

Commit

Permalink
update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbtek committed Jan 4, 2019
1 parent 10a1071 commit 1215968
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 24 deletions.
3 changes: 2 additions & 1 deletion cookbooks/azure-cli/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function installDependencies()
{
if [[ "$(existCommand 'brew')" = 'false' ]]
then
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash"
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash" 'true'
fi
}

Expand All @@ -29,6 +29,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING AZURE-CLI'

Expand Down
1 change: 1 addition & 0 deletions cookbooks/azure-cli/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'UNINSTALLING AZURE-CLI'

Expand Down
14 changes: 12 additions & 2 deletions cookbooks/brew/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@

function install()
{
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < '/dev/null'
local -r confirm="${1}"

if [[ "${confirm}" = 'true' ]]
then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < '/dev/null'
else
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

displayVersion "$(brew -v)"
}

function main()
{
local -r confirm="${1}"

local -r appFolderPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "${appFolderPath}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING BREW'

# Install

install
install "${confirm}"
}

main "${@}"
18 changes: 18 additions & 0 deletions cookbooks/brew/recipes/reinstall.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e

function main()
{
local -r confirm="${1}"

local -r appFolderPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "${appFolderPath}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireRootUser

"${appFolderPath}/uninstall.bash" "${confirm}"
sudo -u "${SUDO_USER}" "${appFolderPath}/install.bash" "${confirm}"
}

main "${@}"
27 changes: 14 additions & 13 deletions cookbooks/brew/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ function uninstall()
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" || true
fi

rm -f -r '/usr/local/.com.apple.installer.keep' \
'/usr/local/bin' \
'/usr/local/Caskroom' \
'/usr/local/Cellar' \
'/usr/local/etc' \
'/usr/local/Frameworks' \
'/usr/local/Homebrew' \
'/usr/local/include' \
'/usr/local/lib' \
'/usr/local/opt' \
'/usr/local/sbin' \
'/usr/local/share' \
'/usr/local/var'
rm -f -r \
'/usr/local/.com.apple.installer.keep' \
'/usr/local/bin' \
'/usr/local/Caskroom' \
'/usr/local/Cellar' \
'/usr/local/etc' \
'/usr/local/Frameworks' \
'/usr/local/Homebrew' \
'/usr/local/include' \
'/usr/local/lib' \
'/usr/local/opt' \
'/usr/local/sbin' \
'/usr/local/share' \
'/usr/local/var'
}

function main()
Expand Down
3 changes: 2 additions & 1 deletion cookbooks/chef-client/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function installDependencies()
{
if [[ "$(existCommand 'brew')" = 'false' ]]
then
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash"
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash" 'true'
fi
}

Expand All @@ -29,6 +29,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING CHEF-CLIENT'

Expand Down
1 change: 1 addition & 0 deletions cookbooks/chef-client/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING CHEF-CLIENT'

Expand Down
3 changes: 2 additions & 1 deletion cookbooks/core-utils/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function installDependencies()
{
if [[ "$(existCommand 'brew')" = 'false' ]]
then
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash"
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash" 'true'
fi
}

Expand All @@ -29,6 +29,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING CORE-UTILS'

Expand Down
1 change: 1 addition & 0 deletions cookbooks/core-utils/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'UNINSTALLING CORE-UTILS'

Expand Down
3 changes: 2 additions & 1 deletion cookbooks/jdk/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function installDependencies()
{
if [[ "$(existCommand 'brew')" = 'false' ]]
then
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash"
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash" 'true'
fi
}

Expand Down Expand Up @@ -32,6 +32,7 @@ function main()
source "${APP_FOLDER_PATH}/../attributes/default.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING JDK'

Expand Down
1 change: 1 addition & 0 deletions cookbooks/jdk/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function main()
source "${APP_FOLDER_PATH}/../attributes/default.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'UNINSTALLING JDK'

Expand Down
3 changes: 2 additions & 1 deletion cookbooks/shell-check/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function installDependencies()
{
if [[ "$(existCommand 'brew')" = 'false' ]]
then
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash"
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash" 'true'
fi
}

Expand All @@ -29,6 +29,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING SHELL-CHECK'

Expand Down
1 change: 1 addition & 0 deletions cookbooks/shell-check/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'UNINSTALLING SHELL-CHECK'

Expand Down
3 changes: 2 additions & 1 deletion cookbooks/vagrant/recipes/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function installDependencies()
{
if [[ "$(existCommand 'brew')" = 'false' ]]
then
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash"
"${APP_FOLDER_PATH}/../../brew/recipes/install.bash" 'true'
fi
}

Expand All @@ -29,6 +29,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING VAGRANT'

Expand Down
1 change: 1 addition & 0 deletions cookbooks/vagrant/recipes/uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function main()
source "${APP_FOLDER_PATH}/../../../libraries/util.bash"

checkRequireMacSystem
checkRequireNonRootUser

header 'INSTALLING VAGRANT'

Expand Down
10 changes: 9 additions & 1 deletion libraries/util.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ function isEmptyString()

function postUpMessage()
{
echo -e "\n\033[1;4;32m¯\_(ツ)_/¯\033[0m"
echo -e "\n\033[1;32m¯\_(ツ)_/¯\033[0m"
}

function printTable()
Expand Down Expand Up @@ -1999,6 +1999,14 @@ function checkExistUserLogin()
fi
}

function checkRequireNonRootUser()
{
if [[ "$(whoami)" = 'root' ]]
then
fatal '\nFATAL : non root login required'
fi
}

function checkRequireRootUser()
{
checkRequireUserLogin 'root'
Expand Down
5 changes: 3 additions & 2 deletions roles/nam/roles/macbook-pro-cli.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ function main()

source "${appFolderPath}/../../../libraries/util.bash"

checkRequireRootUser

# Brew

"${appFolderPath}/../../../cookbooks/brew/recipes/uninstall.bash" 'true'
sudo -u "${SUDO_USER}" "${appFolderPath}/../../../cookbooks/brew/recipes/install.bash"
"${appFolderPath}/../../../cookbooks/brew/recipes/reinstall.bash" 'true'

# Brew Application

Expand Down

0 comments on commit 1215968

Please sign in to comment.