#!/usr/bin/python
import sys
import os
import subprocess

def main(args):
  contents = args[2]
  hostname = os.environ['REMOTE_HOST'].lower()
  f = file('/etc/conserver/conf.d/'+hostname, 'w')
  f.write(contents)
  f.close()
  p = subprocess.Popen(['/etc/init.d/conserver-server', 'reload'],
                       stdout=subprocess.PIPE)
  p.wait()
  return 0

if __name__ == '__main__':
  sys.exit(main(sys.argv))
