helper-scripts/zabbix/init_zabbix.sh

21 lines
617 B
Bash
Raw Normal View History

#!/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