Skip to content

Commit 8033008

Browse files
committed
fix: restore sh files undo formatting
1 parent 6d0bf0e commit 8033008

33 files changed

+1733
-1723
lines changed

ansible/files/admin_api_scripts/grow_fs.sh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ VOLUME_TYPE=${1:-data}
88
UBUNTU_VERSION=$(lsb_release -rs)
99

1010
if pgrep resizefs; then
11-
echo "resize2fs is already running"
12-
exit 1
11+
echo "resize2fs is already running"
12+
exit 1
1313
fi
1414

1515
# install amazon disk utilities if not present on 24.04
1616
if [ "${UBUNTU_VERSION}" = "24.04" ] && ! /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then
17-
apt-get update
18-
apt-get install -y amazon-ec2-utils || true
17+
apt-get update
18+
apt-get install -y amazon-ec2-utils || true
1919
fi
2020

2121
# We currently mount 3 possible disks
@@ -27,15 +27,15 @@ XVDA_DEVICE="/dev/nvme0n1"
2727
XVDH_DEVICE="/dev/nvme1n1"
2828
# Map AWS devices to NVMe for ubuntu 24.04 and later
2929
if [ "${UBUNTU_VERSION}" = "24.04" ] && /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then
30-
for nvme_dev in $(lsblk -dprno name,type | grep disk | awk '{print $1}'); do
31-
if [ -b "$nvme_dev" ]; then
32-
mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null)
33-
case "$mapping" in
34-
"xvda" | "/dev/xvda") XVDA_DEVICE="$nvme_dev" ;;
35-
"xvdh" | "/dev/xvdh") XVDH_DEVICE="$nvme_dev" ;;
36-
esac
37-
fi
38-
done
30+
for nvme_dev in $(lsblk -dprno name,type | grep disk | awk '{print $1}'); do
31+
if [ -b "$nvme_dev" ]; then
32+
mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null)
33+
case "$mapping" in
34+
"xvda"|"/dev/xvda") XVDA_DEVICE="$nvme_dev" ;;
35+
"xvdh"|"/dev/xvdh") XVDH_DEVICE="$nvme_dev" ;;
36+
esac
37+
fi
38+
done
3939
fi
4040

4141
echo "Using devices - Root: $XVDA_DEVICE, Data: $XVDH_DEVICE"
@@ -45,29 +45,29 @@ ROOT_DEVICE_FULL=$(findmnt -no SOURCE /)
4545
ROOT_DEVICE=$(lsblk -no PKNAME "$ROOT_DEVICE_FULL")
4646
ROOT_PARTITION_NUMBER=$(echo "$ROOT_DEVICE_FULL" | sed "s|.*${ROOT_DEVICE}p||")
4747

48-
if ! [[ $ROOT_PARTITION_NUMBER =~ ^[0-9]+$ ]]; then
48+
if ! [[ "$ROOT_PARTITION_NUMBER" =~ ^[0-9]+$ ]]; then
4949
echo "Error: ROOT_PARTITION_NUMBER is not a valid number: $ROOT_PARTITION_NUMBER"
5050
exit 1
5151
fi
5252

53-
if [ -b "${XVDH_DEVICE}" ]; then
54-
if [[ ${VOLUME_TYPE} == "data" ]]; then
55-
resize2fs "${XVDH_DEVICE}"
53+
if [ -b "${XVDH_DEVICE}" ] ; then
54+
if [[ "${VOLUME_TYPE}" == "data" ]]; then
55+
resize2fs "${XVDH_DEVICE}"
5656

