Skip to content

Instantly share code, notes, and snippets.

@ChatchaiJ
Last active February 12, 2017 15:30
Show Gist options
  • Save ChatchaiJ/40327a0a135c24a6f3748044731174b2 to your computer and use it in GitHub Desktop.
Save ChatchaiJ/40327a0a135c24a6f3748044731174b2 to your computer and use it in GitHub Desktop.
#!/bin/bash
VER="3.0.0"
ZABBIXSRC="zabbix-${VER}.tar.gz"
SQLDIR="zabbix-${VER}/database/mysql"
[ ! -f "$ZABBIXSRC" ] && echo "Source file '$ZABBIXSRC' does not exist?" && exit
tar -zxvf ${ZABBIXSRC} ${SQLDIR}
[ ! -d "$SQLDIR" ] && echo "Hmmm? Can't extract MySQL files from Zabbix Source." && exit
WORKDIR=`pwd`
cd $SQLDIR
[ ! -f "schema.sql" -o ! -f "images.sql" -o ! -f "data.sql" ] && \
echo "SQL files missing, please check!" && \
exit
cat << EOT > $WORKDIR/cmd.sql
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'root';
connect zabbix;
source schema.sql;
source images.sql;
source data.sql;
exit;
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment