...
This commit is contained in:
46
debscripts/postinst
Executable file
46
debscripts/postinst
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Post-installation script for zabbix-php-monitoring
|
||||
|
||||
# Create log directory with proper permissions
|
||||
mkdir -p /var/log/zabbix
|
||||
chown www-data:zabbix /var/log/zabbix
|
||||
chmod 755 /var/log/zabbix
|
||||
|
||||
# Create log file with proper permissions if it doesn't exist
|
||||
if [ ! -f /var/log/zabbix/php.log ]; then
|
||||
touch /var/log/zabbix/php.exceptions.log
|
||||
chown www-data:zabbix /var/log/zabbix/php.exceptions.log
|
||||
chmod 644 /var/log/zabbix/php.exceptions.log
|
||||
fi
|
||||
|
||||
# Set permissions on sudoers file
|
||||
chown root:root /etc/sudoers.d/zabbix-php-user
|
||||
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
|
||||
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
|
||||
done
|
||||
|
||||
# Restart services to apply configuration
|
||||
systemctl reload php8.3-fpm.service || true
|
||||
systemctl restart zabbix-agent.service || true
|
||||
|
||||
echo "Zabbix PHP monitoring has been installed successfully."
|
||||
echo "Log file: /var/log/zabbix/php.exceptions.log"
|
||||
echo "Template file: /usr/share/doc/zabbix-php-monitoring/zabbix_template_php_exceptions.yaml"
|
||||
echo ""
|
||||
echo "To complete setup:"
|
||||
echo "1. Import the template into your Zabbix server"
|
||||
echo "2. Assign the template to your hosts"
|
||||
echo "3. Configure zabbix_agentd.conf with appropriate log monitoring"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user