This repository has been archived on 2024-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
joomla/bin/generate_env.sh

51 lines
1.1 KiB
Bash
Raw Normal View History

2023-12-19 12:41:14 -08:00
#!/bin/bash
ENV_FILE=".env"
# Function to generate a random alphanumeric password of a given length
generate_password() {
tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c "${1:-12}"
}
# Function to prompt for a value if not set as a parameter
prompt_for_value() {
read -p "$1: " value
echo "$value"
}
# Set $PROJECTNAME if not provided as a parameter
PROJECTNAME=${1:-$(prompt_for_value "Enter PROJECTNAME")}
cat <<EOF > $ENV_FILE
# Docker
2023-12-19 13:05:01 -08:00
NETWORKNAME=admin_web
2023-12-19 12:41:14 -08:00
# MySQL
MYSQL_ROOT_PASSWORD=$(generate_password)
2023-12-19 13:05:01 -08:00
MYSQL_USER=u_$(echo $PROJECTNAME | tr '[:upper:]' '[:lower:]')
2023-12-19 12:41:14 -08:00
MYSQL_PASSWORD=$(generate_password)
MYSQL_DATABASE=db_$(echo $PROJECTNAME | tr '[:upper:]' '[:lower:]')
# GITEA
GITEA_API_URL=REPLACEME
ACCESS_TOKEN=REPLACEME
# Joomla
2023-12-19 13:05:01 -08:00
EMAIL=noreply@$(echo $PROJECTNAME | tr '[:upper:]' '[:lower:]').com
JOOMLA_USER="$PROJECTNAME"
2023-12-19 12:41:14 -08:00
JOOMLA_USERNAME=admin
# Passwords must be 12 characters long (admin-password)
JOOMLA_PASSWORD=$(generate_password)
# SMTP
SMTP_USER=null
SMTP_PASS=null
SMTP_HOST='mailhog'
SMTP_SECURITY='None'
SMTP_PORT=1025
EOF
2023-12-19 13:05:01 -08:00
rm $0
2023-12-19 12:41:14 -08:00
echo "Generated $ENV_FILE with randomly generated passwords and customized PROJECTNAME."