From 966eac0d4d6641af2d678734c6c0b546ce3fbaa3 Mon Sep 17 00:00:00 2001 From: Holger Sielaff Date: Wed, 1 Oct 2025 11:32:35 +0200 Subject: [PATCH] PHP Version as var --- debscripts/postinst | 13 ++++++++++--- debscripts/prerm | 9 +++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/debscripts/postinst b/debscripts/postinst index d553a92..1391f90 100755 --- a/debscripts/postinst +++ b/debscripts/postinst @@ -1,6 +1,13 @@ #!/bin/bash + +# Uhhhhhhhhhhhhhhhh +PHP_VERSION=$(dpkg -l | grep -Pe 'php[0-9.]+-fpm' | awk '{print $2}' | sed 's/php//;s/-fpm//') +PHP_VERSION=${PHP_VERSION-8.3} + set -e + + # Post-installation script for zabbix-php-monitoring # Create log directory with proper permissions @@ -22,16 +29,16 @@ chmod 440 /etc/sudoers.d/zabbix-php-user # Unset previous empty prepend_file # sed -i 's/^[[:space:]]*auto_prepend_file[[:space:]]*=[[:space:]]*$/; auto_prepend_file =/' /etc/php/*/fpm/php.ini -for cfg in /etc/php/8.3/fpm/pool.d/*.conf; do +for cfg in /etc/php/$PHP_VERSION/fpm/pool.d/*.conf; do grep -q auto_prepend_file $cfg && continue read -p "$(echo -e "\e[3;31mZabbix monitor in $cfg einrichten? [\e[1;31mY\e[0m,n]: \e[0m")" ok comment='' [[ "$ok" =~ n|N ]] && comment='; Comment out to enable\n; ' - echo -e "\n; Added by php8.3-zabbix-monitor\n${comment}php_admin_value[auto_prepend_file] = /usr/lib/zabbix-php.php" >> $cfg + echo -e "\n; Added by php$PHP_VERSION-zabbix-monitor\n${comment}php_admin_value[auto_prepend_file] = /usr/lib/zabbix-php.php" >> $cfg done # Restart services to apply configuration -systemctl reload php8.3-fpm.service || true +systemctl reload php$PHP_VERSION-fpm.service || true systemctl restart zabbix-agent.service || true echo "Zabbix PHP monitoring has been installed successfully." diff --git a/debscripts/prerm b/debscripts/prerm index 44eaba7..a614ca6 100755 --- a/debscripts/prerm +++ b/debscripts/prerm @@ -1,4 +1,9 @@ #!/bin/bash + +# Uhhhhhhhhhhhh +PHP_VERSION=$(dpkg -l | grep -Pe 'php[0-9.]+-fpm' | awk '{print $2}' | sed 's/php//;s/-fpm//') +PHP_VERSION=${PHP_VERSION-8.3} + set -e # Pre-removal script for zabbix-php-monitoring @@ -6,10 +11,10 @@ set -e echo "Removing zabbix-php-monitoring..." # Restart PHP-FPM to clear the auto_prepend_file configuration -systemctl reload php8.3-fpm.service || true +systemctl reload php$PHP_VERSION-fpm.service || true # Note: We don't remove the log files as they may contain important data echo "Log files in /var/log/zabbix/ have been preserved" echo "Configuration files will be removed" -exit 0 \ No newline at end of file +exit 0