mirror of
https://github.com/10h30/wordpress-caddy-docker.git
synced 2026-06-05 15:09:52 +09:00
Update bash script
This commit is contained in:
+90
-55
@@ -6,67 +6,102 @@ WORDPRESS_PASSWORD=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_ADMIN_PASSWOR
|
|||||||
WORDPRESS_PLUGINS_TO_INSTALL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_PLUGINS_TO_INSTALL/{print}' .env)" | xargs)
|
WORDPRESS_PLUGINS_TO_INSTALL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_PLUGINS_TO_INSTALL/{print}' .env)" | xargs)
|
||||||
WORDPRESS_THEME_TO_INSTALL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_THEME_TO_INSTALL/{print}' .env)" | xargs)
|
WORDPRESS_THEME_TO_INSTALL=$(sed -e 's#.*=\(\)#\1#' <<< "$(awk '/WORDPRESS_THEME_TO_INSTALL/{print}' .env)" | xargs)
|
||||||
|
|
||||||
echo "== Installing WordPress =="
|
# Function to ask for yes/no confirmation
|
||||||
## Install Wodpress
|
ask_yes_no() {
|
||||||
docker compose run wpcli core install \
|
QUESTION=$1
|
||||||
--url=${SERVER_NAME} \
|
while true; do
|
||||||
--title="${WORDPRESS_TITLE}" \
|
# Customize your prompt message here
|
||||||
--admin_user=${WORDPRESS_USER} \
|
read -p "$QUESTION" answer
|
||||||
--admin_email=${WORDPRESS_EMAIL} \
|
# Default to Yes if no answer is given
|
||||||
--admin_password=${WORDPRESS_PASSWORD} \
|
if [[ -z "$answer" ]]; then
|
||||||
--skip-email
|
answer="Y"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "== Configure Permalinks =="
|
case $answer in
|
||||||
## Configure Permalinks
|
[Yy]* ) ANSWER=true; break;;
|
||||||
docker compose run wpcli rewrite structure '/%postname%/'
|
[Nn]* ) ANSWER=false;break;;
|
||||||
|
* ) echo "Please answer yes or no.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
echo "== Install Plugins =="
|
|
||||||
## Install Plugins
|
|
||||||
docker compose run wpcli plugin install ${WORDPRESS_PLUGINS_TO_INSTALL} --activate
|
|
||||||
|
|
||||||
## Enable Redis Cache Object
|
|
||||||
#docker compose run wpcli redis enable
|
|
||||||
|
|
||||||
## Enable and config Cache Enabler
|
if ! docker compose run wpcli core is-installed ; then
|
||||||
docker compose run wpcli option update cache_enabler '{
|
## Install Wodpress
|
||||||
"version": "1.8.0",
|
echo "== Installing WordPress =="
|
||||||
"use_trailing_slashes": 1,
|
docker compose run wpcli core install \
|
||||||
"permalink_structure": "has_trailing_slash",
|
--url=${SERVER_NAME} \
|
||||||
"cache_expires": 1,
|
--title="${WORDPRESS_TITLE}" \
|
||||||
"cache_expiry_time": 8,
|
--admin_user=${WORDPRESS_USER} \
|
||||||
"clear_site_cache_on_saved_post": 0,
|
--admin_email=${WORDPRESS_EMAIL} \
|
||||||
"clear_site_cache_on_saved_comment": 0,
|
--admin_password=${WORDPRESS_PASSWORD} \
|
||||||
"clear_site_cache_on_saved_term": 0,
|
--skip-email
|
||||||
"clear_site_cache_on_saved_user": 0,
|
|
||||||
"clear_site_cache_on_changed_plugin": 0,
|
|
||||||
"convert_image_urls_to_webp": 0,
|
|
||||||
"mobile_cache": 0,
|
|
||||||
"compress_cache": 1,
|
|
||||||
"minify_html": 1,
|
|
||||||
"minify_inline_css_js": 1,
|
|
||||||
"excluded_post_ids": "",
|
|
||||||
"excluded_page_paths": "",
|
|
||||||
"excluded_query_strings": "",
|
|
||||||
"excluded_cookies": ""
|
|
||||||
}' --format=json
|
|
||||||
|
|
||||||
echo "== Installing themes =="
|
## Configure Permalinks
|
||||||
# Theme installation
|
echo "== Configure Permalinks =="
|
||||||
docker compose run wpcli theme install "${WORDPRESS_THEME_TO_INSTALL}" --activate
|
docker compose run wpcli rewrite structure '/%postname%/'
|
||||||
|
|
||||||
echo -e "\nREPORT\n"
|
## Install Plugins
|
||||||
|
ask_yes_no "Do you want to install recommended plugins? [Y/n]"
|
||||||
|
DOIT=$ANSWER
|
||||||
|
if [ "$DOIT" = true ]; then
|
||||||
|
echo "== Install Plugins =="
|
||||||
|
|
||||||
|
docker compose run wpcli plugin install ${WORDPRESS_PLUGINS_TO_INSTALL} --activate
|
||||||
|
|
||||||
# List users
|
## Enable Redis Cache Object
|
||||||
echo "== User List =="
|
#docker compose run wpcli redis enable
|
||||||
docker compose run wpcli user list
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Show installed plugin
|
## Enable and config Cache Enabler
|
||||||
echo "== Theme List =="
|
docker compose run wpcli option update cache_enabler '{
|
||||||
docker compose run wpcli theme list
|
"version": "1.8.0",
|
||||||
echo ""
|
"use_trailing_slashes": 1,
|
||||||
|
"permalink_structure": "has_trailing_slash",
|
||||||
|
"cache_expires": 1,
|
||||||
|
"cache_expiry_time": 8,
|
||||||
|
"clear_site_cache_on_saved_post": 0,
|
||||||
|
"clear_site_cache_on_saved_comment": 0,
|
||||||
|
"clear_site_cache_on_saved_term": 0,
|
||||||
|
"clear_site_cache_on_saved_user": 0,
|
||||||
|
"clear_site_cache_on_changed_plugin": 0,
|
||||||
|
"convert_image_urls_to_webp": 0,
|
||||||
|
"mobile_cache": 0,
|
||||||
|
"compress_cache": 1,
|
||||||
|
"minify_html": 1,
|
||||||
|
"minify_inline_css_js": 1,
|
||||||
|
"excluded_post_ids": "",
|
||||||
|
"excluded_page_paths": "",
|
||||||
|
"excluded_query_strings": "",
|
||||||
|
"excluded_cookies": ""
|
||||||
|
}' --format=json
|
||||||
|
fi
|
||||||
|
|
||||||
# Show installed plugin
|
# Theme installation
|
||||||
echo "== Plugin List =="
|
ask_yes_no "Do you want to install recommended theme? [Y/n]"
|
||||||
docker compose run wpcli plugin list
|
DOIT=$ANSWER
|
||||||
echo ""
|
if [ "$DOIT" = true ]; then
|
||||||
|
echo "== Installing themes =="
|
||||||
|
docker compose run wpcli theme install "${WORDPRESS_THEME_TO_INSTALL}" --activate
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\nREPORT\n"
|
||||||
|
|
||||||
|
# List users
|
||||||
|
echo "== User List =="
|
||||||
|
docker compose run wpcli user list
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Show installed plugin
|
||||||
|
echo "== Theme List =="
|
||||||
|
docker compose run wpcli theme list
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Show installed plugin
|
||||||
|
echo "== Plugin List =="
|
||||||
|
docker compose run wpcli plugin list
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo "WordPress is already installed. Exiting now..."
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user