From 6257436bc6e1a04d252cf279b532eb154f1b877c Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Wed, 10 May 2023 15:29:07 -0700 Subject: [PATCH] remove write info for mysql db, info is alwasy written now --- bin/vhost-deploy.sh | 4 ++-- bin/vhost-mysql-db-add.sh | 35 +++++++++++++++-------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index 9a480c6..9b96aec 100755 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -21,7 +21,7 @@ help() echo " -p Password for username. Optional, random password generated if none specified." echo " -x PHP-FPM pm.max_children. Optional, defaults to 4, recommended range 2-12 on Shared Server." echo " -j <0|1> Whether or not to jail the user. 0 = no, 1 = yes. Default is 1, which can be overridden in main config." - echo " -w <0|1> Write user & mysql info to files. 0 = no, 1 = yes. Default is 1, which can be overridden in main config." + echo " -w <0|1> Write user info to /home/username/.passwd. 0 = no, 1 = yes. Default is 1, which can be overridden in main config." exit } @@ -121,4 +121,4 @@ fi /usr/local/bin/vhost-add.sh -d $domain -u $username > /dev/null 2>&1 # add mysql database -/usr/local/bin/vhost-mysql-db-add.sh -d $domain -w $write> /dev/null 2>&1 +/usr/local/bin/vhost-mysql-db-add.sh -d $domain> /dev/null 2>&1 diff --git a/bin/vhost-mysql-db-add.sh b/bin/vhost-mysql-db-add.sh index f4a1931..5a21aad 100755 --- a/bin/vhost-mysql-db-add.sh +++ b/bin/vhost-mysql-db-add.sh @@ -19,8 +19,6 @@ 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 <0|1> Write db info to /srv/www/domain/.my.cnf and create include in /home/username/.my.cnf." - echo " 0 = no, 1 = yes. Default is 1, which can be overridden in main config." 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'" @@ -28,7 +26,6 @@ help() echo " the shell username & the virtualhost name." echo " e.g. for virtualost example.com the db name will be 'exampledotcom' and the" echo " username will be examplec@example.com." - echo " It is highly recommended to use either the -w or -v option if you don't use -p." } vhost:getoptions "$@" @@ -79,23 +76,21 @@ mysql -e "GRANT ALL PRIVILEGES ON $database.* TO '$username'@'localhost';" mysqladmin flush-privileges # save mysql db info to file -if [[ $write == 1 ]]; then - touch /srv/www/$domain/.my.cnf - chown $vhost_username:$vhost_username /srv/www/$domain/.my.cnf - chmod 640 /srv/www/$domain/.my.cnf - echo '[client]' > /srv/www/$domain/.my.cnf - echo "host=127.0.0.1" >> /srv/www/$domain/.my.cnf - echo "user=$username" >> /srv/www/$domain/.my.cnf - echo "password=$password" >> /srv/www/$domain/.my.cnf - echo '[mysql]' >> /srv/www/$domain/.my.cnf - echo "database=$database" >> /srv/www/$domain/.my.cnf - touch /home/$vhost_username/.my.cnf - chown $vhost_username:$vhost_username /home/$vhost_username/.my.cnf - chmod 640 /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 +touch /srv/www/$domain/.my.cnf +chown $vhost_username:$vhost_username /srv/www/$domain/.my.cnf +chmod 640 /srv/www/$domain/.my.cnf +echo '[client]' > /srv/www/$domain/.my.cnf +echo "host=127.0.0.1" >> /srv/www/$domain/.my.cnf +echo "user=$username" >> /srv/www/$domain/.my.cnf +echo "password=$password" >> /srv/www/$domain/.my.cnf +echo '[mysql]' >> /srv/www/$domain/.my.cnf +echo "database=$database" >> /srv/www/$domain/.my.cnf +touch /home/$vhost_username/.my.cnf +chown $vhost_username:$vhost_username /home/$vhost_username/.my.cnf +chmod 640 /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 if [[ -n $verbose ]]; then