paskao
d84ef5909a
* Fixed credentials for OpenLDAP replication * Postfix binding on backends-backends ring * User UID like user@domain.org * Create default user for each backend * Fixed Postfix transport * Setup Dovecot proxy * Some fixes on frontends-backends ring * Removed iptables rule to force dns over tor * Add forgotten local_actions
46 lines
1.3 KiB
Python
Executable file
46 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python
|
|
import os
|
|
import argparse
|
|
import sys
|
|
|
|
|
|
BASE_DIR='generated_vars/openldap'
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description='Generate local vars for networking.')
|
|
parser.add_argument('replication', metavar='replication', type=str, help='the replication tag')
|
|
parser.add_argument('hostname', metavar='hostname', type=str, help='the hostname')
|
|
args = parser.parse_args()
|
|
|
|
REPLICATIOIN_DIR = os.path.join(BASE_DIR, args.replication)
|
|
HOST_PATH = os.path.join(REPLICATIOIN_DIR, args.hostname)
|
|
|
|
if not os.path.exists(REPLICATIOIN_DIR):
|
|
os.makedirs(REPLICATIOIN_DIR)
|
|
|
|
if os.path.exists(HOST_PATH):
|
|
with open(HOST_PATH, 'r') as f:
|
|
host_number = int(f.read())
|
|
print host_number
|
|
f.close()
|
|
sys.exit(0)
|
|
|
|
host_number = 0
|
|
defined_hosts = [f for f in os.listdir(REPLICATIOIN_DIR) if os.path.isfile(os.path.join(REPLICATIOIN_DIR, f))]
|
|
for host in defined_hosts:
|
|
with open(os.path.join(REPLICATIOIN_DIR, host), 'r') as f:
|
|
ip = int(f.read())
|
|
if ip > host_number:
|
|
host_number = ip
|
|
f.close()
|
|
|
|
host_number += 1
|
|
|
|
with open(HOST_PATH, 'w') as f:
|
|
f.write(str(host_number))
|
|
f.close()
|
|
print host_number
|
|
sys.exit(0)
|
|
|
|
|