remove write info for mysql db, info is alwasy written now

This commit is contained in:
Matthew Saunders Brown 2023-05-10 15:29:07 -07:00
parent 05172002df
commit 6257436bc6
2 changed files with 17 additions and 22 deletions

View File

@ -21,7 +21,7 @@ help()
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 " -x <fpmmax> PHP-FPM pm.max_children. Optional, defaults to 4, recommended range 2-12 on Shared Server." echo " -x <fpmmax> 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 " -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 exit
} }
@ -121,4 +121,4 @@ fi
/usr/local/bin/vhost-add.sh -d $domain -u $username > /dev/null 2>&1 /usr/local/bin/vhost-add.sh -d $domain -u $username > /dev/null 2>&1
# add mysql database # 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

View File

@ -19,8 +19,6 @@ 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 <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 " -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'"
@ -28,7 +26,6 @@ help()
echo " the shell username & the virtualhost name." echo " the shell username & the virtualhost name."
echo " e.g. for virtualost example.com the db name will be 'exampledotcom' and the" echo " e.g. for virtualost example.com the db name will be 'exampledotcom' and the"
echo " username will be examplec@example.com." 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 "$@" vhost:getoptions "$@"
@ -79,23 +76,21 @@ mysql -e "GRANT ALL PRIVILEGES ON $database.* TO '$username'@'localhost';"
mysqladmin flush-privileges mysqladmin flush-privileges
# save mysql db info to file # save mysql db info to file
if [[ $write == 1 ]]; then touch /srv/www/$domain/.my.cnf
touch /srv/www/$domain/.my.cnf chown $vhost_username:$vhost_username /srv/www/$domain/.my.cnf
chown $vhost_username:$vhost_username /srv/www/$domain/.my.cnf chmod 640 /srv/www/$domain/.my.cnf
chmod 640 /srv/www/$domain/.my.cnf echo '[client]' > /srv/www/$domain/.my.cnf
echo '[client]' > /srv/www/$domain/.my.cnf echo "host=127.0.0.1" >> /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 "user=$username" >> /srv/www/$domain/.my.cnf echo "password=$password" >> /srv/www/$domain/.my.cnf
echo "password=$password" >> /srv/www/$domain/.my.cnf echo '[mysql]' >> /srv/www/$domain/.my.cnf
echo '[mysql]' >> /srv/www/$domain/.my.cnf echo "database=$database" >> /srv/www/$domain/.my.cnf
echo "database=$database" >> /srv/www/$domain/.my.cnf 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 if [[ ! -f /home/$vhost_username/.my.cnf ]]; then
if [[ ! -f /home/$vhost_username/.my.cnf ]]; then echo "#[client]" > /home/$vhost_username/.my.cnf
echo "#[client]" > /home/$vhost_username/.my.cnf echo '!include' "/srv/www/$domain/.my.cnf" >> /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