helper-scripts/zabbix/init_zabbix.sh

21 lines
715 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
sed "s@^\$DB['PASSWORD'].*$@\$DB['PASSWORD'] = \'${DB_PASSWORD}\';@g" /usr/share/zabbix/conf/zabbix.conf.php.example > /etc/zabbix/web/zabbix.conf.php
2020-04-28 23:00:32 +02:00
systemctl --now enable zabbix-server zabbix-agent nginx php7.3-fpm
systemctl --now mask zabbix-init.service