moved into main repo for pisi 2.0
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
|
||||
def postInstall(fromVersion, fromRelease, toVersion, toRelease):
|
||||
os.system("/bin/chown -R postgres:postgres /var/lib/postgresql")
|
||||
os.system("/bin/chmod -R 0700 /var/lib/postgresql/data")
|
||||
os.system("/bin/chmod -R 0700 /var/lib/postgresql/backups")
|
||||
|
||||
# On first install...
|
||||
if not os.path.exists("/var/lib/postgresql/data/base"):
|
||||
for i in ["LANG", "LANGUAGE", "LC_ALL"]:
|
||||
os.environ[i] = "en_US.UTF-8"
|
||||
|
||||
os.system('/bin/su postgres -s /bin/sh -p -c "/usr/bin/initdb --pgdata /var/lib/postgresql/data"')
|
||||
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from comar.service import *
|
||||
|
||||
serviceType="server"
|
||||
|
||||
serviceDesc = _({"en": "PostgreSQL Database Server",
|
||||
"tr": "PostgreSQL Veritabanı Sunucusu"})
|
||||
|
||||
serviceConf = "postgresql"
|
||||
|
||||
MSG_ERR_PGSQLNOTINST = _({"en": "PostgreSQL is not configured properly, please re-install the package.",
|
||||
"tr": "PostgreSQL düzgün yapılandırılmamış, lütfen paketi tekrar yükleyin.",
|
||||
})
|
||||
|
||||
def check_postgresql():
|
||||
import os
|
||||
if not os.path.exists(config.get("PGDATA", "/var/lib/postgresql/data")):
|
||||
fail(MSG_ERR_PGSQLNOTINST)
|
||||
|
||||
PIDFILE = "%s/postmaster.pid" % config.get("PGDATA", "/var/lib/postgresql/data")
|
||||
|
||||
@synchronized
|
||||
def start():
|
||||
check_postgresql()
|
||||
startService(command="/usr/bin/pg_ctl",
|
||||
args=["start", "-D", config.get("PGDATA", "/var/lib/postgresql/data"), "-l", config.get("PGLOG", "/var/lib/postgresql/data/postgresql.log"), "-o", config.get("PGOPTS", "")],
|
||||
pidfile=PIDFILE,
|
||||
chuid=config.get("PGUSER", "postgres"),
|
||||
donotify=True)
|
||||
|
||||
@synchronized
|
||||
def stop():
|
||||
stopService(command="/usr/bin/pg_ctl",
|
||||
args=["stop", "-D", config.get("PGDATA", "/var/lib/postgresql/data"), "-s", "-m", "fast"],
|
||||
chuid=config.get("PGUSER", "postgres"),
|
||||
donotify=True)
|
||||
|
||||
def reload():
|
||||
stopService(command="/usr/bin/pg_ctl",
|
||||
args=["reload", "-D", config.get("PGDATA", "/var/lib/postgresql/data"), "-s"],
|
||||
donotify=True)
|
||||
|
||||
def status():
|
||||
return isServiceRunning(PIDFILE)
|
||||
Reference in New Issue
Block a user