add ability to create users

This commit is contained in:
ILoveYaToo 2020-04-15 22:41:17 -04:00
parent f475583a6f
commit c9dfcf3435
2 changed files with 33 additions and 14 deletions

View File

@ -19,6 +19,10 @@ services:
- RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=changeme
- RABBITMQ_DEFAULT_VHOST=postal
- POSTAL_FNAME=Sia
- POSTAL_LNAME=Cat
- POSTAL_PASSWORD=SecretCatPassword
- POSTAL_EMAIL=myemail@catsworld.com
mysql:
image: mariadb:10
container_name: postal_mysql

View File

@ -1,5 +1,9 @@
#!/bin/bash
## Clean Up
rm -rf /opt/postal/tmp/pids/*
rm -rf /tmp/postal
## Generate config
if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then
## Build Jinja2 Template
@ -9,20 +13,31 @@ if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.
echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml
## Generate config and keys
/opt/postal/bin/postal initialize-config
## Wait for MySQL to start up
echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do
sleep 0.5
done
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
sleep 0.5
done
/opt/postal/bin/postal initialize
/opt/postal/bin/postal make-user << EOF
"$POSTAL_EMAIL"
"$POSTAL_FNAME"
"$POSTAL_LNAME"
"$POSTAL_PASSWORD"
else
## Wait for MySQL to start up
echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do
sleep 0.5
done
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
sleep 0.5
done
fi
cat /opt/postal/config/postal.yml
## Clean Up
rm -rf /opt/postal/tmp/pids/*
rm -rf /tmp/postal
## Wait for MySQL to start up
echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do
sleep 0.5
done
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
sleep 0.5
done
## Start Postal
/opt/postal/bin/postal "$@"