2020-09-03 22:06:42 +00:00
|
|
|
echo "Installing WordPress .."
|
|
|
|
|
2020-09-08 17:59:02 +00:00
|
|
|
# check we have ssh access
|
|
|
|
[ -z "$ssh_user" ] || [ -z "$ssh_root" ] && echo "Error: user and root ssh configuration must be specified" && exit 5
|
|
|
|
|
|
|
|
ssh -T $ssh_root << EOSSH
|
2020-09-08 19:33:56 +00:00
|
|
|
# install wp-cli first
|
|
|
|
if [ ! -f /usr/local/bin/wp ] ; then
|
|
|
|
wget -nv -O /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
|
|
|
|
&& chmod +x /usr/local/bin/wp
|
|
|
|
fi
|
2020-09-08 17:59:02 +00:00
|
|
|
EOSSH
|
2020-09-03 22:06:42 +00:00
|
|
|
|
2020-09-08 17:59:02 +00:00
|
|
|
ssh -T $ssh_user << EOSSH
|
2020-09-03 22:06:42 +00:00
|
|
|
if wp core is-installed --quiet --path="$wp_path" ; then
|
|
|
|
echo "WordPress already installed"
|
|
|
|
else
|
2020-09-08 19:33:56 +00:00
|
|
|
echo "wp core download \
|
|
|
|
--version=$wp_version \
|
|
|
|
--path=$wp_path \
|
|
|
|
--skip-content \
|
|
|
|
--locale=$wp_locale"
|
2020-09-03 22:06:42 +00:00
|
|
|
wp core download \
|
|
|
|
--version="$wp_version" \
|
|
|
|
--path="$wp_path" \
|
|
|
|
--skip-content \
|
|
|
|
--locale="$wp_locale"
|
|
|
|
wp config create \
|
|
|
|
--path="$wp_path" \
|
2020-09-08 17:24:06 +00:00
|
|
|
--dbname="$db_name" \
|
|
|
|
--dbuser="$db_user" \
|
|
|
|
--dbpass="$db_pass" \
|
2020-09-03 22:06:42 +00:00
|
|
|
--locale="$wp_locale" \
|
|
|
|
--extra-php <<PHP
|
|
|
|
define( 'WP_DEBUG', true );
|
|
|
|
define( 'WP_DEBUG_LOG', true );
|
|
|
|
PHP
|
|
|
|
wp core install \
|
|
|
|
--path="$wp_path" \
|
2020-09-04 12:34:57 +00:00
|
|
|
--url="$domain" \
|
2020-09-03 22:06:42 +00:00
|
|
|
--title="$wp_title" \
|
|
|
|
--admin_user="$wp_user" \
|
|
|
|
--admin_password="$wp_pass" \
|
|
|
|
--admin_email="$wp_email"
|
|
|
|
fi
|
2020-09-04 13:23:11 +00:00
|
|
|
EOSSH
|
2020-09-03 22:06:42 +00:00
|
|
|
|
|
|
|
if [ -n "$wp_themes" ] ; then
|
|
|
|
printf "\nInstalling themes ..."
|
|
|
|
option='--activate'
|
|
|
|
for theme in $wp_themes ; do
|
|
|
|
echo " installing $theme ..."
|
2020-09-08 17:59:02 +00:00
|
|
|
ssh -T $ssh_user << EOSSH
|
2020-09-04 12:34:57 +00:00
|
|
|
wp theme install $theme "$option" --path="$wp_path"
|
2020-09-04 13:23:11 +00:00
|
|
|
EOSSH
|
2020-09-03 22:06:42 +00:00
|
|
|
option=''
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$wp_plugins" ] ; then
|
|
|
|
printf "\nInstalling plugins ..."
|
|
|
|
for plugin in $wp_plugins ; do
|
|
|
|
echo " installing $plugin ..."
|
2020-09-08 17:59:02 +00:00
|
|
|
ssh -T $ssh_user << EOSSH
|
2020-09-04 12:34:57 +00:00
|
|
|
wp plugin install $plugin --path="$wp_path"
|
2020-09-04 13:23:11 +00:00
|
|
|
EOSSH
|
2020-09-03 22:06:42 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$wp_plugins_active" ] ; then
|
|
|
|
printf "\nInstalling plugins to activate ..."
|
|
|
|
for plugin in $wp_plugins_active ; do
|
|
|
|
echo " installing $plugin ..."
|
2020-09-08 17:59:02 +00:00
|
|
|
ssh -T $ssh_user << EOSSH
|
2020-09-04 12:34:57 +00:00
|
|
|
wp plugin install $plugin --activate --path="$wp_path"
|
2020-09-04 13:23:11 +00:00
|
|
|
EOSSH
|
2020-09-03 22:06:42 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2020-09-08 19:33:56 +00:00
|
|
|
if [ -n "$_apache2_version" ] ; then
|
|
|
|
ssh -T $ssh_root << EOSSH
|
|
|
|
if [ -n "$apache2_version" ] ; then
|
|
|
|
mkdir -p /var/log/wordpress/
|
|
|
|
cat << EOF > /etc/apache2/sites-available/wordpress.conf
|
|
|
|
<VirtualHost *:80>
|
|
|
|
ServerName $domain
|
|
|
|
DocumentRoot $wp_path
|
|
|
|
ErrorLog /var/log/wordpress/error.log
|
|
|
|
CustomLog /var/log/wordpress/access.log combined
|
|
|
|
<Directory $wp_path/>
|
|
|
|
AllowOverride All
|
|
|
|
<IfModule mod_rewrite.c>
|
|
|
|
RewriteEngine On
|
|
|
|
RewriteBase /
|
|
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
|
|
|
RewriteRule . /index.php [L]
|
|
|
|
</IfModule>
|
|
|
|
</Directory>
|
|
|
|
</VirtualHost>
|
2020-09-03 22:06:42 +00:00
|
|
|
EOF
|
2020-09-08 19:33:56 +00:00
|
|
|
a2enmod rewrite
|
|
|
|
a2ensite wordpress
|
|
|
|
a2dissite 000-default
|
|
|
|
systemctl reload apache2
|
|
|
|
elif [ -n "nginx_version" ] ; then
|
|
|
|
echo "TODO - nginx wordpress config"
|
|
|
|
elif [ -n "litespeed_version" ] ; then
|
|
|
|
echo "TODO - litespeed wordpress config"
|
|
|
|
else
|
|
|
|
echo "Warning: no webserver configuration found"
|
|
|
|
fi
|
2020-09-03 22:06:42 +00:00
|
|
|
EOSSH
|
2020-09-08 19:33:56 +00:00
|
|
|
fi
|