|
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 | +manual_setup() { |
| 20 | + echo -e "\n\e[91mCanceled:\e[0m Automated Setup has been canceled by the user. Proceeding to manual setup." |
| 21 | + # Provide instructions for manual configuration |
| 22 | + echo -e "\e[36mTo set up manual configuration, create a file named \e[95m'manual-configs.nginx' \e[0m \e[36min the same directory as this script." |
| 23 | + echo -e "Each entry should follow the format: 'PHP-FPM_user FastCGI_cache_path', with one entry per virtual host." |
| 24 | + echo -e "Ensure that every new website added to your host is accompanied by an entry in this file." |
| 25 | + echo -e "After making changes, remember to restart the script \e[95mfastcgi_ops_root.sh\e[0m." |
| 26 | + exit 1 |
| 27 | +} |
| 28 | + |
| 29 | +# user confirmation and handle ctrl+c |
| 30 | +trap manual_setup SIGINT |
19 | 31 |
|
20 | 32 | # Get help before and interrupt |
21 | 33 | help() { |
@@ -143,7 +155,7 @@ while IFS= read -r VHOST; do |
143 | 155 | # Extract PHP-FPM users from running processes, excluding root |
144 | 156 | while read -r user; do |
145 | 157 | ACTIVE_PHP_FPM_USERS+=("$user") |
146 | | - done < <(ps -eo user:30,cmd | grep "[p]hp-fpm:.*$VHOST" | awk '{print $1}' | awk '!seen[$0]++' | grep -v "root") |
| 158 | + done < <(ps -eo user:30,cmd | grep "[p]hp-fpm:.*$VHOST" | awk '{print $1}' | awk '!seen[$0]++' | grep -v "root") |
147 | 159 | done <<< "$ACTIVE_VHOSTS" |
148 | 160 |
|
149 | 161 | # Check if the PHP-FPM user's name is present in the FastCGI cache path |
@@ -173,7 +185,7 @@ check_and_start_systemd_service() { |
173 | 185 | # Generate systemd service file |
174 | 186 | cat <<- NGINX_ > "$service_file" |
175 | 187 | [Unit] |
176 | | -Description=FastCGI Operations Service |
| 188 | +Description=NPP Wordpress Plugin Cache Operations Service |
177 | 189 | After=network.target nginx.service local-fs.target |
178 | 190 | Wants=nginx.service |
179 | 191 |
|
@@ -202,13 +214,13 @@ NGINX_ |
202 | 214 |
|
203 | 215 | # Check if the service started successfully |
204 | 216 | if systemctl is-active --quiet npp-wordpress.service; then |
205 | | - echo -e "\e[92mSuccess:\e[0m Service \e[93mwp-fcgi-notify\e[0m is started." |
| 217 | + echo -e "\e[92mSuccess:\e[0m Service \e[93mnpp-wordpress\e[0m is started." |
206 | 218 | else |
207 | | - echo -e "\e[91mError:\e[0m Service \e[93mwp-fcgi-notify\e[0m failed to start." |
| 219 | + echo -e "\e[91mError:\e[0m Service \e[93mnpp-wordpress\e[0m failed to start." |
208 | 220 | fi |
209 | 221 | else |
210 | 222 | systemctl stop npp-wordpress.service |
211 | | - systemctl start npp-wordpress.service && echo -e "\e[92mSuccess:\e[0m Service \e[93mwp-fcgi-notify\e[0m is re-started." |
| 223 | + systemctl start npp-wordpress.service && echo -e "\e[92mSuccess:\e[0m Service \e[93mnpp-wordpress\e[0m is re-started." |
212 | 224 | fi |
213 | 225 | } |
214 | 226 |
|
@@ -260,6 +272,7 @@ if [[ -f "${this_script_path}/manual-configs.nginx" ]]; then |
260 | 272 |
|
261 | 273 | fcgi["$user"]="$cache_path" |
262 | 274 | done < "${this_script_path}/manual-configs.nginx" |
| 275 | + |
263 | 276 | # Check setup already completed or not |
264 | 277 | if ! [[ -f "${this_script_path}/manual_setup_on" ]]; then |
265 | 278 | check_and_start_systemd_service && touch "${this_script_path}/manual_setup_on" |
@@ -300,13 +313,7 @@ else |
300 | 313 | if [[ $confirm =~ ^[Yy]$ || $confirm == "" ]]; then |
301 | 314 | check_and_start_systemd_service && touch "${this_script_path}/auto_setup_on" |
302 | 315 | else |
303 | | - echo -e "\e[91mCanceled:\e[0m Automated Setup has been canceled by the user. Proceeding to manual setup." |
304 | | - # Provide instructions for manual configuration |
305 | | - echo -e "\n\e[36mTo set up manual configuration, create a file named \e[95m'manual-configs.nginx' \e[0m \e[36min the same directory as this script." |
306 | | - echo -e "Each entry should follow the format: 'PHP-FPM_user FastCGI_cache_path', with one entry per virtual host." |
307 | | - echo -e "Ensure that every new website added to your host is accompanied by an entry in this file." |
308 | | - echo -e "After making changes, remember to restart the script \e[95mfastcgi_ops_root.sh\e[0m." |
309 | | - exit 0 |
| 316 | + manual_setup |
310 | 317 | fi |
311 | 318 | fi |
312 | 319 | fi |
|
0 commit comments