From 336473af573e11473e8633e2ecd03e3b46d43752 Mon Sep 17 00:00:00 2001 From: Thuan Bui Date: Thu, 30 Jan 2025 15:34:30 +0900 Subject: [PATCH] disable log function --- kazewp.sh | 2 +- lib/log.sh | 18 +++++++++++++++--- templates/wp-setup.sh.template | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/kazewp.sh b/kazewp.sh index 15508a6..e905315 100755 --- a/kazewp.sh +++ b/kazewp.sh @@ -12,7 +12,7 @@ source "${SCRIPT_DIR}/lib/docker.sh" source "${SCRIPT_DIR}/lib/caddy.sh" source "${SCRIPT_DIR}/lib/wordpress.sh" source "${SCRIPT_DIR}/lib/menu.sh" -source "${SCRIPT_DIR}/lib/log.sh" +#source "${SCRIPT_DIR}/lib/log.sh" # Check if Docker is installed diff --git a/lib/log.sh b/lib/log.sh index da5bf20..586456c 100644 --- a/lib/log.sh +++ b/lib/log.sh @@ -13,11 +13,23 @@ if [ ! -w "$LOG_FILE" ]; then exit 1 fi +# Function to add timestamp to log file +add_timestamp() { + echo -e "\n========== $(date '+%Y-%m-%d %H:%M:%S') ==========" >> "$LOG_FILE" +} + # Function to strip ANSI color codes strip_colors() { sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" } -# Redirect all output to both the terminal and the log file (without colors) -exec > >(tee -a >(strip_colors >> "$LOG_FILE")) -exec 2> >(tee -a >(strip_colors >> "$LOG_FILE") >&2) \ No newline at end of file +# Save original file descriptors +exec 3>&1 +exec 4>&2 + +# Add timestamp to log file +add_timestamp + +# Redirect stdout and stderr to log file (without color codes) and also to the terminal (with colors) +exec 1> >(tee >(strip_colors >> "$LOG_FILE") >&3) +exec 2> >(tee >(strip_colors >> "$LOG_FILE") >&4) \ No newline at end of file diff --git a/templates/wp-setup.sh.template b/templates/wp-setup.sh.template index 8edaded..06e7d2b 100644 --- a/templates/wp-setup.sh.template +++ b/templates/wp-setup.sh.template @@ -20,7 +20,7 @@ if ! wpcli core is-installed ; then --admin_password="${ADMIN_PASSWORD}" \ --admin_email="${ADMIN_EMAIL}" \ --skip-email - + wpcli rewrite structure '/%postname%/' echo "Installing and activating plugins..." wpcli plugin install wordfence cache-enabler --activate wpcli option update cache_enabler '{ @@ -50,19 +50,19 @@ if ! wpcli core is-installed ; then wpcli theme update --all # List users - echo "== User List ==" - wpcli user list - echo "" + #echo "== User List ==" + #wpcli user list + #echo "" # Show installed plugin - echo "== Theme List ==" - wpcli theme list - echo "" + #echo "== Theme List ==" + #wpcli theme list + #echo "" # Show installed plugin - echo "== Plugin List ==" - wpcli plugin list - echo "" + #echo "== Plugin List ==" + #wpcli plugin list + #echo "" echo "WordPress setup completed!" else