helper-scripts/zabbix/init_zabbix.sh

25 lines
1022 B
Bash
Executable File

#!/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'\][^=]*\).*@\1= '${DB_PASSWORD}';@g" /usr/share/zabbix/conf/zabbix.conf.php.example > /etc/zabbix/web/zabbix.conf.php
wget -qO /usr/bin/freesms https://gitlab.blorand.org/benoit/helper-scripts/raw/branch/master/sms/freesms
wget -qO /usr/lib/zabbix/alertscripts/freesms https://gitlab.blorand.org/benoit/helper-scripts/raw/branch/master/sms/freesms.zabbix_alert_script
chmod +x /usr/lib/zabbix/alertscripts/freesms /usr/bin/freesms
systemctl --now enable zabbix-server zabbix-agent nginx php7.3-fpm
systemctl --now mask zabbix-init.service