92 lines
2.7 KiB
Bash
92 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
# vicinoc-install - ViciNOC installationg script for Kiwi built ViciNOC Distro
|
|
#
|
|
# Copyright (C) 2018 James Pearson <jamesp@vicidial.com> LICENSE: AGPLv2
|
|
#
|
|
|
|
# Get our local IP address and set timezone
|
|
MYIP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`
|
|
yast timezone set timezone=UTC
|
|
|
|
|
|
# MySQL setup
|
|
mkdir -p /var/lib/mysql
|
|
chown mysql:mysql /var/lib/mysql
|
|
mkdir -p /srv/mysql/data
|
|
chown mysql:mysql /srv/mysql/data
|
|
mysql_install_db --datadir=/srv/mysql/data --user=mysql --group=mysql
|
|
service mysql start
|
|
|
|
|
|
# Icinga Database
|
|
mysql -u root < /usr/src/vicinoc/icinga2-create.sql
|
|
mysql -u root icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
|
|
mysql -u root < /usr/src/vicinoc/icingaweb2.sql
|
|
|
|
|
|
# OpenSIPS Database
|
|
mysql -u root < /usr/src/vicinoc/opensips-create.sql
|
|
cd /usr/share/opensips/mysql
|
|
OPENSIPS="standard acc permissions avpops dialog dispatcher drouting load_balancer rtpproxy auth_db"
|
|
IFS=$' '
|
|
for TABLE in $OPENSIPS
|
|
do
|
|
mysql -u root opensips < $TABLE-create.sql
|
|
done
|
|
OPENSIPSLOCAL="standard acc avpops dialog"
|
|
IFS=$' '
|
|
for TABLE in $OPENSIPSLOCAL
|
|
do
|
|
mysql -u root opensips_local < $TABLE-create.sql
|
|
done
|
|
mysql -u root < /usr/src/vicinoc/opensips-accextra.sql
|
|
|
|
|
|
# Homer Database
|
|
cd /usr/src/homer/homer-api/sql/mysql
|
|
mysql -u root < homer_databases.sql
|
|
mysql -u root < homer_user.sql
|
|
mysql -u root homer_data < schema_data.sql
|
|
mysql -u root homer_configuration < schema_configuration.sql
|
|
mysql -u root homer_statistic < schema_statistic.sql
|
|
mysql -u root homer_configuration --execute "update user set password='*33D42AC1DCD8BEFDDD6EEBA2C9AB79EA3A022B4F' where username='admin';"
|
|
|
|
|
|
# Secure MySQL and then cleanup
|
|
mysql -u root --execute "UPDATE mysql.user SET Password=PASSWORD('vicidial') WHERE User='root';"
|
|
mysql -u root --execute "DELETE FROM mysql.user WHERE User='';"
|
|
mysql -u root --execute "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
|
|
mysql -u root --execute "DROP DATABASE test;"
|
|
mysql -u root --execute "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';"
|
|
mysql -u root --execute "FLUSH PRIVILEGES;"
|
|
echo "[client]
|
|
user=root
|
|
password=vicidial
|
|
socket=/var/run/mysql/mysql.sock" > /root/.my.cnfd
|
|
|
|
|
|
# Setup Homer
|
|
cd /opt/sipcapture
|
|
./homer_rotate
|
|
crontab -l > /tmp/rootcron
|
|
echo "# Rotate homer logs daily
|
|
0 0 * * * /opt/sipcapture/homer_rotate > /dev/null 2>&
|
|
" >> /tmp/rootcron
|
|
crontab /tmp/rootcron
|
|
rm /tmp/rootcron
|
|
|
|
|
|
# Activate services
|
|
chkconfig mysql on
|
|
chkconfig icinga2 on
|
|
chkconfig apache2 on
|
|
chkconfig homersips on
|
|
chkconfig opensips on
|
|
chkconfig smokeping on
|
|
service icinga2 start
|
|
service apache2 start
|
|
service homersips start
|
|
service openeipss start
|
|
service smokeping start
|