postoperations.py 534 B

12345678910111213141516
  1. #!/usr/bin/env python3
  2. import os
  3. def postInstall():
  4. os.system("/bin/chown -R postgres:postgres /var/lib/postgresql")
  5. os.system("/bin/chmod -R 0700 /var/lib/postgresql/data")
  6. os.system("/bin/chmod -R 0700 /var/lib/postgresql/backups")
  7. # On first install...
  8. if not os.path.exists("/var/lib/postgresql/data/base"):
  9. for i in ["LANG", "LANGUAGE", "LC_ALL"]:
  10. os.environ[i] = "en_US.UTF-8"
  11. os.system('/bin/su postgres -s /bin/sh -p -c "/usr/bin/initdb --pgdata /var/lib/postgresql/data"')