add ability to create users

This commit is contained in:
ILoveYaToo 2020-04-15 23:30:33 -04:00
parent 3a072a8e83
commit c548b3ac58

View File

@ -6,38 +6,37 @@ rm -rf /tmp/postal
## Generate config ## Generate config
if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then
## Build Jinja2 Template ## Build Jinja2 Template
p2 -t /templates/postal.example.yml.j2 -o /opt/postal/config/postal.example.yml p2 -t /templates/postal.example.yml.j2 -o /opt/postal/config/postal.example.yml
## Add in secret key building ## Add in secret key building
echo "rails:" >> /opt/postal/config/postal.example.yml echo "rails:" >> /opt/postal/config/postal.example.yml
echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml
## Generate config and keys ## Generate config and keys
/opt/postal/bin/postal initialize-config /opt/postal/bin/postal initialize-config
## Wait for MySQL to start up ## Wait for MySQL to start up
echo "== Waiting for MySQL to start up ==" echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do while ! mysqladmin ping -h mysql --silent; do
sleep 0.5 sleep 0.5
done done
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
sleep 0.5 sleep 0.5
done done
/opt/postal/bin/postal initialize /opt/postal/bin/postal initialize
/opt/postal/bin/postal make-user << EOF /opt/postal/bin/postal make-user << EOF
$POSTAL_EMAIL $POSTAL_EMAIL
$POSTAL_FNAME $POSTAL_FNAME
$POSTAL_LNAME $POSTAL_LNAME
$POSTAL_PASSWORD $POSTAL_PASSWORD
EOF EOF
else else
## Wait for MySQL to start up
## Wait for MySQL to start up echo "== Waiting for MySQL to start up =="
echo "== Waiting for MySQL to start up ==" while ! mysqladmin ping -h mysql --silent; do
while ! mysqladmin ping -h mysql --silent; do sleep 0.5
sleep 0.5 done
done while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do sleep 0.5
sleep 0.5 done
done
fi fi
## Start Postal ## Start Postal
/opt/postal/bin/postal "$@" /opt/postal/bin/postal "$@"