Fix logic to bind postgres to all network interfaces
ugh, finally solved this
This commit is contained in:
parent
5fcfc91d83
commit
8c556e6176
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -26,7 +26,6 @@ Fabric Library for PostgreSQL
|
|||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from rattail_fabric2 import apt, append, contains, sed, uncomment
|
||||
|
||||
|
@ -58,29 +57,20 @@ def set_listen_addresses(c, *addresses):
|
|||
version = int(version)
|
||||
|
||||
addresses = ','.join(addresses)
|
||||
# TODO: this does not seem to work, so cannot do this..? need to
|
||||
# figure it out, since it's the whole reason i added this function
|
||||
# addresses = addresses.replace('*', '\\\\*')
|
||||
|
||||
if not contains(c, '/etc/postgresql/{}/main/postgresql.conf'.format(version),
|
||||
"listen_addresses = '{}'".format(addresses),
|
||||
exact=True):
|
||||
|
||||
uncomment(c, '/etc/postgresql/{}/main/postgresql.conf'.format(version),
|
||||
r'^#listen_addresses\s*=.*',
|
||||
r'^# *listen_addresses\s*=.*',
|
||||
use_sudo=True)
|
||||
if addresses == '*':
|
||||
print("\n\nYou requested a wildcard ('*') as the listen_addresses "
|
||||
"value for PostgreSQL. Unfortunately our logic is not yet "
|
||||
"sufficient to handle that scenario, so you must manually "
|
||||
"edit this file:\n\n"
|
||||
" /etc/postgresql/{}/main/postgresql.conf\n\n"
|
||||
"And somewhere in there add exactly the following:\n\n"
|
||||
" listen_addresses = '*'\n\n".format(version))
|
||||
sys.exit(1)
|
||||
|
||||
sed(c, '/etc/postgresql/{}/main/postgresql.conf'.format(version),
|
||||
r'listen_addresses\s*=.*',
|
||||
"listen_addresses = '{}'".format(addresses),
|
||||
use_sudo=True)
|
||||
|
||||
restart(c)
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -240,6 +240,10 @@ def sed(c, filename, before, after, limit='', use_sudo=False, backup='.bak',
|
|||
after = after.replace(char, r'\%s' % char)
|
||||
if limit:
|
||||
limit = r'/%s/ ' % limit
|
||||
|
||||
# if replacement text contains single quote chars, must escape them
|
||||
after = after.replace("'", "'\"'\"'")
|
||||
|
||||
context = {
|
||||
'script': r"'%ss/%s/%s/%sg'" % (limit, before, after, flags),
|
||||
'filename': _expand_path(c, filename),
|
||||
|
|
Loading…
Reference in a new issue