Moved ers database creation in a separate script

This commit is contained in:
Trial97
2021-06-02 08:16:56 +03:00
committed by Dan Christian Bogos
parent e0fdc54ca3
commit 2de9da2349
6 changed files with 56 additions and 10 deletions

View File

@@ -147,12 +147,24 @@
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install for ers mysql
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mysql/setup_ers_db.sh root CGRateS.org localhost'
args:
chdir: '{{ cgrates_dir }}/data/storage/mysql/'
- name: post install postgres2
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_db_with_users.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install for ers postgres
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/postgres/create_ers_db.sh'
args:
chdir: '{{ cgrates_dir }}/data/storage/postgres/'
- name: post install mongo
become: yes
command: 'sh {{ cgrates_dir }}/data/storage/mongo/setup_cgr_db.sh'

View File

@@ -7,9 +7,3 @@ DROP DATABASE IF EXISTS cgrates;
CREATE DATABASE cgrates;
GRANT ALL on cgrates.* TO 'cgrates'@'localhost' IDENTIFIED BY 'CGRateS.org';
-- extra DB for ees and ers
DROP DATABASE IF EXISTS cgrates2;
CREATE DATABASE cgrates2;
GRANT ALL on cgrates2.* TO 'cgrates'@'localhost' IDENTIFIED BY 'CGRateS.org';

View File

@@ -0,0 +1,15 @@
--
-- Sample db and users creation. Replace here with your own details
--
DROP DATABASE IF EXISTS cgrates;
CREATE DATABASE cgrates;
GRANT ALL on cgrates.* TO 'cgrates'@'localhost' IDENTIFIED BY 'CGRateS.org';
-- extra DB for ees and ers
DROP DATABASE IF EXISTS cgrates2;
CREATE DATABASE cgrates2;
GRANT ALL on cgrates2.* TO 'cgrates'@'localhost' IDENTIFIED BY 'CGRateS.org';

View File

@@ -0,0 +1,25 @@
#! /usr/bin/env sh
if test $# -lt 2; then
echo ""
echo "setup_cgr_db.sh <db_user> <db_password> [<db_host>]"
echo ""
exit 0
fi
host=$3
if [ -z "$3" ]; then
host="localhost"
fi
DIR="$(dirname "$(readlink -f "$0")")"
mysql -u $1 -p$2 -h $host < "$DIR"/create_ers_db.sql
cu=$?
if [ $cu = 0 ]; then
echo "\n\t+++ CGR-DB successfully set-up! +++\n"
exit 0
fi

View File

@@ -7,7 +7,3 @@ sudo -u postgres dropdb -e cgrates
sudo -u postgres dropuser -e cgrates
sudo -u postgres psql -c "CREATE USER cgrates password 'CGRateS.org';"
sudo -u postgres createdb -e -O cgrates cgrates
# extra DB for ees and ers
sudo -u postgres dropdb -e cgrates2
sudo -u postgres createdb -e -O cgrates cgrates2

View File

@@ -0,0 +1,4 @@
# extra DB for ees and ers
sudo -u postgres dropdb -e cgrates2
sudo -u postgres createdb -e -O cgrates cgrates2