diff --git a/2.Common_services/3.PostgreSQL/0_setup.py b/2.Common_services/3.PostgreSQL/0_setup.py new file mode 100644 index 0000000000000000000000000000000000000000..dcfb881d62bf4924a600358ccb7dbd7076d17521 --- /dev/null +++ b/2.Common_services/3.PostgreSQL/0_setup.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import utils + + +def setup(interactive=True): + db_host = utils.get_conf('DB_HOST') + if db_host and not db_host.startswith('127') and db_host != 'localhost': + utils.log('Skipping postgresql setup because the database host is set to "%s".' % db_host) + return + cmds = [ + 'DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql', + ] + root_pwd = utils.get_conf('DB_PG_ROOT_PWD') + if root_pwd: + cmds.append('sudo su - postgres -c "psql -w -q -A -c "ALTER USER postgres WITH PASSWORD \'%s\';"' % root_pwd) + utils.run_commands(cmds) diff --git a/2.Common_services/3.PostgreSQL/0_setup.sh b/2.Common_services/3.PostgreSQL/0_setup.sh deleted file mode 100755 index 2ad30e689ae930c4b3b55665684a39937bb6fbef..0000000000000000000000000000000000000000 --- a/2.Common_services/3.PostgreSQL/0_setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# TODO: use PostgreSQL custom repo - -DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql diff --git a/30.Deprecated/4.MySQL/0_setup.py b/30.Deprecated/4.MySQL/0_setup.py index 669f9c67c81fad130709bb53736d29fa737c930b..954547b1e0d5684ad775ddd0d4c9200da98443e5 100644 --- a/30.Deprecated/4.MySQL/0_setup.py +++ b/30.Deprecated/4.MySQL/0_setup.py @@ -13,11 +13,11 @@ def setup(interactive=True): 'cp "%s/override.conf" "/etc/systemd/system/mysql.service.d/override.conf"' % dir_path, '/etc/init.d/mysql restart', ] - MYSQL_ROOT_PWD = utils.get_conf('MYSQL_ROOT_PWD') - if MYSQL_ROOT_PWD: + root_pwd = utils.get_conf('DB_MYSQL_ROOT_PWD') + if root_pwd: # Set password if any - cmds.append('mysqladmin -u root password "%s"' % MYSQL_ROOT_PWD) + cmds.append('mysqladmin -u root password "%s"' % root_pwd) utils.run_commands(cmds) - if not MYSQL_ROOT_PWD: + if not root_pwd: utils.log('No root password was set in the configuration file.\nUse the following command to change it:\n mysqladmin -u root password <pwd>') diff --git a/global-conf.sh b/global-conf.sh index 998177f1b9cb6cfbf45d021574a79c3e719e203b..fb952763105729223ec6d659a3389713c49f164e 100644 --- a/global-conf.sh +++ b/global-conf.sh @@ -67,12 +67,11 @@ CM_ADMIN_PWD='test' CACHE_SERVER_NAME= CACHE_SOURCE= -# -- MySQL -- +# -- Database -- +DB_HOST= # if no password is set, it will not be changed or set -MYSQL_ROOT_PWD= -MYSQL_HOST= -# client IP seen by mysql server, use commas to separate values -MYSQL_CONTACT_IP= +DB_PG_ROOT_PWD= +DB_MYSQL_ROOT_PWD= # -- Celerity -- CELERITY_SIGNING_KEY='test'