57-
elif [[ ${VOLUME_TYPE} == "root" ]]; then
58-
PLACEHOLDER_FL=/home/ubuntu/50M_PLACEHOLDER
59-
rm -f "${PLACEHOLDER_FL}" || true
60-
growpart "${XVDA_DEVICE}" "${ROOT_PARTITION_NUMBER}"
61-
resize2fs "${XVDA_DEVICE}p${ROOT_PARTITION_NUMBER}"
62-
if [[ ! -f ${PLACEHOLDER_FL} ]]; then
63-
fallocate -l50M "${PLACEHOLDER_FL}"
57+
elif [[ "${VOLUME_TYPE}" == "root" ]] ; then
58+
PLACEHOLDER_FL=/home/ubuntu/50M_PLACEHOLDER
59+
rm -f "${PLACEHOLDER_FL}" || true
60+
growpart "${XVDA_DEVICE}" "${ROOT_PARTITION_NUMBER}"
61+
resize2fs "${XVDA_DEVICE}p${ROOT_PARTITION_NUMBER}"
62+
if [[ ! -f "${PLACEHOLDER_FL}" ]] ; then
63+
fallocate -l50M "${PLACEHOLDER_FL}"
64+
fi
65+
else
66+
echo "Invalid disk specified: ${VOLUME_TYPE}"
67+
exit 1
6468
fi
65-
else
66-
echo "Invalid disk specified: ${VOLUME_TYPE}"
67-
exit 1
68-
fi
6969
else
70-
growpart "${XVDA_DEVICE}" "${ROOT_PARTITION_NUMBER}"
71-
resize2fs "${XVDA_DEVICE}p${ROOT_PARTITION_NUMBER}"
70+
growpart "${XVDA_DEVICE}" "${ROOT_PARTITION_NUMBER}"
71+
resize2fs "${XVDA_DEVICE}p${ROOT_PARTITION_NUMBER}"
7272
fi
7373
echo "Done resizing disk"

ansible/files/admin_api_scripts/manage_readonly_mode.sh

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ set -euo pipefail
55
SUBCOMMAND=$1
66

77
function set_mode {
8-
MODE=$1
9-
psql -h localhost -U supabase_admin -d postgres -c "ALTER SYSTEM SET default_transaction_read_only to ${MODE};"
10-
psql -h localhost -U supabase_admin -d postgres -c "SELECT pg_reload_conf();"
8+
MODE=$1
9+
psql -h localhost -U supabase_admin -d postgres -c "ALTER SYSTEM SET default_transaction_read_only to ${MODE};"
10+
psql -h localhost -U supabase_admin -d postgres -c "SELECT pg_reload_conf();"
1111
}
1212

1313
function check_override {
14-
COMMAND=$(
15-
cat <<EOF
14+
COMMAND=$(cat <<EOF
1615
WITH role_comment as (
1716
SELECT pg_catalog.shobj_description(r.oid, 'pg_authid') AS content
1817
FROM pg_catalog.pg_roles r
@@ -26,21 +25,21 @@ SELECT
2625
END as override_active
2726
FROM role_comment;
2827
EOF
29-
)
30-
RESULT=$(psql -h localhost -U supabase_admin -d postgres -At -c "$COMMAND")
31-
echo -n "$RESULT"
28+
)
29+
RESULT=$(psql -h localhost -U supabase_admin -d postgres -At -c "$COMMAND")
30+
echo -n "$RESULT"
3231
}
3332

3433
case $SUBCOMMAND in
35-
"check_override")
36-
check_override
37-
;;
38-
"set")
39-
shift
40-
set_mode "$@"
41-
;;
42-
*)
43-
echo "Error: '$SUBCOMMAND' is not a known subcommand."
44-
exit 1
45-
;;
46-
esac
34+
"check_override")
35+
check_override
36+
;;
37+
"set")
38+
shift
39+
set_mode "$@"
40+
;;
41+
*)
42+
echo "Error: '$SUBCOMMAND' is not a known subcommand."
43+
exit 1
44+
;;
45+
esac

ansible/files/admin_api_scripts/mount-volume.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55
DEVICE=${1:-}
66
MOUNT_POINT=${2:-}
77

