Commit 76fc9f3a authored by Marco Mariani's avatar Marco Mariani

don't do anything if data directory exists; fix ipv6 url

parent c78690ec
...@@ -38,17 +38,18 @@ class Recipe(GenericBaseRecipe): ...@@ -38,17 +38,18 @@ class Recipe(GenericBaseRecipe):
def _options(self, options): def _options(self, options):
options['password'] = self.generatePassword() options['password'] = self.generatePassword()
options['url'] = 'postgresql://%(user)s:%(password)s/%(host)s:%(port)s/%(dbname)s' % dict(options, host=options['ipv6_host'].pop()) options['url'] = 'postgresql://%(user)s:%(password)s/[%(host)s]:%(port)s/%(dbname)s' % dict(options, host=options['ipv6_host'].pop())
def install(self): def install(self):
self.createCluster()
self.createConfig()
self.createDatabase()
self.createRunScript()
pgdata = self.options['pgdata-directory'] pgdata = self.options['pgdata-directory']
if not os.path.exists(pgdata):
self.createCluster()
self.createConfig()
self.createDatabase()
self.createRunScript()
return [ return [
os.path.join(pgdata, 'postgresql.conf') os.path.join(pgdata, 'postgresql.conf')
] ]
...@@ -57,18 +58,16 @@ class Recipe(GenericBaseRecipe): ...@@ -57,18 +58,16 @@ class Recipe(GenericBaseRecipe):
def createCluster(self): def createCluster(self):
initdb_binary = os.path.join(self.options['bin'], 'initdb') initdb_binary = os.path.join(self.options['bin'], 'initdb')
pgdata = self.options['pgdata-directory'] pgdata = self.options['pgdata-directory']
if not os.path.exists(pgdata): try:
try: subprocess.check_call([initdb_binary,
subprocess.check_call([initdb_binary, '-D', pgdata,
'-D', pgdata, '-A', 'ident',
'-A', 'ident', '-E', 'UTF8',
'-E', 'UTF8', ])
]) except subprocess.CalledProcessError:
except subprocess.CalledProcessError: raise UserError('Could not create cluster directory in %s' % pgdata)
raise UserError('Could not create cluster directory in %s' % pgdata)
def createConfig(self): def createConfig(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment