appliances/zabbix/Makefile

146 lines
7.1 KiB
Makefile
Raw Normal View History

2021-04-19 19:22:09 +02:00
02firstboot = $(CHROOT)/usr/local/bin/02firstboot.start
2021-04-13 19:07:06 +02:00
cert-renew.sh = $(CHROOT)/etc/ssl/cert-renew.sh
zabbix-userparameter = $(CHROOT)/var/lib/zabbix/userparameter_mysql.conf
systemd-units: appliance/MySQL-Backup.sh appliance/backup.service appliance/backup.timer appliance/cert-renew.service appliance/cert-renew.timer
2021-04-19 19:22:09 +02:00
mkdir -p $(CHROOT)/usr/local/bin
2021-04-13 19:07:06 +02:00
cp appliance/MySQL-Backup.sh $(CHROOT)/usr/local/bin/
cp appliance/backup.service appliance/backup.timer appliance/cert-renew.service appliance/cert-renew.timer $(CHROOT)/etc/systemd/system/
$(02firstboot): appliance/02firstboot.start
2021-04-19 19:22:09 +02:00
mkdir -p $(CHROOT)/usr/local/bin
2021-04-13 19:07:06 +02:00
cp $< $@
touch $(CHROOT)/02firstboot
$(cert-renew.sh): appliance/cert-renew.sh
mkdir -p $(CHROOT)/etc/ssl
cp $< $@
2021-04-02 18:20:07 +02:00
2021-04-13 19:07:06 +02:00
$(CHROOT)/var/lib/mysql: mariadb/my.cnf.root
# MariaDB-Konfiguration ($$, weil make ein $ entfernt)
2021-04-02 18:20:07 +02:00
sed -i "s/^character-set-server.*$$/character-set-server = utf8mb4/" $(CHROOT)/etc/mysql/mariadb.d/50-distro-server.cnf
sed -iE 's/^\(log-bin\)/#\1/' $(CHROOT)/etc/mysql/mariadb.d/50-distro-server.cnf
echo >> $(CHROOT)/etc/mysql/mariadb.d/50-distro-server.cnf
echo "# innodb tuning" >> $(CHROOT)/etc/mysql/mariadb.d/50-distro-server.cnf
echo "innodb_buffer_pool_size = 2G" >> $(CHROOT)/etc/mysql/mariadb.d/50-distro-server.cnf
echo "innodb_strict_mode = OFF" >> $(CHROOT)/etc/mysql/mariadb.d/50-distro-server.cnf
cp mariadb/my.cnf.root $(CHROOT)/root/.my.cnf
chmod 0600 $(CHROOT)/root/.my.cnf
rm -rf $(CHROOT)/var/lib/mysql/*
2021-04-13 19:07:06 +02:00
RUN bash -c 'yes gentoo | emerge --config dev-db/mariadb'
2021-04-02 18:20:07 +02:00
2021-04-13 19:07:06 +02:00
apache-php:
2021-04-02 18:20:07 +02:00
sed -i 's:APACHE2_OPTS=\":APACHE2_OPTS=\"-D PHP :' $(CHROOT)/etc/conf.d/apache2
find $(CHROOT)/etc/php/apache2-*/ -iname php.ini -print | xargs \sed -i \
-e 's:.*date.timezone =.*:date.timezone = Europe/Berlin:' \
2021-04-13 19:07:06 +02:00
-e 's:.*pcre.jit=.*:pcre.jit=0:' \
2021-04-02 18:20:07 +02:00
-e 's:.*max_execution_time =.*:max_execution_time = 300:' \
-e 's:.*max_input_time =.*:max_input_time = 300:' \
-e 's:.*post_max_size =.*:post_max_size = 16M:' \
-e 's:.*always_populate_raw_post_data =.*:always_populate_raw_post_data = -1:'
2021-04-13 19:07:06 +02:00
zabbix-services:
2021-04-02 18:20:07 +02:00
echo "zabbix-agent 10050/tcp Zabbix Agent" >> $(CHROOT)/etc/services
echo "zabbix-agent 10050/udp Zabbix Agent" >> $(CHROOT)/etc/services
echo "zabbix-trapper 10051/tcp Zabbix Trapper" >> $(CHROOT)/etc/services
echo "zabbix-trapper 10051/udp Zabbix Trapper" >> $(CHROOT)/etc/services
2021-04-13 19:07:06 +02:00
zabbix-webapp:
RUN webapp-config -h localhost -d zabbix -I zabbix `ls $(CHROOT)/usr/share/webapps/zabbix`
2021-04-02 18:20:07 +02:00
cp $(CHROOT)/var/www/localhost/htdocs/zabbix/conf/zabbix.conf.php.example $(CHROOT)/var/www/localhost/htdocs/zabbix/conf/zabbix.conf.php
# enable any language
sed -i "s:'display' => false]:'display' => true]:" $(CHROOT)/var/www/localhost/htdocs/zabbix/include/locales.inc.php
# im Zabbix-Ebuild wird fowners und fperms vor webapp_src_install aufgerufen und deswegen wieder überschrieben
2021-04-13 19:07:06 +02:00
RUN chown -R zabbix:zabbix \
2021-04-02 18:20:07 +02:00
/etc/zabbix \
/var/lib/zabbix \
/var/lib/zabbix/home \
/var/lib/zabbix/scripts \
/var/lib/zabbix/alertscripts \
/var/lib/zabbix/externalscripts \
/var/log/zabbix
chmod 0750 \
$(CHROOT)/etc/zabbix \
$(CHROOT)/var/lib/zabbix \
$(CHROOT)/var/lib/zabbix/home \
$(CHROOT)/var/lib/zabbix/scripts \
$(CHROOT)/var/lib/zabbix/alertscripts \
$(CHROOT)/var/lib/zabbix/externalscripts \
$(CHROOT)/var/log/zabbix
2021-04-13 19:07:06 +02:00
$(zabbix-userparameter): zabbix/userparameter_mysql.conf
mkdir -p $(CHROOT)/var/lib/zabbix
cp $< $@
2021-04-02 18:20:07 +02:00
2021-04-13 19:07:06 +02:00
zabbix-syslog:
2021-04-02 18:20:07 +02:00
# Zabbix Syslog (https://github.com/v-zhuravlev/zabbix-syslog)
mkdir -p $(CHROOT)/etc/zabbix/scripts/lib
cp zabbix/zabbix-syslog/zabbix_syslog_create_urls.pl $(CHROOT)/etc/zabbix/scripts/zabbix_syslog_create_urls.pl
cp zabbix/zabbix-syslog/zabbix_syslog_lkp_host.pl $(CHROOT)/etc/zabbix/scripts/zabbix_syslog_lkp_host.pl
cp zabbix/zabbix-syslog/Template_syslog.xml $(CHROOT)/etc/zabbix/scripts/Template_syslog.xml
2021-04-02 18:20:07 +02:00
cp zabbix/zabbix-syslog/zabbix_syslog.cfg $(CHROOT)/etc/zabbix/zabbix_syslog.cfg
cp zabbix/zabbix-syslog/lib/ZabbixAPI.pm $(CHROOT)/etc/zabbix/scripts/lib/ZabbixAPI.pm
cp zabbix/zabbix-syslog/70-zabbix_rsyslog.conf $(CHROOT)/etc/rsyslog.d/70-zabbix_rsyslog.conf
2021-04-13 19:07:06 +02:00
RUN chown -R zabbix:zabbix /etc/zabbix/scripts
2021-04-02 18:20:07 +02:00
chmod +x $(CHROOT)/etc/zabbix/scripts/zabbix_syslog_create_urls.pl
chmod +x $(CHROOT)/etc/zabbix/scripts/zabbix_syslog_lkp_host.pl
zabbix-config:
sed -i \
-e 's:# PidFile=/tmp/zabbix_agent2.pid:PidFile=/run/zabbix/zabbix_agent2.pid:' \
-e 's:# LogFile=/tmp/zabbix_agent2.log:LogFile=/var/log/zabbix/zabbix_agent2.log:' \
$(CHROOT)/etc/zabbix/zabbix_agent2.conf
sed -i \
-e 's:LogFile=/tmp/zabbix_proxy.log:LogFile=/var/log/zabbix/zabbix_proxy.log:' \
-e 's:# PidFile=/tmp/zabbix_proxy.pid:PidFile=/run/zabbix/zabbix_proxy.pid:' \
$(CHROOT)/etc/zabbix/zabbix_proxy.conf
sed -i \
-e 's:LogFile=/tmp/zabbix_server.log:LogFile=/var/log/zabbix/zabbix_server.log:' \
-e 's:# PidFile=/tmp/zabbix_server.pid:PidFile=/run/zabbix/zabbix_server.pid:' \
-e 's:# StartPollers=5:StartPollers=15:' \
-e 's:# StartIPMIPollers=0:StartIPMIPollers=5:' \
-e 's:# StartPollersUnreachable=1:StartPollersUnreachable=15:' \
-e 's:# StartPingers=1:StartPingers=25:' \
-e 's:# StartDiscoverers=1:StartDiscoverers=5:' \
-e 's:# JavaGateway=:JavaGateway=127.0.0.1:' \
-e 's:# VMwareCacheSize=8M:VMwareCacheSize=16M:' \
-e 's:# VMwareTimeout=10:VMwareTimeout=30:' \
-e 's:# SNMPTrapperFile=/tmp/zabbix_traps.tmp:SNMPTrapperFile=/var/log/snmptt/snmptt.log:' \
-e 's:# CacheSize=8M:CacheSize=32M:' \
-e 's:# HistoryIndexCacheSize=4M:HistoryIndexCacheSize=8M:' \
-e 's:Timeout=4:Timeout=10:' \
-e 's:^# AlertScriptsPath=.*:AlertScriptsPath=/var/lib/zabbix/alertscripts:' \
-e 's:^# ExternalScripts=.*:ExternalScripts=/var/lib/zabbix/externalscripts:' \
-e 's:# ProxyConfigFrequency=3600:ProxyConfigFrequency=360:' \
-e 's:# ProxyDataFrequency=1:ProxyDataFrequency=60:' \
$(CHROOT)/etc/zabbix/zabbix_server.conf
fping-perm:
2021-04-13 19:07:06 +02:00
chmod u=rwsx,g=rx,o=rx $(CHROOT)/usr/sbin/fping
chmod u=rwsx,g=rx,o=rx $(CHROOT)/usr/sbin/fping6
2021-04-02 18:20:07 +02:00
snmp-conf:
cp -f snmp/snmpd.conf $(CHROOT)/etc/snmp/snmpd.conf
cp -f snmp/snmptrapd.conf $(CHROOT)/etc/snmp/snmptrapd.conf
cp -f snmp/snmptt.conf $(CHROOT)/etc/snmp/snmptt.conf
2021-04-02 18:20:07 +02:00
sed -i \
-e 's:^mode = .*:mode = standalone:' \
-e 's:^net_snmp_perl_enable = .*:net_snmp_perl_enable = 1:' \
-e 's:^translate_log_trap_oid = .*:translate_log_trap_oid = 2:' \
-e 's:^translate_integers = .*:translate_integers = 0:' \
-e 's:^#mibs_environment = .*:mibs_environment = ALL:' \
-e 's.^#date_time_format =.date_time_format = %H:%M:%S %Y/%m/%d.' \
-e 's:^daemon_uid = .*:daemon_uid = zabbix:' \
-e 's:^log_system_enable = .*:log_system_enable = 1:' \
-e 's:^unknown_trap_log_enable = .*:unknown_trap_log_enable = 1:' \
-e 's:^syslog_level = .*:syslog_level = err:' \
-e 's:^syslog_system_level = .*:syslog_system_level = err:' \
2021-04-02 18:20:07 +02:00
$(CHROOT)/etc/snmp/snmptt.ini
mkdir -p $(CHROOT)/var/log/snmptt
2021-04-13 19:07:06 +02:00
chmod 0775 $(CHROOT)/var/log/snmptt
RUN chown zabbix:zabbix /var/log/snmptt
preinstall:
postinstall: systemd-units $(02firstboot) $(cert-renew.sh) $(CHROOT)/var/lib/mysql apache-php zabbix-services zabbix-webapp $(zabbix-userparameter) zabbix-syslog zabbix-config fping-perm snmp-conf