8-
if [[ -z $DEVICE || -z $MOUNT_POINT ]]; then
8+
if [[ -z "$DEVICE" || -z "$MOUNT_POINT" ]]; then
99
echo "Usage: $0 <device> <mount_point>"
1010
echo "Example: sudo ./mount-volume.sh /dev/nvme1n1 /data/150008"
1111
exit 1
@@ -54,7 +54,7 @@ FSTAB_LINE="UUID=$UUID $MOUNT_POINT $FSTYPE $MOUNT_OPTS 0 2"
5454

5555
if ! grep -q "$UUID" "$FSTAB_FILE"; then
5656
echo "Adding $FSTAB_LINE to $FSTAB_FILE"
57-
echo "$FSTAB_LINE" >>"$FSTAB_FILE"
57+
echo "$FSTAB_LINE" >> "$FSTAB_FILE"
5858
else
5959
echo "UUID $UUID already in $FSTAB_FILE — skipping"
6060
fi

ansible/files/admin_api_scripts/pg_upgrade_scripts/check.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ set -euo pipefail
88
STATUS_FILE="/tmp/pg-upgrade-status"
99

1010
if [ -f "${STATUS_FILE}" ]; then
11-
STATUS=$(cat "${STATUS_FILE}")
12-
echo -n "${STATUS}"
11+
STATUS=$(cat "${STATUS_FILE}")
12+
echo -n "${STATUS}"
1313
else
14-
echo -n "unknown"
14+
echo -n "unknown"
1515
fi
16+

ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,41 @@ REPORTING_CREDENTIALS_FILE="/root/upgrade-reporting-credentials"
77

88
REPORTING_ANON_KEY=""
99
if [ -f "$REPORTING_CREDENTIALS_FILE" ]; then
10-
REPORTING_ANON_KEY=$(cat "$REPORTING_CREDENTIALS_FILE")
10+
REPORTING_ANON_KEY=$(cat "$REPORTING_CREDENTIALS_FILE")
1111
fi
1212

1313
# shellcheck disable=SC2120
1414
# Arguments are passed in other files
1515
function run_sql {
16-
psql -h localhost -U supabase_admin -d postgres "$@"
16+
psql -h localhost -U supabase_admin -d postgres "$@"
1717
}
1818

1919
function ship_logs {
20-
LOG_FILE=$1
21-
22-
if [ -z "$REPORTING_ANON_KEY" ]; then
23-
echo "No reporting key found. Skipping log upload."
24-
return 0
25-
fi
26-
27-
if [ ! -f "$LOG_FILE" ]; then
28-
echo "No log file found. Skipping log upload."
29-
return 0
30-
fi
31-
32-
if [ ! -s "$LOG_FILE" ]; then
33-
echo "Log file is empty. Skipping log upload."
34-
return 0
35-
fi
36-
37-
HOSTNAME=$(hostname)
38-
DERIVED_REF="${HOSTNAME##*-}"
39-
40-
printf -v BODY '{ "ref": "%s", "step": "%s", "content": %s }' "$DERIVED_REF" "completion" "$(cat "$LOG_FILE" | jq -Rs '.')"
41-
curl -sf -X POST "https://$REPORTING_PROJECT_REF.supabase.co/rest/v1/error_logs" \
42-
-H "apikey: ${REPORTING_ANON_KEY}" \
43-
-H 'Content-type: application/json' \
44-
-d "$BODY"
20+
LOG_FILE=$1
21+
22+
if [ -z "$REPORTING_ANON_KEY" ]; then
23+
echo "No reporting key found. Skipping log upload."
24+
return 0
25+
fi
26+
27+
if [ ! -f "$LOG_FILE" ]; then
28+
echo "No log file found. Skipping log upload."
29+
return 0
30+
fi
31+
32+
if [ ! -s "$LOG_FILE" ]; then
33+
echo "Log file is empty. Skipping log upload."
34+
return 0
35+
fi
36+
37+
HOSTNAME=$(hostname)
38+
DERIVED_REF="${HOSTNAME##*-}"
39+
40+
printf -v BODY '{ "ref": "%s", "step": "%s", "content": %s }' "$DERIVED_REF" "completion" "$(cat "$LOG_FILE" | jq -Rs '.')"
41+
curl -sf -X POST "https://$REPORTING_PROJECT_REF.supabase.co/rest/v1/error_logs" \
42+
-H "apikey: ${REPORTING_ANON_KEY}" \
43+
-H 'Content-type: application/json' \
44+
-d "$BODY"
4545
}
4646

