302 | | pgconffile = self.confirmPipe("to find PostgreSQL's configuration files", "find /etc -name postgresql.conf 2>/dev/null") |
303 | | if pgconffile is not False : |
304 | | pgconffile = pgconffile.strip() |
305 | | pgconfdir = os.path.split(pgconffile)[0] |
306 | | answer = self.confirmPipe("to see if PostgreSQL accepts TCP/IP connections", "grep ^tcpip_socket %(pgconffile)s" % locals()) |
307 | | conflines = pghbaconf.split("\n") |
308 | | if answer is not False : |
309 | | tcpip = answer.strip().lower().endswith("true") |
310 | | else : |
311 | | tcpip = False |
312 | | if tcpip : |
313 | | conflines.insert(2, "host\tpykota\tpykotaadmin,pykotauser\t127.0.0.1\t255.255.255.255\tmd5") |
314 | | else : |
315 | | conflines.insert(1, "local\tpykota\tpykotaadmin,pykotauser\t\tmd5") |
316 | | conf = "\n".join(conflines) |
317 | | self.confirmCommand("to configure PostgreSQL correctly for PyKota", 'echo "%(conf)s" >%(pgconfdir)s/pg_hba.conf' % locals()) |
318 | | self.confirmCommand("to make PostgreSQL take the changes into account", self.pgrestart) |
319 | | return tcpip |
| 302 | pgconffiles = self.confirmPipe("to find PostgreSQL's configuration files", "find /etc -name postgresql.conf 2>/dev/null") |
| 303 | if pgconffiles is not False : |
| 304 | pgconffiles = [part.strip() for part in pgconffiles.split()] |
| 305 | pgconfdirs = [os.path.split(pgconffile)[0] for pgconffile in pgconffiles] |
| 306 | for i in range(len(pgconfdirs)) : |
| 307 | pgconfdir = pgconfdirs[i] |
| 308 | pgconffile = pgconffiles[i] |
| 309 | if (len(pgconfdirs) == 1) or self.yesno("Do PostgreSQL configuration files reside in %(pgconfdir)s" % locals()) : |
| 310 | answer = self.confirmPipe("to see if PostgreSQL accepts TCP/IP connections", "grep ^tcpip_socket %(pgconffile)s" % locals()) |
| 311 | conflines = pghbaconf.split("\n") |
| 312 | if answer is not False : |
| 313 | tcpip = answer.strip().lower().endswith("true") |
| 314 | else : |
| 315 | tcpip = False |
| 316 | if tcpip : |
| 317 | conflines.insert(2, "host\tpykota\tpykotaadmin,pykotauser\t127.0.0.1\t255.255.255.255\tmd5") |
| 318 | else : |
| 319 | conflines.insert(1, "local\tpykota\tpykotaadmin,pykotauser\t\tmd5") |
| 320 | conf = "\n".join(conflines) |
| 321 | self.confirmCommand("to configure PostgreSQL correctly for PyKota", 'echo "%(conf)s" >%(pgconfdir)s/pg_hba.conf' % locals()) |
| 322 | self.confirmCommand("to make PostgreSQL take the changes into account", self.pgrestart) |
| 323 | return tcpip |