Skip to content

Commit

Permalink
use comm -23
Browse files Browse the repository at this point in the history
  • Loading branch information
hsntgm authored Mar 9, 2024
1 parent 88a56bc commit c9c7bc1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastcgi_ops_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ for VHOST in $ACTIVE_VHOSTS; do
FASTCGI_CACHE_PATHS=$(extract_fastcgi_cache_paths)

# Extract PHP-FPM users from running processes, excluding root
PHP_FPM_USERS=$(grep -ri -h -E "^\s*user\s*=" /etc/php | awk -F '=' '{print $2}' | sort | uniq | sed 's/^\s*//;s/\s*$//')
PHP_FPM_USERS=$(grep -ri -h -E "^\s*user\s*=" /etc/php | awk -F '=' '{print $2}' | sort | uniq | sed 's/^\s*//;s/\s*$//' | grep -v "nobody")
ACTIVE_PHP_FPM_USERS=$(ps -eo user:20,cmd | grep "[p]hp-fpm:.*$VHOST" | awk '{print $1}' | awk '!seen[$0]++' | grep -v "root")
ONDEMAND_PHP_FPM_USERS=$(echo "$PHP_FPM_USERS" "$ACTIVE_PHP_FPM_USERS" | tr ' ' '\n' | sort | uniq -u)
ONDEMAND_PHP_FPM_USERS=$(comm -23 <(echo "$PHP_FPM_USERS") <(echo "$ACTIVE_PHP_FPM_USERS")
for PHP_FPM_USER in $PHP_FPM_USERS; do
for FASTCGI_CACHE_PATH in $FASTCGI_CACHE_PATHS; do
# Check if the PHP-FPM user's name is present in the FastCGI cache path
Expand Down

0 comments on commit c9c7bc1

Please sign in to comment.