Création d'un script d'initialisation de zabbix pour une installation preseed

This commit is contained in:
root 2020-04-28 22:55:26 +02:00
parent 4e0f1593ae
commit a9569b0547

20
zabbix/init_zabbix.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
DB_NAME=zabbix
DB_USER=zabbix
DB_PASSWORD="$(openssl rand -base64 18)"
mysql -u root << EOF
create database ${DB_NAME} character set utf8 collate utf8_bin;
grant all privileges on ${DB_NAME}.* to ${DB_USER}@localhost identified by '${DB_PASSWORD}';
quit;
EOF
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME}
echo "DBPassword=${DB_PASSWORD}" >> /etc/zabbix/zabbix_server.conf.d/db.conf
systemctl restart zabbix-server zabbix-agent nginx php7.3-fpm
systemctl enable zabbix-server zabbix-agent nginx php7.3-fpm
systemctl disable zabbix-init.service