16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
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
19
28
manual_setup () {
20
29
echo -e " \n\e[91mCanceled:\e[0m Automated Setup has been canceled by the user. Proceeding to manual setup."
21
30
# Provide instructions for manual configuration
@@ -26,7 +35,7 @@ manual_setup() {
26
35
exit 1
27
36
}
28
37
29
- # user confirmation and handle ctrl+c
38
+ # Handle ctrl+c
30
39
trap manual_setup SIGINT
31
40
32
41
# Get help before and interrupt
@@ -39,8 +48,8 @@ help() {
39
48
40
49
echo -e " \n${m_tab}${cyan} # Wordpress FastCGI Cache Purge&Preload Help"
41
50
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) "
44
53
echo -e " ${m_tab} # ---------------------------------------------------------------------------------------------------${reset} \n"
45
54
}
46
55
@@ -77,12 +86,12 @@ if ! tune2fs -l "${fs}" | grep -q "Default mount options:.*acl"; then
77
86
exit 1
78
87
fi
79
88
80
- # discover script path
89
+ # Discover script path
81
90
this_script_full_path=$( realpath " ${BASH_SOURCE[0]} " )
82
91
this_script_path=$( dirname " ${this_script_full_path} " )
83
92
this_script_name=$( basename " ${this_script_full_path} " )
84
93
85
- # ensure script path is resolved
94
+ # Ensure script path is resolved
86
95
if [[ -z " ${this_script_path} " ]]; then
87
96
echo " ERROR: Cannot find script path!"
88
97
exit 1
@@ -214,13 +223,15 @@ NGINX_
214
223
215
224
# Check if the service started successfully
216
225
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/.*: //' ) "
218
229
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."
220
231
fi
221
232
else
222
233
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."
224
235
fi
225
236
}
226
237
0 commit comments