|
7 | 7 |
|
8 | 8 | from string import Template
|
9 | 9 |
|
| 10 | +from setup_app import paths |
10 | 11 | from setup_app.static import AppType, InstallOption
|
11 | 12 | from setup_app.config import Config
|
12 | 13 | from setup_app.utils import base
|
@@ -92,14 +93,31 @@ def local_install(self):
|
92 | 93 |
|
93 | 94 | elif Config.rdbm_type == 'pgsql':
|
94 | 95 | if base.clone_type == 'rpm':
|
95 |
| - self.restart('postgresql') |
| 96 | + self.run(['postgresql-setup', 'initdb']) |
| 97 | + elif base.clone_type == 'deb': |
| 98 | + self.run([paths.cmd_chmod, '640', '/etc/ssl/private/ssl-cert-snakeoil.key']) |
| 99 | + |
| 100 | + self.restart('postgresql') |
| 101 | + |
96 | 102 | cmd_create_db = '''su - postgres -c "psql -U postgres -d postgres -c \\"CREATE DATABASE {};\\""'''.format(Config.rdbm_db)
|
97 | 103 | cmd_create_user = '''su - postgres -c "psql -U postgres -d postgres -c \\"CREATE USER {} WITH PASSWORD '{}';\\""'''.format(Config.rdbm_user, Config.rdbm_password)
|
98 | 104 | cmd_grant_previlages = '''su - postgres -c "psql -U postgres -d postgres -c \\"GRANT ALL PRIVILEGES ON DATABASE {} TO {};\\""'''.format(Config.rdbm_db, Config.rdbm_user)
|
99 | 105 |
|
100 | 106 | for cmd in (cmd_create_db, cmd_create_user, cmd_grant_previlages):
|
101 | 107 | self.run(cmd, shell=True)
|
102 | 108 |
|
| 109 | + if base.clone_type == 'rpm': |
| 110 | + hba_file_path_query = self.run('''su - postgres -c "psql -U postgres -d postgres -t -c \\"SHOW hba_file;\\""''', shell=True) |
| 111 | + if hba_file_path_query and hba_file_path_query.strip(): |
| 112 | + self.stop('postgresql') |
| 113 | + hba_file_path = hba_file_path_query.strip() |
| 114 | + hba_file_content = self.readFile(hba_file_path) |
| 115 | + hba_file_content = 'host\t{0}\t{1}\t127.0.0.1/32\tmd5\nhost\t{0}\t{1}\t::1/128\tmd5\n'.format(Config.rdbm_db, Config.rdbm_user) + hba_file_content |
| 116 | + self.writeFile(hba_file_path, hba_file_content) |
| 117 | + self.start('postgresql') |
| 118 | + |
| 119 | + self.enable('postgresql') |
| 120 | + |
103 | 121 | self.dbUtils.bind(force=True)
|
104 | 122 |
|
105 | 123 | def get_sql_col_type(self, attrname, table=None):
|
|
0 commit comments