Commit 48da8a37 authored by Matteo Melli's avatar Matteo Melli
Browse files

Fixed SHELLCHECK and sanity check

Use bash -n to check script sanity instead of actually executing it
parent aa8e7d92
Pipeline #88696 passed with stage
in 14 seconds
......@@ -10,6 +10,7 @@ export ENVIRONMENT=$1
export ROLE=$2
export GITLAB_ENV=$ENVIRONMENT
# shellcheck source=/dev/null
source "${BASE}/source_vars"
source "${BASE}/env_${ENVIRONMENT}" # That is, .env_staging or .env_production (test also supported)
source "${BASE}/utilities"
......
......@@ -13,6 +13,6 @@ find_scripts | while IFS='' read -r file; do
if [[ -x ${file} ]]; then
echo "${file}"
SANITY_CHECK_ONLY=1 "${file}"
bash -n "${file}"
fi
done
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
for host in "${AZURE_HOSTS[@]}" "${GCP_HOSTS[@]}"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
all_ok=true
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
echo "Create tombstone database and table if not already existing"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
tombstone_msg=$(date +'%Y%m%d_%H%M%S')"_${ENVIRONMENT}"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
for host in "${AZURE_HOSTS[@]}" "${GCP_HOSTS[@]}"; do
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
for host in "${AZURE_PGBOUNCERS[@]}"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
for host in "${GCP_HOSTS[@]}"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
ssh_remote "$AZURE_MASTER" sudo -u gitlab-psql gitlab-psql -d gitlab_repmgr -c \
......
......@@ -2,12 +2,13 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
echo "standby_mode = 'on'
primary_conninfo = 'user=gitlab_repmgr host=''$GCP_MASTER_CANDIDATE'' password=$GITLAB_REPMGR_PASSWORD port=5432 fallback_application_name=repmgr sslmode=prefer sslcompression=1 application_name=''$AZURE_MASTER'''
primary_slot_name = secondary_azureprd
restore_command = '/usr/bin/envdir /etc/wal-e.d/env /opt/wal-e/bin/wal-e wal-fetch -p 32 "%f" "%p"'
restore_command = '/usr/bin/envdir /etc/wal-e.d/env /opt/wal-e/bin/wal-e wal-fetch -p 32 \"%f\" \"%p\"'
recovery_target_timeline = 'latest'" | \
ssh_remote "$AZURE_MASTER" sudo tee /var/lib/opt/gitlab/postgresql/data/recovery.conf > /dev/null
ssh_remote "$AZURE_MASTER" sudo chown postgres:postgres /var/lib/opt/gitlab/postgresql/data/recovery.conf
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
if ssh_remote "$AZURE_MASTER" sudo -u gitlab-psql gitlab-psql postgres \
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
azure_master_lsn="$(ssh_remote "$AZURE_MASTER" sudo -u gitlab-psql gitlab-psql postgres \
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
# WARNING WARNING WARNING here switchover happens!
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
if ssh_remote "$GCP_MASTER_CANDIDATE" sudo -u gitlab-psql gitlab-psql postgres \
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
echo "Register $GCP_MASTER_CANDIDATE as master with repmgr"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
echo "Checking state of $GCP_MASTER_CANDIDATE"
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
# chef
......
......@@ -2,6 +2,7 @@
set -eu
# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"
for host in "${GCP_PGBOUNCERS[@]}"
......@@ -9,7 +10,7 @@ do
echo "Check pgbouncer on $host"
ssh_remote "$host" gitlab-ctl pgb-console -c "SHOW DATABASES"
ssh_remote "$host" gitlab-ctl pgb-console -c "SHOW SERVERS"
read -s -N 1 -p "Press [y] to continue, any other key to abort." key
read -r -s -N 1 -p "Press [y] to continue, any other key to abort." key
if [ "$key" != "y" ]
then
return 1
......
......@@ -72,9 +72,9 @@ function do_menu(){
fi
if which rlwrap > /dev/null 2>&1
then
command="$(rlwrap -f migration.dict -C migration bash -c 'read -p "'"$read_prompt"'" command; echo "$command"')"
command="$(rlwrap -f migration.dict -C migration bash -c 'read -r -p "'"$read_prompt"'" command; echo "$command"')"
else
read -p "$read_prompt" command
read -r -p "$read_prompt" command
fi
step=
case "$command" in
......@@ -126,7 +126,7 @@ function do_menu(){
cat "$script"
fi
echo
read -s -N 1 -p "Press [y] to continue, any other key to abort." key
read -r -s -N 1 -p "Press [y] to continue, any other key to abort." key
if [ "$key" == "y" ]
then
next_step="$(printf "%03d" "$(($(step_number "$step")+1))")"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment