134 lines
6.6 KiB
Makefile
134 lines
6.6 KiB
Makefile
SB_COMMIT ?= 52d576be616453b3fd4c93cad4eccae29cc5b3b5
|
|
SB_TARBALL = $(SB_COMMIT).tar.gz
|
|
SB_URL = https://github.com/mickvav/snmpbuilder/archive/$(SB_TARBALL)
|
|
|
|
preinstall:
|
|
# hardcoded users and groups
|
|
$(inroot) useradd --system --comment="created from appliance building - zabbix user" --home-dir="/var/lib/zabbix/home" --shell="/sbin/nologin" --no-create-home --uid 600 --user-group zabbix
|
|
# switch to hardened, build hardened toolchain, rebuild everything
|
|
mkdir -p $(CHROOT)/etc/portage/profile
|
|
echo "-hardened" >> $(CHROOT)/etc/portage/profile/use.mask
|
|
$(inroot) $(EMERGE) $(USEPKG) --oneshot gcc
|
|
$(inroot) $(EMERGE) $(USEPKG) --oneshot binutils virtual/libc
|
|
-$(gcc_config)
|
|
$(inroot) $(EMERGE) $(USEPKG) --emptytree @world
|
|
$(inroot) perl-cleaner --all
|
|
$(inroot) bash -c 'yes YES | etc-update --automode -9'
|
|
|
|
install_snmpbuilder:
|
|
$(inroot) test -f /var/cache/distfiles/$(SB_TARBALL) || \
|
|
$(inroot) wget -P /var/cache/distfiles $(SB_URL)
|
|
$(inroot) tar xf /var/cache/distfiles/$(SB_TARBALL) -C /tmp
|
|
cp $(CHROOT)/tmp/snmpbuilder-$(SB_COMMIT)/snmp_builder.php $(CHROOT)/var/www/localhost/htdocs/zabbix/
|
|
cp -r $(CHROOT)/tmp/snmpbuilder-$(SB_COMMIT)/snmp_builder $(CHROOT)/var/www/localhost/htdocs/zabbix/
|
|
sed -i 's#/var/www/html/zabbix/snmp_builder/mibs#/var/www/localhost/htdocs/zabbix/snmp_builder/mibs#' $(CHROOT)/var/www/localhost/htdocs/zabbix/snmp_builder.php
|
|
patch -d $(CHROOT)/var/www/localhost/htdocs/zabbix/ -p1 < zabbix/snmp_builder.diff
|
|
|
|
postinstall: base/timesyncd.conf base/firstboot.start
|
|
# Konfigurationen anpassen
|
|
cp base/timesyncd.conf $(CHROOT)/etc/systemd/timesyncd.conf
|
|
mkdir -p $(CHROOT)/etc/local.d
|
|
cp base/firstboot.start $(CHROOT)/etc/local.d/firstboot.start
|
|
touch $(CHROOT)/firstboot
|
|
sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' $(CHROOT)/etc/sudoers
|
|
sed -i 's#^auth.*$$#auth [success=2 default=ignore] pam_ssh_agent_auth.so file=~/.ssh/authorized_keys\nauth include system-auth#' $(CHROOT)/etc/pam.d/sudo
|
|
echo "Defaults env_keep += SSH_AUTH_SOCK" > $(CHROOT)/etc/sudoers.d/ssh_auth_sock
|
|
$(inroot) useradd -m -G users,wheel -s /bin/bash --comment="virtual appliance admin" --uid 2000 admin
|
|
$(inroot) passwd -d admin; $(inroot) passwd -e admin
|
|
$(inroot) systemctl enable tmux@root.service
|
|
cp base/tmux.conf $(CHROOT)/root/.tmux.conf
|
|
|
|
# Beispiel feste IP-Adresse
|
|
cp base/00-eth0.network $(CHROOT)/00-eth0.network.example
|
|
|
|
# MariaDB-Konfiguration
|
|
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/*
|
|
$(inroot) bash -c 'yes gentoo | emerge --config dev-db/mariadb'
|
|
|
|
# Apache-/PHP-Konfiguration
|
|
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:' \
|
|
-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:'
|
|
$(inroot) systemctl enable apache2
|
|
|
|
# Add zabbix service definitions
|
|
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
|
|
|
|
# Install Zabbix webapp
|
|
$(inroot) webapp-config -h localhost -d zabbix -I zabbix `ls $(CHROOT)/usr/share/webapps/zabbix`
|
|
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
|
|
$(inroot) chown -R zabbix:zabbix \
|
|
/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
|
|
|
|
# Zabbix Agent
|
|
cp zabbix/userparameter_mysql.conf $(CHROOT)/var/lib/zabbix/userparameter_mysql.conf
|
|
|
|
# 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/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
|
|
$(inroot)chown -R zabbix:zabbix /etc/zabbix/scripts
|
|
chmod +x $(CHROOT)/etc/zabbix/scripts/zabbix_syslog_create_urls.pl
|
|
chmod +x $(CHROOT)/etc/zabbix/scripts/zabbix_syslog_lkp_host.pl
|
|
|
|
# FPing
|
|
$(inroot)chmod u=rwsx,g=rx,o=rx /usr/sbin/fping
|
|
$(inroot)chmod u=rwsx,g=rx,o=rx /usr/sbin/fping6
|
|
|
|
# SNMP
|
|
cp snmp/snmpd.conf $(CHROOT)/etc/snmp/snmpd.conf
|
|
cp snmp/snmptrapd.conf $(CHROOT)/etc/snmp/snmptrapd.conf
|
|
cp snmp/snmptt.conf $(CHROOT)/etc/snmp/snmptt.conf
|
|
sed -i \
|
|
-e 's:net_snmp_perl_enable = 0:net_snmp_perl_enable = 1:' \
|
|
-e 's:translate_integers = 1:translate_integers = 0:' \
|
|
-e 's:#mibs_environment = ALL:mibs_environment = ALL:' \
|
|
-e 's.#date_time_format =.date_time_format = %H:%M:%S %Y/%m/%d.' \
|
|
-e 's:daemon_uid = snmptt:daemon_uid = zabbix:' \
|
|
-e 's:log_system_enable = 0:log_system_enable = 1:' \
|
|
-e 's:unknown_trap_log_enable = 0:unknown_trap_log_enable = 1:' \
|
|
$(CHROOT)/etc/snmp/snmptt.ini
|
|
mkdir -p $(CHROOT)/var/log/snmptt
|
|
$(inroot)chmod 0775 /var/log/snmptt
|
|
$(inroot)chown zabbix:zabbix /var/log/snmptt
|
|
|
|
# Zabbix SNMP Builder
|
|
## $(MAKE) install_snmpbuilder
|
|
|
|
clean:
|