Skip to content

Commit 7d6f27d

Browse files
committed
chore: check file existence before running psql against it
1 parent 4af43eb commit 7d6f27d

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

ansible/files/admin_api_scripts/pg_upgrade_complete.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ cleanup() {
2828
exit $EXIT_CODE
2929
}
3030

31-
cleanup() {
32-
UPGRADE_STATUS=${1:-"failed"}
33-
EXIT_CODE=${?:-0}
34-
35-
echo "${UPGRADE_STATUS}" > /tmp/pg-upgrade-status
36-
37-
exit $EXIT_CODE
38-
}
39-
4031
function complete_pg_upgrade {
4132
if [ -f /tmp/pg-upgrade-status ]; then
4233
echo "Upgrade job already started. Bailing."
@@ -60,7 +51,9 @@ function complete_pg_upgrade {
6051

6152
if [ -d /data/sql ]; then
6253
for FILE in /data/sql/*.sql; do
63-
run_sql -f $FILE
54+
if [ -f "$FILE" ]; then
55+
run_sql -f $FILE
56+
fi
6457
done
6558
fi
6659

ansible/files/admin_api_scripts/pg_upgrade_initiate.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,6 @@ run_sql() {
2424
psql -h localhost -U supabase_admin -d postgres -c "$STATEMENT"
2525
}
2626

27-
function shutdown_services {
28-
if [[ $(systemctl is-active gotrue) == "active" ]]; then
29-
echo "stopping gotrue"
30-
systemctl stop gotrue || true
31-
fi
32-
33-
if [[ $(systemctl is-active postgrest) == "active" ]]; then
34-
echo "stopping postgrest"
35-
systemctl stop postgrest || true
36-
fi
37-
}
38-
39-
function start_services {
40-
if [[ $(systemctl is-active gotrue) == "inactive" ]]; then
41-
echo "starting gotrue"
42-
systemctl start gotrue || true
43-
fi
44-
45-
if [[ $(systemctl is-active postgrest) == "inactive" ]]; then
46-
echo "starting postgrest"
47-
systemctl start postgrest || true
48-
fi
49-
}
50-
5127
cleanup() {
5228
UPGRADE_STATUS=${1:-"failed"}
5329
EXIT_CODE=${?:-0}

0 commit comments

Comments
 (0)