mysql site option

Option to create MySQL site.
This commit is contained in:
Cristhian Martínez Ochoa 2017-12-18 21:26:05 -06:00
parent a3e5906ae4
commit d97a3da0b5
2 changed files with 20 additions and 7 deletions

View file

@ -31,7 +31,7 @@ wpinstall() {
local dbpref="wp_" local dbpref="wp_"
echo "${blu}" echo "${blu}"
if [[ $wp != [2] ]]; then if [[ $wp == 1 ]]; then
echo "Do you need to setup new MySQL database? [Y/n]" echo "Do you need to setup new MySQL database? [Y/n]"
while read -r -n 1 -s setupmysql; do while read -r -n 1 -s setupmysql; do
setupmysql=${setupmysql:-y} setupmysql=${setupmysql:-y}
@ -44,12 +44,17 @@ wpinstall() {
done done
fi fi
# Just create DB, not install WP
[[ $wp == 0 ]] && setupwp="n"
# Download WP (latest version) # Download WP (latest version)
sudo wget --timeout=15 -qrO /var/www/$domain/htdocs/wp.tar.gz https://wordpress.org/latest.tar.gz if [[ $wp == [12] ]]; then
sudo tar -xf /var/www/$domain/htdocs/wp.tar.gz -C /var/www/$domain/htdocs/ sudo wget --timeout=15 -qrO /var/www/$domain/htdocs/wp.tar.gz https://wordpress.org/latest.tar.gz
sudo mv /var/www/$domain/htdocs/wordpress/* /var/www/$domain/htdocs/ sudo tar -xf /var/www/$domain/htdocs/wp.tar.gz -C /var/www/$domain/htdocs/
sudo rm -rf /var/www/$domain/htdocs/wordpress sudo mv /var/www/$domain/htdocs/wordpress/* /var/www/$domain/htdocs/
sudo rm /var/www/$domain/htdocs/wp.tar.gz sudo rm -rf /var/www/$domain/htdocs/wordpress
sudo rm /var/www/$domain/htdocs/wp.tar.gz
fi
# Generate and auto-fill wp-config.php and also create database # Generate and auto-fill wp-config.php and also create database
if [[ "$setupmysql" == y || "$setupmysql" == Y || "$setupwp" == y || "$setupwp" == Y ]] ; then if [[ "$setupmysql" == y || "$setupmysql" == Y || "$setupwp" == y || "$setupwp" == Y ]] ; then
@ -144,7 +149,8 @@ wpinstall() {
if [[ $wp != [2] ]]; then if [[ $wp != [2] ]]; then
read -p "Database User [$dom]:" dbuser read -p "Database User [$dom]:" dbuser
read -p "Database Password [$AUTOGENPASS_WPDB]:" dbpass read -p "Database Password [$AUTOGENPASS_WPDB]:" dbpass
read -p "Database Prefix [wp_]:" dbpref # Not ask for wp_prefix when wp=0 (mysql only site)
[[ $wp == 0 ]] || read -p "Database Prefix [wp_]:" dbpref
echo "${end}" echo "${end}"
# If empty, assign defalut values # If empty, assign defalut values

View file

@ -89,6 +89,13 @@ elif [[ "$domain" == "-delete-all" && -z "$type" && -z "$cache" ]]; then
elif [ "$type" == "-php" ]; then elif [ "$type" == "-php" ]; then
createsite createsite
# Create MYSQL site
elif [ "$type" == "-mysql" ]; then
# We use WP function to create DB when wp=0 WP files are not installed.
createsite
wpinstall
# Create HTML site # Create HTML site
elif [ "$type" == "-html" ]; then elif [ "$type" == "-html" ]; then