From 14372aab5818ee8b2530d232f22d956a1fb7984b Mon Sep 17 00:00:00 2001 From: sceox Date: Mon, 7 Mar 2022 13:18:19 -0800 Subject: [PATCH] pull the database name from the homeserver config file --- synapse-purge-compress.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/synapse-purge-compress.sh b/synapse-purge-compress.sh index 72f2a51..16e3019 100755 --- a/synapse-purge-compress.sh +++ b/synapse-purge-compress.sh @@ -18,6 +18,7 @@ if test -r /etc/matrix-synapse/access_token ; then token="$(cat /etc/matrix-synapse/access_token)" range="2months" db_password="$(grep '^\s*password: ' $homeserver_config | awk '{print $2}')" + db_name="$(grep '^\s*database: ' $homeserver_config | awk '{print $2}')" else # TODO: if standard output is not a tty, exit with failure read -p "synapse admin API access_token: " token @@ -93,7 +94,7 @@ compress_state () { for room_id ; do sqlf="/tmp/$(echo $room_id | tr -c -d '[:alpha:]').sql" repl=$(synapse-compress-state -t -o $sqlf -p \ - "host=${host} user=synapse password=${db_password} dbname=synapse" \ + "host=${host} user=synapse password=${db_password} dbname=${db_name}" \ -r "$room_id" | sed -n '/%/s/.*(\([0-9]*\).[0-9]*%).*/\1/p') if [ "$repl" -le "$((100 - $min_compression_percent))" ]; then