4747
function retry {
@@ -54,53 +54,53 @@ function retry {
5454
wait=$((2 ** (count + 1)))
5555
count=$((count + 1))
5656
if [ $count -lt "$retries" ]; then
57-
echo "Command $* exited with code $exit, retrying..."
58-
sleep $wait
57+
echo "Command $* exited with code $exit, retrying..."
58+
sleep $wait
5959
else
60-
echo "Command $* exited with code $exit, no more retries left."
61-
return $exit
60+
echo "Command $* exited with code $exit, no more retries left."
61+
return $exit
6262
fi
6363
done
6464
return 0
6565
}
6666

6767
CI_stop_postgres() {
68-
BINDIR=$(pg_config --bindir)
69-
ARG=${1:-""}
68+
BINDIR=$(pg_config --bindir)
69+
ARG=${1:-""}
7070

71-
if [ "$ARG" = "--new-bin" ]; then
72-
BINDIR="/tmp/pg_upgrade_bin/$PG_MAJOR_VERSION/bin"
73-
fi
71+
if [ "$ARG" = "--new-bin" ]; then
72+
BINDIR="/tmp/pg_upgrade_bin/$PG_MAJOR_VERSION/bin"
73+
fi
7474

75-
su postgres -c "$BINDIR/pg_ctl stop -o '-c config_file=/etc/postgresql/postgresql.conf' -l /tmp/postgres.log"
75+
su postgres -c "$BINDIR/pg_ctl stop -o '-c config_file=/etc/postgresql/postgresql.conf' -l /tmp/postgres.log"
7676
}
7777

7878
CI_start_postgres() {
79-
BINDIR=$(pg_config --bindir)
80-
ARG=${1:-""}
79+
BINDIR=$(pg_config --bindir)
80+
ARG=${1:-""}
8181

82-
if [ "$ARG" = "--new-bin" ]; then
83-
BINDIR="/tmp/pg_upgrade_bin/$PG_MAJOR_VERSION/bin"
84-
fi
82+
if [ "$ARG" = "--new-bin" ]; then
83+
BINDIR="/tmp/pg_upgrade_bin/$PG_MAJOR_VERSION/bin"
84+
fi
8585

86-
su postgres -c "$BINDIR/pg_ctl start -o '-c config_file=/etc/postgresql/postgresql.conf' -l /tmp/postgres.log"
86+
su postgres -c "$BINDIR/pg_ctl start -o '-c config_file=/etc/postgresql/postgresql.conf' -l /tmp/postgres.log"
8787
}
8888

8989
swap_postgres_and_supabase_admin() {
90-
run_sql <<'EOSQL'
90+
run_sql <<'EOSQL'
9191
alter database postgres connection limit 0;
9292
select pg_terminate_backend(pid) from pg_stat_activity where backend_type = 'client backend' and pid != pg_backend_pid();
9393
EOSQL
9494

95-
if [ -z "$IS_CI" ]; then
96-
retry 5 systemctl restart postgresql
97-
else
98-
CI_start_postgres ""
99-
fi
95+
if [ -z "$IS_CI" ]; then
96+
retry 5 systemctl restart postgresql
97+
else
98+
CI_start_postgres ""
99+
fi
100100

101-
retry 8 pg_isready -h localhost -U supabase_admin
101+
retry 8 pg_isready -h localhost -U supabase_admin
102102

103-
run_sql <<'EOSQL'
103+
run_sql <<'EOSQL'
104104
set statement_timeout = '600s';
105105
begin;
106106
create role supabase_tmp superuser;

0 commit comments

Comments
 (0)