added password generator

This commit is contained in:
Nick Yeoman 2023-07-23 08:47:26 -07:00
parent bbb8ab9c13
commit 9fd870dee8

View File

@ -0,0 +1,21 @@
#!/bin/bash
# Function to generate a random password using passgen
generate_password() {
pwgen -cnsB1v 12
}
# Get the name of the current directory (project name)
PROJECT_NAME=$(basename "$(pwd)")
MYSQL_USER="${PROJECT_NAME}_joomla_user"
MYSQL_DATABASE="${PROJECT_NAME}_joomla_db"
echo "Generated passwords:"
# Generate passwords for specific variables and print them to CLI
echo "MYSQL_ROOT_PASSWORD=$(generate_password)"
echo "MYSQL_USER=$MYSQL_USER"
echo "MYSQL_DATABASE=$MYSQL_DATABASE"
echo "MYSQL_PASSWORD=$(generate_password)"
echo "MYSQL_DATABASE=$MYSQL_DATABASE"
echo "JOOMLA_PASSWORD=$(generate_password)"