#!/bin/bash # Check if WP-CLI is available if [ ! -f "/home/litespeed/bin/wp" ]; then echo "WP-CLI not found" exit 1 fi # Function to run WP-CLI commands run_wp_command() { /home/litespeed/bin/wp --path=/var/www/webroot/ROOT "$@" } # Check for correct number of arguments if [ "$#" -ne 4 ]; then echo "Usage: $0 TTL_PUB TTL_PRIV TTL_FRONTPAGE TTL_FEED" exit 1 fi # Assigning input parameters to variables TTL_PUB=$1 TTL_PRIV=$2 TTL_FRONTPAGE=$3 TTL_FEED=$4 # Update TTL values run_wp_command litespeed-option set cache-ttl_pub "$TTL_PUB" run_wp_command litespeed-option set cache-ttl_priv "$TTL_PRIV" run_wp_command litespeed-option set cache-ttl_frontpage "$TTL_FRONTPAGE" run_wp_command litespeed-option set cache-ttl_feed "$TTL_FEED" # Purge cache run_wp_command litespeed-purge all echo "LiteSpeed cache settings updated successfully"