Skip to content

Commit 65ceab3

Browse files
committed
[DEVEL] setup-testdb invalid function syntax, mktemp: too few X's in template
Address the 3 problems with the setup_testdb.sh script on Linux 1. Invalid function declaration syntax 2. Invalid template syntax for mktemp (missing X characters) 3. Usage of `bash`-only commands in a script that wants to run in `sh` (pushd) Fixes smartcontractkit#16179 Signed-off-by: Peter Somogyvari <[email protected]>
1 parent 8af9a90 commit 65ceab3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/scripts/setup_testdb.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#/bin/sh
1+
#/bin/bash
22

3-
function exit_error {
3+
exit_error() {
44
echo "Error: $1"
55
exit 1
66
}
77
# Create a new user and database for development
88
# This script is intended to be run on a local development machine
9-
tdir=$(mktemp -d -t db-dev-user)
9+
tdir=$(mktemp -d -t db-dev-user.XXX-XXX)
1010

1111
username="chainlink_dev"
1212
password="insecurepassword"
@@ -44,15 +44,15 @@ echo "##########################################################################
4444
echo "##########################################################################################################"
4545
echo ""
4646
# Run the SQL commands
47-
psql -U postgres -h localhost -f $tdir/db-dev-user.sql || exit_error "Failed to create user $username and database $database"
47+
psql -U postgres -h localhost -p 55432 -f $tdir/db-dev-user.sql || exit_error "Failed to create user $username and database $database"
4848

4949

5050
#test the connection
51-
PGPASSWORD=$password psql -U $username -h localhost -d $database -c "SELECT 1" || exit_error "Connection failed for $username to $database"
51+
PGPASSWORD=$password psql -U $username -h localhost -p 55432 -d $database -c "SELECT 1" || exit_error "Connection failed for $username to $database"
5252

5353

5454

55-
db_url=$(echo "CL_DATABASE_URL=postgresql://$username:$password@localhost:5432/$database?sslmode=disable")
55+
db_url=$(echo "CL_DATABASE_URL=postgresql://$username:$password@localhost:55432/$database?sslmode=disable")
5656
echo $db_url
5757
repo=$(git rev-parse --show-toplevel)
5858
pushd $repo

0 commit comments

Comments
 (0)