PHP Version as var
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Post-installation script for zabbix-php-monitoring
|
# Post-installation script for zabbix-php-monitoring
|
||||||
|
|
||||||
# Create log directory with proper permissions
|
# Create log directory with proper permissions
|
||||||
@@ -22,16 +29,16 @@ chmod 440 /etc/sudoers.d/zabbix-php-user
|
|||||||
# Unset previous empty prepend_file
|
# Unset previous empty prepend_file
|
||||||
# sed -i 's/^[[:space:]]*auto_prepend_file[[:space:]]*=[[:space:]]*$/; auto_prepend_file =/' /etc/php/*/fpm/php.ini
|
# 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
|
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
|
read -p "$(echo -e "\e[3;31mZabbix monitor in $cfg einrichten? [\e[1;31mY\e[0m,n]: \e[0m")" ok
|
||||||
comment=''
|
comment=''
|
||||||
[[ "$ok" =~ n|N ]] && comment='; Comment out to enable\n; '
|
[[ "$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
|
done
|
||||||
|
|
||||||
# Restart services to apply configuration
|
# 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
|
systemctl restart zabbix-agent.service || true
|
||||||
|
|
||||||
echo "Zabbix PHP monitoring has been installed successfully."
|
echo "Zabbix PHP monitoring has been installed successfully."
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e
|
||||||
|
|
||||||
# Pre-removal script for zabbix-php-monitoring
|
# Pre-removal script for zabbix-php-monitoring
|
||||||
@@ -6,10 +11,10 @@ set -e
|
|||||||
echo "Removing zabbix-php-monitoring..."
|
echo "Removing zabbix-php-monitoring..."
|
||||||
|
|
||||||
# Restart PHP-FPM to clear the auto_prepend_file configuration
|
# 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
|
# 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 "Log files in /var/log/zabbix/ have been preserved"
|
||||||
echo "Configuration files will be removed"
|
echo "Configuration files will be removed"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user