Update default path of database config file
This commit is contained in:
parent
14372aab58
commit
25e5cccd84
@ -1,34 +1,22 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
# guide: https://levans.fr/shrink-synapse-database.html
|
# guide: https://levans.fr/shrink-synapse-database.html
|
||||||
# doc: https://matrix-org.github.io/synapse/develop/admin_api/purge_history_api.html
|
# doc: https://matrix-org.github.io/synapse/develop/admin_api/purge_history_api.html
|
||||||
|
|
||||||
host='localhost'
|
host='localhost'
|
||||||
port='8008'
|
port='8008'
|
||||||
synapse_log='/var/log/matrix-synapse/homeserver.log'
|
synapse_log='/var/log/matrix-synapse/homeserver.log'
|
||||||
homeserver_config='/etc/matrix-synapse/homeserver.yaml'
|
db_conf_file='/etc/matrix-synapse/conf.d/database.yaml'
|
||||||
rooms_query_limit=6666
|
rooms_query_limit=6666
|
||||||
|
range="2months"
|
||||||
|
|
||||||
debug=0
|
debug=0
|
||||||
|
|
||||||
# don't bother compressing unless we will save this much:
|
# don't bother compressing unless we will save this much:
|
||||||
min_compression_percent=15
|
min_compression_percent=15
|
||||||
|
|
||||||
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
|
|
||||||
read -p "history to keep (date range with no spaces, eg 1month, 1day): " range
|
|
||||||
fi
|
|
||||||
|
|
||||||
# synapse wants timestamps in milliseconds since the epoch
|
|
||||||
ts_history="$(date -d-${range} +%s)000"
|
|
||||||
ts_media="$(date -d-1month +%s)000"
|
|
||||||
|
|
||||||
debug () {
|
debug () {
|
||||||
if [ "$debug" = 1 ]; then
|
if [ "$debug" = 1 ]; then
|
||||||
echo $* 1>&2
|
echo $* 1>&2
|
||||||
@ -105,6 +93,26 @@ compress_state () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if test -r /etc/matrix-synapse/access_token ; then
|
||||||
|
token="$(cat /etc/matrix-synapse/access_token)"
|
||||||
|
else
|
||||||
|
# TODO: if standard output is not a tty, exit with failure
|
||||||
|
read -p "synapse admin API access_token: " token
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -r $db_conf_file; then
|
||||||
|
db_password="$(grep '^\s*password: ' $db_conf_file | awk '{print $2}')"
|
||||||
|
db_name="$(grep '^\s*database: ' $db_conf_file | awk '{print $2}')"
|
||||||
|
else
|
||||||
|
# TODO: if standard output is not a tty, exit with failure
|
||||||
|
read -p "synapse database name: " db_name
|
||||||
|
read -p "synapse database password: " db_password
|
||||||
|
fi
|
||||||
|
|
||||||
|
# synapse wants timestamps in milliseconds since the epoch
|
||||||
|
ts_history="$(date -d-${range} +%s)000"
|
||||||
|
ts_media="$(date -d-1month +%s)000"
|
||||||
|
|
||||||
purge_obsolete_rooms
|
purge_obsolete_rooms
|
||||||
purge_history $(get_all_rooms)
|
purge_history $(get_all_rooms)
|
||||||
purge_media_cache
|
purge_media_cache
|
||||||
|
Reference in New Issue
Block a user