new php-fpm check

This commit is contained in:
2025-10-29 11:48:24 +01:00
parent e574c6cfe4
commit e5dd257757

View File

@@ -34,10 +34,27 @@ usage () {
} }
# #
# Function to check if a service is already running or not # Function check if a service is running or stopped, including php-fpm
# #
serviceno () { printf "\n%s" "$service" ; printf " is not running cannot continue...\n\n"; } checkservice() {
servicedead () { status=$(systemctl is-active "$service"); if [[ "$status" != "active" ]]; then serviceno ; exit 1 ; fi; } local svc="$1" ; local mode="$2"
if [[ "$svc" == php*-fpm ]] && ! systemctl list-unit-files --type=service | grep -q "^${svc}.service" ; then
svc="php-fpm"
fi
if [[ "$mode" == "mustberunning" ]]; then
if ! systemctl is-active --quiet "$svc" 2>/dev/null; then
printf "\nService %s is not running, aborting...\n\n" "$svc"
exit 1
fi
elif [[ "$mode" == "mustnotberunning" ]]; then
if systemctl is-active --quiet "$svc" 2>/dev/null; then
printf "\nService %s is already running, aborting...\n\n" "$svc"
exit 1
fi
fi
}
# #
# Function input check # Function input check
@@ -45,9 +62,9 @@ servicedead () { status=$(systemctl is-active "$service"); if [[ "$status" != "
inputcheck () { if [[ -z "$1" ]]; then usage ; printf "ERROR: DOMAIN CANNOT BE EMPTY!\n\n" ; exit; fi; } inputcheck () { if [[ -z "$1" ]]; then usage ; printf "ERROR: DOMAIN CANNOT BE EMPTY!\n\n" ; exit; fi; }
# #
# If Nginx is not running then die # If Nginx or PHP-Fpm version is not found or not running the die.
# #
service="nginx" ; servicedead checkservice nginx running ; checkservice "$phpfpm" running
# #
# Let's go # Let's go