voxpupuli / puppet-gitlab

Puppet module to manage Gitlab (Omnibus)
https://forge.puppet.com/puppet/gitlab/
BSD 3-Clause "New" or "Revised" License
74 stars 166 forks source link

shellcheck validation of tasks/postgres_upgrade.sh fails #356

Closed speculatrix closed 3 years ago

speculatrix commented 3 years ago

simple scripting tweak required:

$ shellcheck gitlab/tasks/postgres_upgrade.sh

In gitlab/tasks/postgres_upgrade.sh line 12:
  if [ $DB_SIZE -lt $FREE ]; then
       ^------^ SC2086: Double quote to prevent globbing and word splitting.
                    ^---^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
  if [ "$DB_SIZE" -lt "$FREE" ]; then

For more information:
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
igalic commented 3 years ago

do you think you can provide a patch for that?

speculatrix commented 3 years ago

here's the corrected file. am not sure how I can get pupperware/puppet module to show me a diff against the forge version

#!/bin/bash

echo 'Checking pgsql version'
CMD=$(gitlab-psql --version)
echo "version is ${CMD##* }"
#9.2.18
if [ "${CMD##* }" = "9.2.18" ]; then
  echo 'Version is below required for Gitlab 10+, checking...'
  DB_SIZE=$(du -shk /var/opt/gitlab/postgresql/data | awk '{print $1}')
  FREE=$(df -hk /var/opt/gitlab/postgresql/data/ | tail -1 | awk '{print $4}')
  echo "Database size is: $DB_SIZE kb and freespace is $FREE kb"
  if [ "$DB_SIZE" -lt "$FREE" ]; then
    echo 'Enough freespace available to proceed.'
    gitlab-ctl pg-upgrade
    echo 'Upgrade complete.  Please verify everything is correct and then run the post_upgrade task.'
  else
    echo 'You need to have enough freespace for a second copy of the database. Please resolve and then re-run the task.'
    exit 1
  fi
else
  echo 'Version is correct for Gitlab 10+, upgrade skipped...'
fi