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

shellcheck validation of tasks/postgres_upgrade.sh fails #356

Closed
speculatrix opened this issue Sep 11, 2020 · 2 comments · Fixed by #357
Closed

shellcheck validation of tasks/postgres_upgrade.sh fails #356

speculatrix opened this issue Sep 11, 2020 · 2 comments · Fixed by #357
Assignees

Comments

@speculatrix
Copy link

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
Copy link

igalic commented Sep 14, 2020

do you think you can provide a patch for that?

@speculatrix
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants