remove password warning, only create /home/username/.my.cnf if it doesn't exist

This commit is contained in:
Matthew Saunders Brown 2023-04-15 12:41:56 -07:00
parent 5788ca2040
commit d000064624

View File

@ -19,8 +19,7 @@ help()
echo " -d <domain> Domain name of VirtualHost to add db for." echo " -d <domain> Domain name of VirtualHost to add db for."
echo " -u <username> Username for accessing the database. Optional, autogenerated if none specified." echo " -u <username> Username for accessing the database. Optional, autogenerated if none specified."
echo " -p <password> Password for username. Optional, random password generated if none specified." echo " -p <password> Password for username. Optional, random password generated if none specified."
echo " -w Write db info to /srv/www/domain/.my.cnf and create include in" echo " -w Write db info to /srv/www/domain/.my.cnf and create include in /home/username/.my.cnf."
echo " /home/username/.my.cnf. Warning! This includes the unencrypted password."
echo " -v Verbose - output newly created db info to console." echo " -v Verbose - output newly created db info to console."
echo "" echo ""
echo " MySQL database names is based on virtualhost with . replaced by the word 'dot'" echo " MySQL database names is based on virtualhost with . replaced by the word 'dot'"
@ -87,8 +86,10 @@ if [[ -n $write ]]; then
touch /home/$vhost_username/.my.cnf touch /home/$vhost_username/.my.cnf
chown $vhost_username:$vhost_username /home/$vhost_username/.my.cnf chown $vhost_username:$vhost_username /home/$vhost_username/.my.cnf
chmod 640 /home/$vhost_username/.my.cnf chmod 640 /home/$vhost_username/.my.cnf
echo "#[client]" > /home/$vhost_username/.my.cnf if [[ ! -f /home/$vhost_username/.my.cnf ]]; then
echo '!include' "/srv/www/$domain/.my.cnf" >> /home/$vhost_username/.my.cnf echo "#[client]" > /home/$vhost_username/.my.cnf
echo '!include' "/srv/www/$domain/.my.cnf" >> /home/$vhost_username/.my.cnf
fi
fi fi
if [[ -n $verbose ]]; then if [[ -n $verbose ]]; then