Update bash script

This commit is contained in:
2024-03-20 09:22:17 +07:00
parent 47b616df4c
commit 725b25aa38
+39 -4
View File
@@ -6,8 +6,30 @@ 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_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
ask_yes_no() {
QUESTION=$1
while true; do
# Customize your prompt message here
read -p "$QUESTION" answer
# Default to Yes if no answer is given
if [[ -z "$answer" ]]; then
answer="Y"
fi
case $answer in
[Yy]* ) ANSWER=true; break;;
[Nn]* ) ANSWER=false;break;;
* ) echo "Please answer yes or no.";;
esac
done
}
if ! docker compose run wpcli core is-installed ; then
## Install Wodpress
echo "== Installing WordPress =="
docker compose run wpcli core install \
--url=${SERVER_NAME} \
--title="${WORDPRESS_TITLE}" \
@@ -16,12 +38,16 @@ docker compose run wpcli core install \
--admin_password=${WORDPRESS_PASSWORD} \
--skip-email
echo "== Configure Permalinks =="
## Configure Permalinks
echo "== Configure Permalinks =="
docker compose run wpcli rewrite structure '/%postname%/'
echo "== Install Plugins =="
## 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
## Enable Redis Cache Object
@@ -49,10 +75,16 @@ docker compose run wpcli option update cache_enabler '{
"excluded_query_strings": "",
"excluded_cookies": ""
}' --format=json
fi
echo "== Installing themes =="
# Theme installation
ask_yes_no "Do you want to install recommended theme? [Y/n]"
DOIT=$ANSWER
if [ "$DOIT" = true ]; then
echo "== Installing themes =="
docker compose run wpcli theme install "${WORDPRESS_THEME_TO_INSTALL}" --activate
fi
echo -e "\nREPORT\n"
@@ -70,3 +102,6 @@ echo ""
echo "== Plugin List =="
docker compose run wpcli plugin list
echo ""
else
echo "WordPress is already installed. Exiting now..."
fi