From 4f19a98a3b417c8f451efba856ae233a3347c1ba Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 9 Jun 2020 22:10:52 +0100 Subject: [PATCH] update --- config-example | 9 ++++--- run.sh | 10 ++++--- wp-duplicate.sh | 2 -- wp-install.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 9 deletions(-) diff --git a/config-example b/config-example index 3e1517b..c412026 100755 --- a/config-example +++ b/config-example @@ -1,8 +1,5 @@ #!/bin/sh -export local_url='' -export remote_url='' - export username='' export webuser='' export db_root_pass='' @@ -13,6 +10,12 @@ export wp_path='' export wp_user='' export wp_pass='' +# list of themes to install - first one will be activate +export wp_themes="" +export wp_plugins="" +export wp_plugins_active="" +export wp_plugins_uninstall="" + export php_version='' # set one of diff --git a/run.sh b/run.sh index c7120f4..763ba3e 100755 --- a/run.sh +++ b/run.sh @@ -3,13 +3,15 @@ . ./config-urls if [ "$1" = 'local' ] ; then - ( export local_url="$local_url"; \ - export remote_url="$remote_url"; \ + ( + echo "export local_url=\"$local_ur\""; \ + echo "export remote_url=\"$remote_url\""; \ cat config "$2" \ ) | ssh root@"$local_url" -T /bin/sh elif [ "$1" = 'remote' ] ; then - ( export local_url="$remote_url"; \ - export remote_url="$local_url"; \ + ( + echo "export local_url=\"$remote_url\""; \ + echo "export remote_url=\"$local_url\""; \ cat config "$2" \ ) | ssh root@"$remote_url" -T /bin/sh else diff --git a/wp-duplicate.sh b/wp-duplicate.sh index 829303e..1a24852 100755 --- a/wp-duplicate.sh +++ b/wp-duplicate.sh @@ -1,3 +1 @@ #!/bin/sh - - diff --git a/wp-install.sh b/wp-install.sh index 829303e..76be19a 100755 --- a/wp-install.sh +++ b/wp-install.sh @@ -1,3 +1,73 @@ #!/bin/sh +if [ -n "$php_version" ] ; then + echo "TODO - install specific PHP version" + exit 1 +elif ! php ; then + apt install -y php-fpm php-bcmath php-curl php-gd php-imagick php-mbstring \ + php-mysql php-soap php-xml php-zip +fi +php_config_file=$(php --ini | grep Loaded | awk '{ print $4 }') +sed -i '/memory_limit/c\memory_limit = 256M' "$php_config_file" +sed -i '/upload_max_filesize/c\upload_max_filesize = 64M' "$php_config_file" +sed -i '/post_max_size/c\post_max_size = 64M' "$php_config_file" +sed -i '/max_execution_time/c\max_execution_time = 300M' "$php_config_file" +sed -i '/max_input_time/c\max_input_time = 1000' "$php_config_file" +# 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 + +if wp core is-installed --quiet --path="$wp_path" --allow-root ; then + echo "WordPress already installed" +else + echo "TODO - install WordPress" +fi + +# check if wordpress already installed in $wp_path +# if not then install + +if [ -n "$wp_themes" ] ; then +printf "\nInstalling themes ..." + option='--activate' + for theme in $wp_themes ; do + echo " installing $theme ..." + wp theme install $theme "$option" --path="$wp_path" --allow-root + option='' + done +fi + +if [ -n "$wp_plugins" ] ; then +printf "\nInstalling plugins ..." + for plugin in $wp_plugins ; do + echo " installing $plugin ..." + wp plugin install $plugin --path="$wp_path" --allow-root + done +fi + +if [ -n "$wp_plugins_active" ] ; then +printf "\nInstalling plugins to activate ..." + for plugin in $wp_plugins_active ; do + echo " installing $plugin ..." + wp plugin install $plugin --activate --path="$wp_path" --allow-root + done +fi + +if [ -n "$wp_plugins_active" ] ; then +printf "\nUninstalling plugins ..." + for plugin in $wp_plugins_uninstall ; do + echo " installing $plugin ..." + wp plugin deactivate $plugin --path="$wp_path" --allow-root + wp plugin uninstall $plugin --path="$wp_path" --allow-root + done +fi + +# TODO determine web user programatically +ownergroup='www-data:www-data' +if [ -n "$litespeed_version" ] ; then + ownergroup='nobody:nogroup' +fi + +chown -R "$ownergroup" "$wp_path"