Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ function parse_url() {
DB_HOST="${hostport}"
fi

# Check if the host is an IP address or hostname
if [[ "$DB_HOST" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# If it's an IP, try to resolve it to a hostname
DB_HOST=$(getent hosts "$DB_HOST" | awk '{ print $2 }')
# If the resolution fails (no hostname found), we can leave it as is (i.e., IP)
if [ -z "$DB_HOST" ]; then
echo "Warning: DB_HOST is an IP address, and no hostname resolution was performed."
fi
fi

DB_NAME="$(echo $url | grep / | cut -d/ -f2-)"
}

Expand Down