dev-scripts/dev-production-universal/scripts/debian10/install-wordpress.sh

115 lines
2.8 KiB
Bash
Executable File

echo "Installing WordPress .."
# 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
# 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
EOSSH
ssh -T $ssh_user << EOSSH
if wp core is-installed --quiet --path="$wp_path" ; then
echo "WordPress already installed"
else
echo "wp core download \
--version=$wp_version \
--path=$wp_path \
--skip-content \
--locale=$wp_locale"
wp core download \
--version="$wp_version" \
--path="$wp_path" \
--skip-content \
--locale="$wp_locale"
wp config create \
--path="$wp_path" \
--dbname="$db_name" \
--dbuser="$db_user" \
--dbpass="$db_pass" \
--locale="$wp_locale" \
--extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
wp core install \
--path="$wp_path" \
--url="$domain" \
--title="$wp_title" \
--admin_user="$wp_user" \
--admin_password="$wp_pass" \
--admin_email="$wp_email"
fi
EOSSH
if [ -n "$wp_themes" ] ; then
printf "\nInstalling themes ..."
option='--activate'
for theme in $wp_themes ; do
echo " installing $theme ..."
ssh -T $ssh_user << EOSSH
wp theme install $theme "$option" --path="$wp_path"
EOSSH
option=''
done
fi
if [ -n "$wp_plugins" ] ; then
printf "\nInstalling plugins ..."
for plugin in $wp_plugins ; do
echo " installing $plugin ..."
ssh -T $ssh_user << EOSSH
wp plugin install $plugin --path="$wp_path"
EOSSH
done
fi
if [ -n "$wp_plugins_active" ] ; then
printf "\nInstalling plugins to activate ..."
for plugin in $wp_plugins_active ; do
echo " installing $plugin ..."
ssh -T $ssh_user << EOSSH
wp plugin install $plugin --activate --path="$wp_path"
EOSSH
done
fi
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>
EOF
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
EOSSH
fi