Browse Source

Created setup_wordpress function

old-stable
gau1991 11 years ago
parent
commit
2c5b6673bb
  1. 18
      bin/ee
  2. 2
      config/easyengine/ee.conf
  3. 65
      src/modules/site/create/ee_mod_setup_wordpress.sh

18
bin/ee

@ -954,21 +954,21 @@ MYSQLINFO()
EEWPDBPREFIX()
{
# Get The WordPress Database Table Prefix
WPDBPREFIX=$(grep wpdbprefix /etc/easyengine/ee.conf | awk '{print($3)}')
EE_WP_PREFIX=$(grep wpdbprefix /etc/easyengine/ee.conf | awk '{print($3)}')
# Display WPDBPREFIX Valid Characters Warning & Try Again
while [ $(echo $WPDBPREFIX | grep '[^[:alnum:] _]') ]
# Display EE_WP_PREFIX Valid Characters Warning & Try Again
while [ $(echo $EE_WP_PREFIX | grep '[^[:alnum:] _]') ]
do
ee_lib_echo_fail "Warning: \033[34mTable Prefix Can Only Contain Numbers, Letters, And Underscores."
# For Proper read Command Output
stty echo
read -p "Enter The MySQL Database Table Prefix [wp_]: " WPDBPREFIX
read -p "Enter The MySQL Database Table Prefix [wp_]: " EE_WP_PREFIX
done
# WordPress Database Table Prefix Default: wp_
if [[ $WPDBPREFIX = "" ]]
if [[ $EE_WP_PREFIX = "" ]]
then
WPDBPREFIX=wp_
EE_WP_PREFIX=wp_
fi
}
@ -1334,7 +1334,7 @@ ee_mod_domain_setup()
fi
}
EEWPSETUP()
ee_mod_setup_wordpress()
{
# Download Latest WordPress
ee_lib_echo "Downloading WordPress, Please Wait..."
@ -1371,7 +1371,7 @@ EEWPSETUP()
sed -i "s/localhost/$EE_MYSQL_HOST/" \
/var/www/$EE_DOMAIN/wp-config.php
sed -i "s/wp_/$WPDBPREFIX/" \
sed -i "s/wp_/$EE_WP_PREFIX/" \
/var/www/$EE_DOMAIN/wp-config.php
printf '%s\n' "g/put your unique phrase here/d" \
@ -1442,7 +1442,7 @@ SETUPEE_DOMAIN()
EEee_mod_domain_setup
# Setup WordPress Webroot & Database
EEWPSETUP
ee_mod_setup_wordpress
EEWPDBSETUP
}

2
config/easyengine/ee.conf

@ -15,7 +15,7 @@
db-user = false
[wordpress]
prefix = wp_
prefix = false
user = admin
password =
email =

65
src/modules/site/create/ee_mod_setup_wordpress.sh

@ -0,0 +1,65 @@
# Setup WordPress for $EE_DOMAIN
function ee_mod_setup_wordpress()
{
# Download latest WordPress
ee_lib_echo "Downloading WordPress, please wait..."
wget --no-check-certificate -cqO /var/www/$EE_DOMAIN/htdocs/latest.tar.gz \
http://wordpress.org/latest.tar.gz \
|| ee_lib_error "Unable to download WordPress, exit status = " $?
# Extracting WordPress
tar --strip-components=1 -zxf /var/www/$EE_DOMAIN/htdocs/latest.tar.gz \
-C /var/www/$EE_DOMAIN/htdocs/ \
|| ee_lib_error "Unable to extract WordPress, exit status = " $?
# Removing WordPress archive
rm /var/www/$EE_DOMAIN/htdocs/latest.tar.gz
# Default WordPress prefix or custom prefix
if [ $($EE_CONFIG_GET wordpress.prefix) == "true" ];then
read -p "Enter the MySQL database table prefix [wp_]: " EE_WP_PREFIX
# Display EE_WP_PREFIX valid characters warning & try again
while [[ ! ($EE_WP_PREFIX =~ ^[A-Za-z0-9_]*$) ]]; do
echo "Warning: table prefix can only contain numbers, letters, and underscores"
read -p "Enter the MySQL database table prefix [wp_]: " EE_WP_PREFIX
done
fi
# If wordpress.prefix = false
# Then it never ask for WordPress prefix in this case $EE_WP_PREFIX is empty
# If wordpress.prefix = true
# User enter custom WordPress prefix then $EE_WP_PREFIX is not empty & we used provided WordPress prefix
# If user pressed enter then $EE_WP_PREFIX is empty
# WordPress database table prefix default: wp_
if [[ $EE_WP_PREFIX = "" ]];then
EE_WP_PREFIX=wp_
fi
# Database setup
ee_mod_setup_database
# Modify wp-config.php & move outside the webroot
cp /var/www/$EE_DOMAIN/htdocs/wp-config-sample.php \
/var/www/$EE_DOMAIN/wp-config.php
sed -i "s/database_name_here/$EE_DB_NAME/" \
/var/www/$EE_DOMAIN/wp-config.php
sed -i "s/username_here/$EE_DB_USER/" \
/var/www/$EE_DOMAIN/wp-config.php
sed -i "s/password_here/$EE_DB_PASS/" \
/var/www/$EE_DOMAIN/wp-config.php
sed -i "s/localhost/$EE_MYSQL_HOST/" \
/var/www/$EE_DOMAIN/wp-config.php
sed -i "s/wp_/$EE_WP_PREFIX/" \
/var/www/$EE_DOMAIN/wp-config.php
printf '%s\n' "g/put your unique phrase here/d" \
a "$(curl -sL https://api.wordpress.org/secret-key/1.1/salt/)" . w \
| ed -s /var/www/$EE_DOMAIN/wp-config.php
}
Loading…
Cancel
Save