PHP Version as var
This commit is contained in:
@@ -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."
|
||||
|
||||
@@ -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,7 +11,7 @@ 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"
|
||||
|
||||
Reference in New Issue
Block a user