-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
150 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
uname | ||
uname -a | ||
set -e | ||
set -x | ||
|
||
|
||
database_type=$1 | ||
|
||
. /etc/os-release | ||
distrib=${ID} | ||
distrib=$(echo $distrib | tr '[:lower:]' '[:upper:]') | ||
|
||
|
||
if [ $database_type == 'mysql' ]; then | ||
echo "########################### Start MySQL ######################################" | ||
#workaround of forbidden execution of mysqld | ||
cp /usr/libexec/mysqld /usr/libexec/mysqldtoto | ||
/usr/libexec/mysqldtoto --user=root --initialize-insecure | ||
/usr/libexec/mysqldtoto --user=root & | ||
|
||
while [ ! -S /var/lib/mysql/mysql.sock ] && [ ! -S /var/run/mysqld/mysqld.sock ]; do | ||
sleep 10 | ||
done | ||
|
||
else | ||
echo "########################### Start MariaDB ######################################" | ||
if [ "$distrib" = "ALMALINUX" ]; then | ||
mysql_install_db --user=root --basedir=/usr --datadir=/var/lib/mysql | ||
mariadbd --socket=/var/lib/mysql/mysql.sock --user=root > /dev/null 2>&1 & | ||
else | ||
mkdir -p /run/mysqld | ||
chown mysql:mysql /run/mysqld | ||
mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 & | ||
fi | ||
fi | ||
|
||
sleep 5 | ||
echo "########################### Init centreon database ############################" | ||
|
||
mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon'" | ||
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon'" | ||
|
||
|
||
mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost'" | ||
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'" | ||
|
||
cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql | ||
|
||
mysql -u root_centreon -pcentreon < resources/centreon_storage.sql | ||
mysql -u root_centreon -pcentreon < /tmp/centreon.sql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters