diff --git a/util/bump-version.sh b/util/bump-version.sh index 1e9db9b02..fd98360cb 100755 --- a/util/bump-version.sh +++ b/util/bump-version.sh @@ -8,7 +8,7 @@ if [ "$(uname)" == "Darwin" ]; then PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" fi -if [ -z "$1" -o -z "$2" ]; then +if [ -z "$1" ] || [ -z "$2" ]; then echo "New version not specified. Usage: bump-version.sh NEW_PCLUSTER_VERSION NEW_AWSBATCH_CLI_VERSION" exit 1 fi @@ -35,13 +35,13 @@ for cookbook in "${COOKBOOKS[@]}"; do done # Update version in specific cookbook metadata -sed -i "s/version '${CURRENT_PCLUSTER_VERSION_SHORT}'/version '${NEW_PCLUSTER_VERSION_SHORT}'/g" ${METADATA_FILES[*]} +sed -i "s/version '${CURRENT_PCLUSTER_VERSION_SHORT}'/version '${NEW_PCLUSTER_VERSION_SHORT}'/g" "${METADATA_FILES[@]}" -for COOKBOOK in ${COOKBOOKS[*]}; do +for COOKBOOK in "${COOKBOOKS[@]}"; do # Update dependencies version in main cookbook metadata sed -i "s/depends '${COOKBOOK}', '~> ${CURRENT_PCLUSTER_VERSION_SHORT}'/depends '${COOKBOOK}', '~> ${NEW_PCLUSTER_VERSION_SHORT}'/g" metadata.rb # Update dependencies version in specific cookbook metadata - sed -i "s/depends '${COOKBOOK}', '~> ${CURRENT_PCLUSTER_VERSION_SHORT}'/depends '${COOKBOOK}', '~> ${NEW_PCLUSTER_VERSION_SHORT}'/g" ${METADATA_FILES[*]} + sed -i "s/depends '${COOKBOOK}', '~> ${CURRENT_PCLUSTER_VERSION_SHORT}'/depends '${COOKBOOK}', '~> ${NEW_PCLUSTER_VERSION_SHORT}'/g" "${METADATA_FILES[@]}" done # Update AWS Batch CLI version diff --git a/util/cinc-install.sh b/util/cinc-install.sh index c880db49a..14d825014 100644 --- a/util/cinc-install.sh +++ b/util/cinc-install.sh @@ -75,6 +75,7 @@ checksum_mismatch() { unable_to_retrieve_package() { echo "Unable to retrieve a valid package!" report_bug + # shellcheck disable=SC2154 echo "Metadata URL: $metadata_url" if test "x$download_url" != "x"; then echo "Download URL: $download_url" @@ -132,7 +133,7 @@ do_wget() { wget --user-agent="User-Agent: mixlib-install/3.12.27" -O "$2" "$1" 2>$tmp_dir/stderr rc=$? # check for 404 - grep "ERROR 404" $tmp_dir/stderr 2>&1 >/dev/null + grep "ERROR 404" $tmp_dir/stderr >/dev/null 2>&1 if test $? -eq 0; then echo "ERROR 404" http_404_error @@ -153,7 +154,7 @@ do_curl() { curl -A "User-Agent: mixlib-install/3.12.27" --retry 5 -sL -D $tmp_dir/stderr "$1" > "$2" rc=$? # check for 404 - grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null + grep "404 Not Found" $tmp_dir/stderr >/dev/null 2>&1 if test $? -eq 0; then echo "ERROR 404" http_404_error @@ -183,7 +184,7 @@ do_perl() { perl -e 'use LWP::Simple; getprint($ARGV[0]);' "$1" > "$2" 2>$tmp_dir/stderr rc=$? # check for 404 - grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null + grep "404 Not Found" $tmp_dir/stderr >/dev/null 2>&1 if test $? -eq 0; then echo "ERROR 404" http_404_error @@ -204,7 +205,7 @@ do_python() { python -c "import sys,urllib2; sys.stdout.write(urllib2.urlopen(urllib2.Request(sys.argv[1], headers={ 'User-Agent': 'mixlib-install/3.12.27' })).read())" "$1" > "$2" 2>$tmp_dir/stderr rc=$? # check for 404 - grep "HTTP Error 404" $tmp_dir/stderr 2>&1 >/dev/null + grep "HTTP Error 404" $tmp_dir/stderr >/dev/null 2>&1 if test $? -eq 0; then echo "ERROR 404" http_404_error @@ -222,12 +223,12 @@ do_python() { do_checksum() { if exists sha256sum; then echo "Comparing checksum with sha256sum..." - checksum=`sha256sum $1 | awk '{ print $1 }'` - return `test "x$checksum" = "x$2"` + checksum=$(sha256sum $1 | awk '{ print $1 }') + return "$(test "x$checksum" = "x$2")" elif exists shasum; then echo "Comparing checksum with shasum..." - checksum=`shasum -a 256 $1 | awk '{ print $1 }'` - return `test "x$checksum" = "x$2"` + checksum=$(shasum -a 256 $1 | awk '{ print $1 }') + return "$(test "x$checksum" = "x$2")" else echo "WARNING: could not find a valid checksum program, pre-install shasum or sha256sum in your O/S image to get validation..." return 0 @@ -311,7 +312,7 @@ install_file() { "deb") echo "installing with dpkg..." # WARNING: Custom fix to avoid hangs when another installation is running - flock $(apt-config shell StateDir Dir::State/d | sed -r "s/.*'(.*)'$/\1/")daily_lock dpkg -i "$2" + flock "$(apt-config shell StateDir Dir::State/d | sed -r "s/.*'(.*)'$/\1/")daily_lock" dpkg -i "$2" ;; "bff") echo "installing with installp..." @@ -333,7 +334,7 @@ install_file() { echo "installing dmg file..." hdiutil detach "/Volumes/cinc_project" >/dev/null 2>&1 || true hdiutil attach "$2" -mountpoint "/Volumes/cinc_project" - cd / && /usr/sbin/installer -pkg `find "/Volumes/cinc_project" -name \*.pkg` -target / + cd / && /usr/sbin/installer -pkg "$(find "/Volumes/cinc_project" -name \*.pkg)" -target / hdiutil detach "/Volumes/cinc_project" ;; "sh" ) @@ -408,7 +409,7 @@ do esac done -shift `expr $OPTIND - 1` +shift "$(expr $OPTIND - 1)" if test -d "/opt/$project" && test "x$install_strategy" = "xonce"; then @@ -530,6 +531,7 @@ elif test "x$os" = "xAIX"; then elif test -f "/etc/os-release"; then . /etc/os-release if test "x$CISCO_RELEASE_INFO" != "x"; then + # shellcheck source=/dev/null . $CISCO_RELEASE_INFO fi @@ -633,6 +635,7 @@ if test "x$platform" = "xsolaris2"; then fi # WARNING: Custom code to detect AWS Region +# shellcheck disable=SC2034 # instance_metadata_file is used below instance_metadata_file=$tmp_dir/instance_metadata get_region instance_metadata_file diff --git a/util/upload-cookbook.sh b/util/upload-cookbook.sh index 72b2e8a6d..be0d5ab12 100755 --- a/util/upload-cookbook.sh +++ b/util/upload-cookbook.sh @@ -10,7 +10,8 @@ _info() { } _help() { - local -- _cmd=$(basename "$0") + local -- _cmd + _cmd=$(basename "$0") cat < /dev/null + pushd "${_srcdir}" > /dev/null || exit _stashName=$(git stash create) git archive --format tar --prefix="aws-parallelcluster-cookbook-${_version}/" "${_stashName:-HEAD}" | gzip > "${_cwd}/aws-parallelcluster-cookbook-${_version}.tgz" #tar zcvf "${_cwd}/aws-parallelcluster-cookbook-${_version}.tgz" --transform "s,^aws-parallelcluster-cookbook/,aws-parallelcluster-cookbook-${_version}/," ../aws-parallelcluster-cookbook - popd > /dev/null + popd > /dev/null || exit md5sum aws-parallelcluster-cookbook-${_version}.tgz > aws-parallelcluster-cookbook-${_version}.md5 # upload packages