Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Shellcheck severity level to warning and make fixes #2611

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
severity: error
severity: warning
ignore_paths: cookbooks/third-party
rspec:
name: ChefSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function info() {
}

function help() {
local -- cmd=$(basename "$0")
local -- cmd
cmd=$(basename "$0")
cat <<EOF

Usage: ${cmd} [OPTION]...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function info() {
}

function help() {
local -- cmd=$(basename "$0")
local -- cmd
cmd=$(basename "$0")
cat <<EOF

Usage: ${cmd} [OPTION]...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ LVM_PATH="/dev/${LVM_VG_NAME}/${LVM_NAME}"
LVM_ACTIVE_STATE="a"
FS_TYPE="ext4"
MOUNT_OPTIONS="noatime,nodiratime"
# cfn_ephemeral_dir is set in the environment by cfnconfig sourcing
# shellcheck disable=SC2154 # cfn_ephemeral_dir is set in the environment by cfnconfig sourcing
INPUT_MOUNTPOINT="${cfn_ephemeral_dir}"

function log {
SCRIPT=$(basename "$0")
MESSAGE="$1"
echo "ParallelCluster - ${MESSAGE}"
}
Expand Down Expand Up @@ -73,7 +72,7 @@ function print_block_device_mapping {
function check_instance_store {
if ls /dev/nvme* >& /dev/null; then
IS_NVME=1
MAPPINGS=$(realpath --relative-to=/dev/ -P /dev/disk/by-id/nvme*Instance_Storage* | grep -v "*Instance_Storage*" | uniq)
MAPPINGS=$(realpath --relative-to=/dev/ -P /dev/disk/by-id/nvme*Instance_Storage* | grep -v "\*Instance_Storage\*" | uniq)
else
IS_NVME=0
set_imds_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _validate_json() {
if [[ -z "${json_param}" ]]; then
_fail "${message}. Empty JSON."
fi
if ! $(jq -e . >/dev/null 2>&1 <<<"${json_param}"); then
if ! jq -e . >/dev/null 2>&1 <<<"${json_param}"; then
_fail "${message}. Wrong JSON."
fi
}
Expand Down
8 changes: 4 additions & 4 deletions util/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 13 additions & 13 deletions util/cinc-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ checksum_mismatch() {
unable_to_retrieve_package() {
echo "Unable to retrieve a valid package!"
report_bug
echo "Metadata URL: $metadata_url"
if test "x$download_url" != "x"; then
echo "Download URL: $download_url"
fi
Expand Down Expand Up @@ -107,7 +106,6 @@ http_404_error() {
echo "that $platform is not supported."
echo ""
# deliberately do not call report_bug to suppress bug report noise.
echo "Metadata URL: $metadata_url"
if test "x$download_url" != "x"; then
echo "Download URL: $download_url"
fi
Expand All @@ -132,7 +130,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
Expand All @@ -153,7 +151,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
Expand Down Expand Up @@ -183,7 +181,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
Expand All @@ -204,7 +202,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
Expand All @@ -222,12 +220,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
Expand Down Expand Up @@ -311,7 +309,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..."
Expand All @@ -333,7 +331,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" )
Expand Down Expand Up @@ -408,7 +406,7 @@ do
esac
done

shift `expr $OPTIND - 1`
shift "$(expr $OPTIND - 1)"


if test -d "/opt/$project" && test "x$install_strategy" = "xonce"; then
Expand Down Expand Up @@ -530,6 +528,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

Expand Down Expand Up @@ -633,6 +632,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

Expand Down
7 changes: 4 additions & 3 deletions util/upload-cookbook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ _info() {
}

_help() {
local -- _cmd=$(basename "$0")
local -- _cmd
_cmd=$(basename "$0")

cat <<EOF

Expand Down Expand Up @@ -84,11 +85,11 @@ main() {

# Create archive and md5
_cwd=$(pwd)
pushd "${_srcdir}" > /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
Expand Down
Loading