5
0

Abort if token or database file not readable and no TTY

This commit is contained in:
sceox 2022-12-26 12:09:55 -08:00
parent 1b890db29f
commit 009ef80bbf

View File

@ -103,8 +103,10 @@ main () {
if test -r /etc/matrix-synapse/access_token ; then
token="$(cat /etc/matrix-synapse/access_token)"
elif ! [ -t 1 ]; then
echo "Error: Access token file is not readable and cannot prompt for token." >&2
exit 1
else
# TODO: if standard output is not a tty, exit with failure
read -p "synapse admin API access_token: " token
fi
@ -113,8 +115,10 @@ if test -r $db_conf_file; then
db_name="$(grep '^\s*database: ' $db_conf_file | awk '{print $2}')"
db_user="$(grep '^\s*user: ' $db_conf_file | awk '{print $2}')"
db_password="$(grep '^\s*password: ' $db_conf_file | awk '{print $2}')"
elif ! [ -t 1 ]; then
echo "Error: Database config file is not readable and cannot prompt for database config." >&2
exit 1
else
# TODO: if standard output is not a tty, exit with failure
read -p "synapse database name: " db_name
read -p "synapse database user: " db_user
read -p "synapse database password: " db_password