1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-06-15 00:05:11 +02:00

Move data to the root directory, for simplification

This commit is contained in:
Tim Möhlmann
2018-11-21 12:30:35 +02:00
parent 436055f02c
commit e3a503a559
2 changed files with 10 additions and 10 deletions

View File

@ -27,18 +27,18 @@ def setup():
conn.close()
# Bootstrap the database if postgresql is running for the first time
if not os.path.exists('/var/lib/postgresql/data/pg_wal'):
os.system("chown -R postgres:postgres /var/lib/postgresql")
os.system("su - postgres -c 'initdb -D /var/lib/postgresql/data'")
if not os.path.exists('/data/pg_wal'):
os.system("chown -R postgres:postgres /data")
os.system("su - postgres -c 'initdb -D /data'")
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
for pg_file in glob.glob("/conf/*.conf"):
convert(pg_file, os.path.join("/var/lib/postgresql/data", os.path.basename(pg_file)))
convert(pg_file, os.path.join("/data", os.path.basename(pg_file)))
# Run postgresql locally for DB and user creation
os.system("su - postgres -c 'pg_ctl start -D /var/lib/postgresql/data -o \"-h localhost\"'")
os.system("su - postgres -c 'pg_ctl start -D /data -o \"-h localhost\"'")
setup()
os.system("su - postgres -c 'pg_ctl stop -m smart -w -D /var/lib/postgresql/data'")
os.system("su - postgres -c 'pg_ctl stop -m smart -w -D /data'")
# Run postgresql service
os.system("su - postgres -c 'postgres -D /var/lib/postgresql/data -h \*'")
os.system("su - postgres -c 'postgres -D /data -h \*'")