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