Unattended WP Custom Install
Unattended WP installation with custom data.
This commit is contained in:
parent
4b606e1445
commit
a34e086951
45
lib/sites
45
lib/sites
|
@ -30,6 +30,20 @@ wpinstall() {
|
|||
local dbpass=$AUTOGENPASS_WPDB
|
||||
local dbpref="wp_"
|
||||
|
||||
# WP with Custom Data
|
||||
if [[ $wp == 3 ]]; then
|
||||
[[ $setmsqcustom == "false" ]] && setupmysql="n"
|
||||
[[ $setpwpcustom == "false" ]] && setupwp="n"
|
||||
|
||||
dbhost="$dbhostcustom"
|
||||
dbname="$dbnamecustom"
|
||||
dbuser="$dbusercustom"
|
||||
dbpass="$dbpasscustom"
|
||||
dbpref="$dbprefcustom"
|
||||
dburoot="$exusercustom"
|
||||
dbproot="$expasscustom"
|
||||
fi
|
||||
|
||||
echo "${blu}"
|
||||
if [[ $wp == 1 ]]; then
|
||||
echo "Do you need to setup new MySQL database? [Y/n]"
|
||||
|
@ -48,7 +62,7 @@ wpinstall() {
|
|||
[[ $wp == 0 ]] && setupwp="n"
|
||||
|
||||
# Download WP (latest version)
|
||||
if [[ $wp == [12] ]]; then
|
||||
if [[ $wp == [123] ]]; then
|
||||
sudo wget --timeout=15 -qrO /var/www/$domain/htdocs/wp.tar.gz https://wordpress.org/latest.tar.gz
|
||||
sudo tar -xf /var/www/$domain/htdocs/wp.tar.gz -C /var/www/$domain/htdocs/
|
||||
sudo mv /var/www/$domain/htdocs/wordpress/* /var/www/$domain/htdocs/
|
||||
|
@ -65,7 +79,7 @@ wpinstall() {
|
|||
done="1"
|
||||
# Ask DB data or suggest default values
|
||||
echo ""
|
||||
[[ $wp == [2] ]] || read -p "Database Host [localhost]:" dbhost
|
||||
[[ $wp == [23] ]] || read -p "Database Host [localhost]:" dbhost
|
||||
dbhost=${dbhost:-localhost}
|
||||
|
||||
if [[ $dbhost == "localhost" && ( "$setupmysql" == y || "$setupmysql" == Y ) && $(conf_read mysql) != "true" ]]; then
|
||||
|
@ -82,17 +96,20 @@ wpinstall() {
|
|||
echo "${gre}MySQL Client has been successfully installed!${end}"
|
||||
fi
|
||||
echo "${blu}"
|
||||
read -p "External DB root username [root]: " dburoot
|
||||
read -p "External DB root password: " dbproot
|
||||
echo ""
|
||||
local dburoot=${dburoot:-root}
|
||||
local dbproot=${dbproot:-nodefined}
|
||||
|
||||
|
||||
if [[ $wp == 1 || ($wp == 3 && ( -z $dburoot || -z $dbproot )) ]]; then
|
||||
read -p "External DB root username [root]: " dburoot
|
||||
read -p "External DB root password: " dbproot
|
||||
echo ""
|
||||
local dburoot=${dburoot:-root}
|
||||
local dbproot=${dbproot:-nodefined}
|
||||
fi
|
||||
|
||||
local dburl=$(echo "$dbhost" | cut -f 1 -d ':')
|
||||
local dbport=$(echo "$dbhost" | cut -f 2 -d ':')
|
||||
fi
|
||||
|
||||
[[ $wp == [2] ]] || read -p "Database Name [$dom]:" dbname
|
||||
[[ $wp == [23] ]] || read -p "Database Name [$dom]:" dbname
|
||||
dbname=${dbname:-$dom}
|
||||
|
||||
# Check for duplicate database names, if already exists ask for another dbname to create the new db
|
||||
|
@ -146,7 +163,7 @@ wpinstall() {
|
|||
fi
|
||||
done
|
||||
fi
|
||||
if [[ $wp != [2] ]]; then
|
||||
if [[ $wp != [23] ]]; then
|
||||
read -p "Database User [$dom]:" dbuser
|
||||
read -p "Database Password [$AUTOGENPASS_WPDB]:" dbpass
|
||||
# Not ask for wp_prefix when wp=0 (mysql only site)
|
||||
|
@ -276,7 +293,7 @@ deletesite() {
|
|||
|
||||
|
||||
createsite() {
|
||||
if [[ "$wp" == [12] && $(conf_read php) != "true" ]]; then
|
||||
if [[ "$wp" == [123] && $(conf_read php) != "true" ]]; then
|
||||
echo "${red}"
|
||||
echo " [ERROR] PHP must be installed before you can create a WP site!"
|
||||
echo "${end}"
|
||||
|
@ -307,7 +324,7 @@ createsite() {
|
|||
# Create data folder for new site
|
||||
if [[ ! -d /var/www/$domain/htdocs || ! -d /var/www/$domain ]]; then
|
||||
sudo mkdir -p /var/www/$domain/htdocs
|
||||
if [[ "$wp" == [12] ]]; then
|
||||
if [[ "$wp" == [123] ]]; then
|
||||
wpinstall
|
||||
fi
|
||||
else
|
||||
|
@ -324,7 +341,7 @@ createsite() {
|
|||
if [[ $wwwexist == n || $wwwexist == N ]]; then
|
||||
sudo rm -rf /var/www/$domain/htdocs
|
||||
sudo mkdir -p /var/www/$domain/htdocs
|
||||
if [[ "$wp" == [12] ]]; then
|
||||
if [[ "$wp" == [123] ]]; then
|
||||
wpinstall
|
||||
fi
|
||||
fi
|
||||
|
@ -336,7 +353,7 @@ createsite() {
|
|||
fi
|
||||
|
||||
# Activate FastCgi cache
|
||||
if [[ "$cache" == "-cache" && "$wp" == [12] ]]; then
|
||||
if [[ "$cache" == "-cache" && "$wp" == [123] ]]; then
|
||||
sudo sed -i '/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
|
||||
nginx_helper_plugin
|
||||
fi
|
||||
|
|
24
plugins/site
24
plugins/site
|
@ -30,7 +30,7 @@ if [[ "$type" == "-cache" && -n $cache ]]; then
|
|||
cache="$2"
|
||||
fi
|
||||
|
||||
wp="0" # Evaluate if site to create is WP
|
||||
wp="0" # Evaluate if site to create is WP ( 0 = noWP, 1 = WP, 2 = WP with default values, 3 = WP with custom values )
|
||||
if [[ "$type" == "-wp" || "$type" == "-wpsubdir" || "$type" == "-wpsubdom" ]]; then
|
||||
wp="1"
|
||||
fi
|
||||
|
@ -39,6 +39,28 @@ if [[ "$type" == "-wp="* || "$type" == "-wpsubdir="* || "$type" == "-wpsubdom="*
|
|||
if [[ $wpunat == "default" ]]; then
|
||||
wp="2"
|
||||
type=$(echo "${type}" | cut -d'=' -f 1 -s)
|
||||
else
|
||||
# -wp=[setupmysql,setupwp,dbhost,dbname,dbuser,dbpass,dbpref,extdbuser,extdbpass]
|
||||
custombegin=$(echo "${wpunat}" | cut -c-1)
|
||||
customlast=$(echo "${wpunat}" | rev | cut -c-1)
|
||||
wpdata=${wpunat:1:-1}
|
||||
|
||||
# Double coma is for lower case convertion
|
||||
setmsqcustom=$(echo "${wpdata,,}" | cut -d',' -f 1 -s)
|
||||
setpwpcustom=$(echo "${wpdata,,}" | cut -d',' -f 2 -s)
|
||||
|
||||
dbhostcustom=$(echo "${wpdata}" | cut -d',' -f 3 -s)
|
||||
dbnamecustom=$(echo "${wpdata}" | cut -d',' -f 4 -s)
|
||||
dbusercustom=$(echo "${wpdata}" | cut -d',' -f 5 -s)
|
||||
dbpasscustom=$(echo "${wpdata}" | cut -d',' -f 6 -s)
|
||||
dbprefcustom=$(echo "${wpdata}" | cut -d',' -f 7 -s)
|
||||
exusercustom=$(echo "${wpdata}" | cut -d',' -f 8 -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
|
||||
wp="3"
|
||||
type=$(echo "${type}" | cut -d'=' -f 1 -s)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue