diff --git a/cookbooks/ec2-ami-tools/recipes/install.bash b/cookbooks/ec2-ami-tools/recipes/install.bash index 233c7581..2b97a450 100755 --- a/cookbooks/ec2-ami-tools/recipes/install.bash +++ b/cookbooks/ec2-ami-tools/recipes/install.bash @@ -32,11 +32,7 @@ function install() # Move Folder - local -r currentPath="$(pwd)" - - cd "${unzipFolder}" - find '.' -maxdepth 1 -not -name '.' -exec mv '{}' "${EC2_AMI_TOOLS_INSTALL_FOLDER}" \; - cd "${currentPath}" + moveFolderContent "${unzipFolder}" "${EC2_AMI_TOOLS_INSTALL_FOLDER}" symlinkLocalBin "${EC2_AMI_TOOLS_INSTALL_FOLDER}/bin" rm -f -r "${unzipFolder}" diff --git a/cookbooks/ec2-api-tools/recipes/install.bash b/cookbooks/ec2-api-tools/recipes/install.bash index d029ddeb..7390f3ec 100755 --- a/cookbooks/ec2-api-tools/recipes/install.bash +++ b/cookbooks/ec2-api-tools/recipes/install.bash @@ -32,11 +32,7 @@ function install() # Move Folder - local -r currentPath="$(pwd)" - - cd "${unzipFolder}" - find '.' -maxdepth 1 -not -name '.' -exec mv '{}' "${EC2_API_TOOLS_INSTALL_FOLDER}" \; - cd "${currentPath}" + moveFolderContent "${unzipFolder}" "${EC2_API_TOOLS_INSTALL_FOLDER}" rm -f -r "${unzipFolder}" # Config Profile diff --git a/cookbooks/go-cd/recipes/install-agent.bash b/cookbooks/go-cd/recipes/install-agent.bash index 37820134..091cae67 100755 --- a/cookbooks/go-cd/recipes/install-agent.bash +++ b/cookbooks/go-cd/recipes/install-agent.bash @@ -34,11 +34,7 @@ function install() # Move Folder - local -r currentPath="$(pwd)" - - cd "${unzipFolder}" - find '.' -maxdepth 1 -not -name '.' -exec mv '{}' "${GO_CD_AGENT_INSTALL_FOLDER}" \; - cd "${currentPath}" + moveFolderContent "${unzipFolder}" "${GO_CD_AGENT_INSTALL_FOLDER}" # Finalize diff --git a/cookbooks/go-cd/recipes/install-server.bash b/cookbooks/go-cd/recipes/install-server.bash index 40f088fa..2d64c74f 100755 --- a/cookbooks/go-cd/recipes/install-server.bash +++ b/cookbooks/go-cd/recipes/install-server.bash @@ -32,11 +32,7 @@ function install() # Move Folder - local -r currentPath="$(pwd)" - - cd "${unzipFolder}" - find '.' -maxdepth 1 -not -name '.' -exec mv '{}' "${GO_CD_SERVER_INSTALL_FOLDER}" \; - cd "${currentPath}" + moveFolderContent "${unzipFolder}" "${GO_CD_SERVER_INSTALL_FOLDER}" # Finalize diff --git a/cookbooks/groovy/recipes/install.bash b/cookbooks/groovy/recipes/install.bash index 44ac0b67..d905b4a8 100755 --- a/cookbooks/groovy/recipes/install.bash +++ b/cookbooks/groovy/recipes/install.bash @@ -32,11 +32,7 @@ function install() # Move Folder - local -r currentPath="$(pwd)" - - cd "${unzipFolder}" - find '.' -maxdepth 1 -not -name '.' -exec mv '{}' "${GROOVY_INSTALL_FOLDER}" \; - cd "${currentPath}" + moveFolderContent "${unzipFolder}" "${GROOVY_INSTALL_FOLDER}" rm -f -r "${unzipFolder}" # Config Lib diff --git a/cookbooks/shell-check/recipes/install.bash b/cookbooks/shell-check/recipes/install.bash index ca9af7f6..60c3382b 100755 --- a/cookbooks/shell-check/recipes/install.bash +++ b/cookbooks/shell-check/recipes/install.bash @@ -7,9 +7,11 @@ function installDependencies() function install() { + local -r userHomeFolderPath="$(getCurrentUserHomeFolder)" + # Clean Up - rm -f -r ~/.cabal ~/.ghc + rm -f -r "${userHomeFolderPath}/.cabal" "${userHomeFolderPath}/.ghc" initializeFolder "${CABAL_INSTALL_FOLDER}" # Install @@ -17,8 +19,8 @@ function install() cabal update cabal install 'shellcheck' - mv ~/.cabal/* "${CABAL_INSTALL_FOLDER}" - rm -f -r ~/.cabal ~/.ghc + moveFolderContent "${userHomeFolderPath}/.cabal" "${CABAL_INSTALL_FOLDER}" + rm -f -r "${userHomeFolderPath}/.cabal" "${userHomeFolderPath}/.ghc" ln -f -s "${CABAL_INSTALL_FOLDER}/bin/shellcheck" '/usr/local/bin/shellcheck' # Config Profile diff --git a/libraries/util.bash b/libraries/util.bash index 6e4ddc50..8a00dc0e 100755 --- a/libraries/util.bash +++ b/libraries/util.bash @@ -169,6 +169,21 @@ function isValidJSONFile() isValidJSONContent "$(cat "${file}")" } +function moveFolderContent() +{ + local -r sourceFolder="${1}" + local -r destinationFolder="${2}" + + checkExistFolder "${sourceFolder}" + checkExistFolder "${destinationFolder}" + + local -r currentPath="$(pwd)" + + cd "${sourceFolder}" + find '.' -maxdepth 1 -not -name '.' -exec mv '{}' "${destinationFolder}" \; + cd "${currentPath}" +} + function symlinkLocalBin() { local -r sourceBinFolder="${1}"