From 966c28a45871655c6e0d907d93704682e3a1ea95 Mon Sep 17 00:00:00 2001 From: witchent Date: Mon, 14 Apr 2025 22:08:21 +0000 Subject: [PATCH] Add options for database string and use it for sockets --- app/entrypoint.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 5b664fe..85e23a1 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -12,13 +12,20 @@ url="$(echo ${SYNC_TOKENSERVER_DATABASE_URL/$proto/})" userpass="$(echo $url | grep @ | cut -d@ -f1)" pass="$(echo $userpass | grep : | cut -d: -f2)" user="$(echo $userpass | grep : | cut -d: -f1)" -host="$(echo ${url/$user:$pass@/} | cut -d/ -f1)" -port="$(echo $host | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')" -host="$(echo ${host/:$port/} | cut -d/ -f1)" -db="$(echo $url | grep / | cut -d/ -f2-)" +hostport="$(echo ${url/$user:$pass@/} | cut -d/ -f1)" +port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')" +host="$(echo ${hostport/:$port/} | cut -d/ -f1)" +db="$(echo $url | grep / | cut -d/ -f2 | cut -d? -f1)" +IFS="&" read -ra options <<< $(echo $url | grep ? | cut -d? -f2) +for option in "${options[@]}" +do + declare "$(echo $option | cut -d= -f1)=$(echo $option | cut -d= -f2)" +done # Create service and node if they doesnt exist -mysql $db -h $host -P $port -u $user -p"$pass" < /config/local.toml <