Add postgres and rabbitmq password update scripts

This commit is contained in:
jo 2021-08-05 21:31:47 +02:00
parent 579dfe5b9e
commit d0d21f1bc5
2 changed files with 42 additions and 0 deletions

21
utils/update-postgres-password Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -u
error() {
echo >&2 "error: $*"
exit 1
}
# Make sure only root can run our script
(($( id -u) == 0)) || error "this script must be run as root!"
command -v sudo > /dev/null || error "sudo command not found!"
command -v openssl > /dev/null || error "openssl command not found!"
command -v psql > /dev/null || error "psql command not found!"
typeset -r DB_USER="airtime"
typeset -r DB_PASSWORD=$(openssl rand -hex 16)
echo "Changing password for database user '$DB_USER' to '$DB_PASSWORD'"
sudo -u postgres psql -c "ALTER USER $DB_USER WITH PASSWORD '$DB_PASSWORD';"

21
utils/update-rabbitmq-password Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -u
error() {
echo >&2 "error: $*"
exit 1
}
# Make sure only root can run our script
(($( id -u) == 0)) || error "this script must be run as root!"
command -v openssl > /dev/null || error "openssl command not found!"
command -v rabbitmqctl > /dev/null || error "rabbitmqctl command not found!"
typeset -r RMQ_USER="airtime"
typeset -r RMQ_PASSWORD=$(openssl rand -hex 16)
# RabbitMQ
echo "Changing password for rabbitmq user '$RMQ_USER' to '$RMQ_PASSWORD'"
rabbitmqctl change_password "$RMQ_USER" "$RMQ_PASSWORD"