1616# You should have received a copy of the GNU General Public License
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19+ # SCRIPT DESCRIPTION:
20+ # This script manages Nginx FastCGI cache operations for WordPress websites running on Nginx.
21+ # This script is written for "FastCGI Cache Purge and Preload for Nginx" Wordpress Plugin.
22+ # It automates cache purging and preload tasks by monitoring changes in FastCGI cache
23+ # directories using inotifywait. Additionally, it sets up ACL permissions for PHP-FPM users,
24+ # ensuring they have necessary access for cache operations. The script also integrates with
25+ # systemd to manage a background service for continuous cache management.
26+
27+ # Manual setup instructions
1928manual_setup () {
2029 echo -e " \n\e[91mCanceled:\e[0m Automated Setup has been canceled by the user. Proceeding to manual setup."
2130 # Provide instructions for manual configuration
@@ -26,7 +35,7 @@ manual_setup() {
2635 exit 1
2736}
2837
29- # user confirmation and handle ctrl+c
38+ # Handle ctrl+c
3039trap manual_setup SIGINT
3140
3241# Get help before and interrupt
@@ -39,8 +48,8 @@ help() {
3948
4049 echo -e " \n${m_tab}${cyan} # Wordpress FastCGI Cache Purge&Preload Help"
4150 echo -e " ${m_tab} # ---------------------------------------------------------------------------------------------------"
42- echo -e " ${m_tab} #${m_tab} --wp-inotify-start need root or SUDO! set ACL permission (cache folder) for website-user "
43- echo -e " ${m_tab} #${m_tab} --wp-inotify-stop need root or SUDO! unset ACL permission (cache folder) for website-user "
51+ echo -e " ${m_tab} #${m_tab} --wp-inotify-start need root! start listening events (cache folder), set ACL permission(PHP-FPM USER) "
52+ echo -e " ${m_tab} #${m_tab} --wp-inotify-stop need root! stop listening events (cache folder), unset ACL permission(PHP-FPM USER) "
4453 echo -e " ${m_tab} # ---------------------------------------------------------------------------------------------------${reset} \n"
4554}
4655
@@ -77,12 +86,12 @@ if ! tune2fs -l "${fs}" | grep -q "Default mount options:.*acl"; then
7786 exit 1
7887fi
7988
80- # discover script path
89+ # Discover script path
8190this_script_full_path=$( realpath " ${BASH_SOURCE[0]} " )
8291this_script_path=$( dirname " ${this_script_full_path} " )
8392this_script_name=$( basename " ${this_script_full_path} " )
8493
85- # ensure script path is resolved
94+ # Ensure script path is resolved
8695if [[ -z " ${this_script_path} " ]]; then
8796 echo " ERROR: Cannot find script path!"
8897 exit 1
@@ -214,13 +223,15 @@ NGINX_
214223
215224 # Check if the service started successfully
216225 if systemctl is-active --quiet npp-wordpress.service; then
217- echo -e " \e[92mSuccess:\e[0m Service \e[93mnpp-wordpress\e[0m is started."
226+ echo -e " \e[92mSuccess:\e[0m Systemd service \e[93mnpp-wordpress\e[0m is started."
227+ echo " "
228+ echo " $( systemctl status npp-wordpress.service | grep -E ' Started|All done!' | sed ' s/.*: //' ) "
218229 else
219- echo -e " \e[91mError:\e[0m Service \e[93mnpp-wordpress\e[0m failed to start."
230+ echo -e " \e[91mError:\e[0m Systemd service \e[93mnpp-wordpress\e[0m failed to start."
220231 fi
221232 else
222233 systemctl stop npp-wordpress.service
223- systemctl start npp-wordpress.service && echo -e " \e[92mSuccess:\e[0m Service \e[93mnpp-wordpress\e[0m is re-started."
234+ systemctl start npp-wordpress.service && echo -e " \e[92mSuccess:\e[0m Systemd service \e[93mnpp-wordpress\e[0m is re-started."
224235 fi
225236}
226237
0 commit comments