summaryrefslogtreecommitdiffstats
path: root/archives/publik-move/update-config-pck.py
blob: 4f48c7b85c7f73a0f36b50dd97bd29c42f43a445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python2
import pickle
import sys

wcs_password = open('/srv/nfs/etc/wcs/password').read().strip()

def adapt_wcs(path, dbname, dbmaster='prod.saas.entrouvert.org.clusters.entrouvert.org'):
    dbname = dbname.strip()
    with open(path, 'rb') as fh:
        cf = pickle.load(fh)
        if not 'postgresql' in cf:
            print('%s not a postgresql instance' % path)
        cf['postgresql']['host'] = dbmaster
        cf['postgresql']['port'] = '5432'
        cf['postgresql']['user'] = 'wcs'
        cf['postgresql']['password'] = wcs_password
        cf['postgresql']['database'] = dbname

    with open(path, 'wb') as fh:
        pickle.dump(cf, fh)

adapt_wcs(sys.argv[1], sys.argv[2])