From ab99aac5b5d4cce1540357c2276b0950b027fd73 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Jan 2014 23:42:45 +0000 Subject: [PATCH] Bring `__check_config_dir` into required scope. --- bootstrap-salt.sh | 101 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index e759807..ef02a97 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -113,6 +113,56 @@ check_pip_allowed() { fi } +#=== FUNCTION ================================================================ +# NAME: __check_config_dir +# DESCRIPTION: Checks the config directory, retrieves URLs if provided. +#=============================================================================== +__check_config_dir() { + CC_DIR_NAME="$1" + CC_DIR_BASE=$(basename "${CC_DIR_NAME}") + + case "$CC_DIR_NAME" in + http://*|https://*) + __fetch_url "/tmp/${CC_DIR_BASE}" "${CC_DIR_NAME}" + CC_DIR_NAME="/tmp/${CC_DIR_BASE}" + ;; + ftp://*) + __fetch_url "/tmp/${CC_DIR_BASE}" "${CC_DIR_NAME}" + CC_DIR_NAME="/tmp/${CC_DIR_BASE}" + ;; + *) + if [ ! -e "${CC_DIR_NAME}" ]; then + echo "null" + return 0 + fi + ;; + esac + + case "$CC_DIR_NAME" in + *.tgz|*.tar.gz) + tar -zxf "${CC_DIR_NAME}" -C /tmp + CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tgz") + CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.gz") + CC_DIR_NAME="/tmp/${CC_DIR_BASE}" + ;; + *.tbz|*.tar.bz2) + tar -xjf "${CC_DIR_NAME}" -C /tmp + CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tbz") + CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.bz2") + CC_DIR_NAME="/tmp/${CC_DIR_BASE}" + ;; + *.txz|*.tar.xz) + tar -xJf "${CC_DIR_NAME}" -C /tmp + CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".txz") + CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.xz") + CC_DIR_NAME="/tmp/${CC_DIR_BASE}" + ;; + esac + + echo "${CC_DIR_NAME}" +} + + #=== FUNCTION ================================================================ # NAME: usage # DESCRIPTION: Display usage information. @@ -431,57 +481,6 @@ __fetch_url() { } -#=== FUNCTION ================================================================ -# NAME: __check_config_dir -# DESCRIPTION: Checks the config directory, retrieves URLs if provided. -#=============================================================================== -__check_config_dir() { - CC_DIR_NAME="$1" - CC_DIR_BASE=$(basename "${CC_DIR_NAME}") - - case "$CC_DIR_NAME" in - http://*|https://*) - __fetch_url "/tmp/${CC_DIR_BASE}" "${CC_DIR_NAME}" - CC_DIR_NAME="/tmp/${CC_DIR_BASE}" - ;; - ftp://*) - __fetch_url "/tmp/${CC_DIR_BASE}" "${CC_DIR_NAME}" - CC_DIR_NAME="/tmp/${CC_DIR_BASE}" - ;; - *) - if [ ! -e "${CC_DIR_NAME}" ]; then - echo "null" - return 0 - fi - ;; - esac - - case "$CC_DIR_NAME" in - *.tgz|*.tar.gz) - tar -zxf "${CC_DIR_NAME}" -C /tmp - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tgz") - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.gz") - CC_DIR_NAME="/tmp/${CC_DIR_BASE}" - ;; - *.tbz|*.tar.bz2) - tar -xjf "${CC_DIR_NAME}" -C /tmp - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tbz") - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.bz2") - CC_DIR_NAME="/tmp/${CC_DIR_BASE}" - ;; - *.txz|*.tar.xz) - tar -xJf "${CC_DIR_NAME}" -C /tmp - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".txz") - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.xz") - CC_DIR_NAME="/tmp/${CC_DIR_BASE}" - ;; - esac - - echo "${CC_DIR_NAME}" -} - - - #--- FUNCTION ---------------------------------------------------------------- # NAME: __gather_hardware_info # DESCRIPTION: Discover hardware information