From d000064624bbdc8301fe27259bab77c529f1e68b Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Sat, 15 Apr 2023 12:41:56 -0700 Subject: [PATCH] remove password warning, only create /home/username/.my.cnf if it doesn't exist --- bin/vhost-mysql-db-add.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/vhost-mysql-db-add.sh b/bin/vhost-mysql-db-add.sh index f2ed88e..8bb868a 100755 --- a/bin/vhost-mysql-db-add.sh +++ b/bin/vhost-mysql-db-add.sh @@ -19,8 +19,7 @@ help() echo " -d Domain name of VirtualHost to add db for." echo " -u Username for accessing the database. Optional, autogenerated if none specified." echo " -p 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 " /home/username/.my.cnf. Warning! This includes the unencrypted password." + echo " -w Write db info to /srv/www/domain/.my.cnf and create include in /home/username/.my.cnf." echo " -v Verbose - output newly created db info to console." echo "" 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 chown $vhost_username:$vhost_username /home/$vhost_username/.my.cnf chmod 640 /home/$vhost_username/.my.cnf - echo "#[client]" > /home/$vhost_username/.my.cnf - echo '!include' "/srv/www/$domain/.my.cnf" >> /home/$vhost_username/.my.cnf + if [[ ! -f /home/$vhost_username/.my.cnf ]]; then + echo "#[client]" > /home/$vhost_username/.my.cnf + echo '!include' "/srv/www/$domain/.my.cnf" >> /home/$vhost_username/.my.cnf + fi fi if [[ -n $verbose ]]; then