mysql site unattended
MySQL site now can run unattended and also acept default and custom data.
This commit is contained in:
parent
ab654a0b7b
commit
448870d1bc
32
lib/sites
32
lib/sites
|
@ -77,9 +77,9 @@ dbword_check() {
|
||||||
|
|
||||||
|
|
||||||
wpinstall() {
|
wpinstall() {
|
||||||
|
[[ $domain == "-mysql" ]] && local dom="Webinoly_$(pwgen -s -1)" || local dom=${domain//./_}
|
||||||
local ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
|
local ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
|
||||||
local AUTOGENPASS_WPDB=`pwgen -s -1`
|
local AUTOGENPASS_WPDB=`pwgen -s -1`
|
||||||
local dom=${domain//./_}
|
|
||||||
local setupmysql="y"
|
local setupmysql="y"
|
||||||
local setupwp="y"
|
local setupwp="y"
|
||||||
local dbhost="localhost"
|
local dbhost="localhost"
|
||||||
|
@ -89,7 +89,7 @@ wpinstall() {
|
||||||
local dbpref="wp_"
|
local dbpref="wp_"
|
||||||
|
|
||||||
# WP with Custom Data
|
# WP with Custom Data
|
||||||
if [[ $wp == 3 ]]; then
|
if [[ $wp == [35] ]]; then
|
||||||
[[ $setmsqcustom == "false" ]] && setupmysql="n"
|
[[ $setmsqcustom == "false" ]] && setupmysql="n"
|
||||||
[[ $setpwpcustom == "false" ]] && setupwp="n"
|
[[ $setpwpcustom == "false" ]] && setupwp="n"
|
||||||
|
|
||||||
|
@ -102,6 +102,16 @@ wpinstall() {
|
||||||
dbproot="$expasscustom"
|
dbproot="$expasscustom"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Print MySQL default data
|
||||||
|
if [[ $wp == 4 ]]; then
|
||||||
|
echo "${blu}"
|
||||||
|
echo "Host: $dbhost"
|
||||||
|
echo "Database Name: $dbname"
|
||||||
|
echo "Database User: $dbuser"
|
||||||
|
echo "Password: $dbpass"
|
||||||
|
echo "${end}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${blu}"
|
echo "${blu}"
|
||||||
if [[ $wp == 1 ]]; 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]"
|
||||||
|
@ -117,7 +127,7 @@ wpinstall() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Just create DB, not install WP
|
# Just create DB, not install WP
|
||||||
[[ $wp == 0 ]] && setupwp="n"
|
[[ $wp == [045] ]] && setupwp="n"
|
||||||
|
|
||||||
# Download WP (latest version)
|
# Download WP (latest version)
|
||||||
if [[ $wp == [123] ]]; then
|
if [[ $wp == [123] ]]; then
|
||||||
|
@ -137,16 +147,16 @@ wpinstall() {
|
||||||
done="1"
|
done="1"
|
||||||
# Ask DB data or suggest default values
|
# Ask DB data or suggest default values
|
||||||
echo ""
|
echo ""
|
||||||
[[ $wp == [23] ]] || read -p "Database Host [localhost]:" dbhost
|
[[ $wp == [2345] ]] || read -p "Database Host [localhost]:" dbhost
|
||||||
dbhost=${dbhost:-localhost}
|
dbhost=${dbhost:-localhost}
|
||||||
|
|
||||||
if [[ $dbhost == "localhost" && ( "$setupmysql" == y || "$setupmysql" == Y ) && $(conf_read mysql) != "true" ]]; then
|
if [[ $dbhost == "localhost" && $setupmysql == [yY] && $(conf_read mysql) != "true" ]]; then
|
||||||
echo "${red} [ERROR] MySQL is not installed or localhost was not found!${blu}"
|
echo "${red} [ERROR] MySQL is not installed or localhost was not found!${blu}"
|
||||||
done="0"
|
done="0"
|
||||||
continue 1;
|
continue 1;
|
||||||
fi
|
fi
|
||||||
# Check if localhost or external DB
|
# Check if localhost or external DB
|
||||||
if [[ $dbhost != "localhost" && ( "$setupmysql" == y || "$setupmysql" == Y ) ]]; then
|
if [[ $dbhost != "localhost" && $setupmysql == [yY] ]]; then
|
||||||
if [[ $(conf_read mysql-client) != "true" ]]; then
|
if [[ $(conf_read mysql-client) != "true" ]]; then
|
||||||
echo "${gre}MySQL Client is not installed and we need it to stablish a connection with your external server."
|
echo "${gre}MySQL Client is not installed and we need it to stablish a connection with your external server."
|
||||||
echo "Wait while we install MySQL Client... installing!!!${end}"
|
echo "Wait while we install MySQL Client... installing!!!${end}"
|
||||||
|
@ -155,7 +165,7 @@ wpinstall() {
|
||||||
fi
|
fi
|
||||||
echo "${blu}"
|
echo "${blu}"
|
||||||
|
|
||||||
if [[ $wp == 1 || ($wp == 3 && ( -z $dburoot || -z $dbproot )) ]]; then
|
if [[ $wp == 1 || ($wp == [35] && ( -z $dburoot || -z $dbproot )) ]]; then
|
||||||
read -p "External DB root username [root]: " dburoot
|
read -p "External DB root username [root]: " dburoot
|
||||||
read -p "External DB root password: " dbproot
|
read -p "External DB root password: " dbproot
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -169,7 +179,7 @@ wpinstall() {
|
||||||
|
|
||||||
# ************* Ask for DB Name and validate data *************** #
|
# ************* Ask for DB Name and validate data *************** #
|
||||||
dom=$(dbword_check $dom)
|
dom=$(dbword_check $dom)
|
||||||
[[ $wp == [23] ]] || read -p "Database Name [$dom]:" dbname
|
[[ $wp == [2345] ]] || read -p "Database Name [$dom]:" dbname
|
||||||
dbname=${dbname:-$dom}
|
dbname=${dbname:-$dom}
|
||||||
|
|
||||||
# Check for duplicate database names, if already exists ask for another dbname to create the new db
|
# Check for duplicate database names, if already exists ask for another dbname to create the new db
|
||||||
|
@ -234,7 +244,7 @@ wpinstall() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ************* Ask for DB User and validate data *************** #
|
# ************* Ask for DB User and validate data *************** #
|
||||||
[[ $wp == [23] ]] || read -p "Database User [$dom]:" dbuser
|
[[ $wp == [2345] ]] || read -p "Database User [$dom]:" dbuser
|
||||||
dbuser=${dbuser:-$dom}
|
dbuser=${dbuser:-$dom}
|
||||||
|
|
||||||
# Check for duplicate database users, if already exists ask for another dbuser to create the new user
|
# Check for duplicate database users, if already exists ask for another dbuser to create the new user
|
||||||
|
@ -298,10 +308,10 @@ wpinstall() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $wp != [23] ]]; then
|
if [[ $wp != [2345] ]]; then
|
||||||
read -p "Database Password [$AUTOGENPASS_WPDB]:" dbpass
|
read -p "Database Password [$AUTOGENPASS_WPDB]:" dbpass
|
||||||
# Not ask for wp_prefix when wp=0 (mysql only site)
|
# Not ask for wp_prefix when wp=0 (mysql only site)
|
||||||
[[ $wp == 0 ]] || read -p "Database Prefix [wp_]:" dbpref
|
[[ $wp == [045] ]] || read -p "Database Prefix [wp_]:" dbpref
|
||||||
echo "${end}"
|
echo "${end}"
|
||||||
|
|
||||||
# If empty, assign defalut values
|
# If empty, assign defalut values
|
||||||
|
|
21
plugins/site
21
plugins/site
|
@ -31,7 +31,11 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# Extract value if exist
|
# Extract value if exist
|
||||||
if [[ $type == "-parked="* || $type == "-proxy="* || $type == "-wp="* || $type == "-wpsubdir="* || $type == "-wpsubdom="* || $type == "-ssl-off="* ]]; then
|
if [[ $domain == "-mysql="* ]]; then
|
||||||
|
value=$(echo "${domain}" | cut -d'=' -f 2 -s)
|
||||||
|
domain=$(echo "${domain}" | cut -d'=' -f 1 -s)
|
||||||
|
fi
|
||||||
|
if [[ $type == "-parked="* || $type == "-proxy="* || $type == "-wp="* || $type == "-wpsubdir="* || $type == "-wpsubdom="* || $type == "-ssl-off="* || $type == "-mysql="* ]]; then
|
||||||
value=$(echo "${type}" | cut -d'=' -f 2 -s)
|
value=$(echo "${type}" | cut -d'=' -f 2 -s)
|
||||||
type=$(echo "${type}" | cut -d'=' -f 1 -s)
|
type=$(echo "${type}" | cut -d'=' -f 1 -s)
|
||||||
fi
|
fi
|
||||||
|
@ -58,20 +62,23 @@ fi
|
||||||
[[ $cache == "-subdomain" && $value == "false" ]] && subdomflag="0"
|
[[ $cache == "-subdomain" && $value == "false" ]] && subdomflag="0"
|
||||||
|
|
||||||
|
|
||||||
# Evaluate if site to create is WP ( 0 = noWP, 1 = WP, 2 = WP with default values, 3 = WP with custom values )
|
# Evaluate if site to create is WP ( 0 = noWP, 1 = WP, 2 = WP with default values, 3 = WP with custom values, 4 = MySQL with default values, 3 = MySQL with custom values )
|
||||||
wp="0"
|
wp="0"
|
||||||
if [[ $type == "-wp" || $type == "-wpsubdir" || $type == "-wpsubdom" ]]; then
|
if [[ $type == "-wp" || $type == "-wpsubdir" || $type == "-wpsubdom" || $type == "-mysql" || $domain == "-mysql" ]]; then
|
||||||
wp="1"
|
[[ $type == "-mysql" || $domain == "-mysql" ]] || wp="1"
|
||||||
|
|
||||||
if [[ -n $value ]]; then
|
if [[ -n $value ]]; then
|
||||||
if [[ $value == "default" ]]; then
|
if [[ $value == "default" ]]; then
|
||||||
wp="2"
|
[[ $type == "-mysql" || $domain == "-mysql" ]] && wp="4" || wp="2"
|
||||||
else
|
else
|
||||||
# -wp=[setupmysql,setupwp,dbhost,dbname,dbuser,dbpass,dbpref,extdbuser,extdbpass]
|
# -wp=[setupmysql,setupwp,dbhost,dbname,dbuser,dbpass,dbpref,extdbuser,extdbpass]
|
||||||
custombegin=$(echo "${value}" | cut -c-1)
|
custombegin=$(echo "${value}" | cut -c-1)
|
||||||
customlast=$(echo "${value}" | rev | cut -c-1)
|
customlast=$(echo "${value}" | rev | cut -c-1)
|
||||||
wpdata=${value:1:-1}
|
wpdata=${value:1:-1}
|
||||||
|
|
||||||
|
# Because MySQL format not have this parameters at the beggining to match WP format. Insert it!
|
||||||
|
[[ $type == "-mysql" || $domain == "-mysql" ]] && wpdata=${wpdata/#/true,false,}
|
||||||
|
|
||||||
# Double coma is for lower case convertion
|
# Double coma is for lower case convertion
|
||||||
setmsqcustom=$(echo "${wpdata,,}" | cut -d',' -f 1 -s)
|
setmsqcustom=$(echo "${wpdata,,}" | cut -d',' -f 1 -s)
|
||||||
setpwpcustom=$(echo "${wpdata,,}" | cut -d',' -f 2 -s)
|
setpwpcustom=$(echo "${wpdata,,}" | cut -d',' -f 2 -s)
|
||||||
|
@ -84,8 +91,8 @@ if [[ $type == "-wp" || $type == "-wpsubdir" || $type == "-wpsubdom" ]]; then
|
||||||
exusercustom=$(echo "${wpdata}" | cut -d',' -f 8 -s)
|
exusercustom=$(echo "${wpdata}" | cut -d',' -f 8 -s)
|
||||||
expasscustom=$(echo "${wpdata}" | cut -d',' -f 9 -s)
|
expasscustom=$(echo "${wpdata}" | cut -d',' -f 9 -s)
|
||||||
|
|
||||||
if [[ $custombegin == "[" && $customlast == "]" && ((($setmsqcustom == "true" || $setpwpcustom == "true") && -n $dbhostcustom && -n $dbnamecustom && -n $dbusercustom && -n $dbpasscustom && -n $dbprefcustom) || ($setmsqcustom == "false" && $setpwpcustom == "false")) ]]; then
|
if [[ $custombegin == "[" && $customlast == "]" && ((($setmsqcustom == "true" || $setpwpcustom == "true") && -n $dbhostcustom && -n $dbnamecustom && -n $dbusercustom && -n $dbpasscustom && (-n $dbprefcustom || $type == "-mysql" || $domain == "-mysql")) || ($setmsqcustom == "false" && $setpwpcustom == "false")) ]]; then
|
||||||
wp="3"
|
[[ $type == "-mysql" || $domain == "-mysql" ]] && wp="5" || wp="3"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue