~charmers/charms/trusty/shoutcast/trunk

« back to all changes in this revision

Viewing changes to hooks/config-changed

  • Committer: Charles Butler
  • Date: 2014-09-25 06:27:11 UTC
  • Revision ID: chuck@dasroot.net-20140925062711-wbbo073x3c4ixsw7
Adds relay support  through relations of scsource and screlay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        return
53
53
 
54
54
    with open(CONFIG_PATH, 'w') as f:
 
55
        relaycfg = am_i_a_relay()
 
56
        if relaycfg:
 
57
          config['screlayhost'] = relaycfg[0]
 
58
          config['screlayport'] = relaycfg[1]
55
59
        f.write(render(os.path.basename(CONFIG_PATH), config))
56
60
 
57
61
    chown_recursive(user.pw_uid, user.pw_gid)
61
65
    if not os.path.exists('/etc/init/shoutcast.conf'):
62
66
      shutil.copy('templates/shoutcast.conf', '/etc/init/shoutcast.conf')
63
67
 
 
68
def am_i_a_relay():
 
69
  # try to be clever, and append to the config dict if we have a relation
 
70
  relaycache = os.path.join(os.environ['CHARM_DIR'], '.relay')
 
71
  if os.path.exists(relaycache):
 
72
    with open(relaycache, 'r') as f:
 
73
      cache = f.readlines()
 
74
      return cache
 
75
 
64
76
 
65
77
def chown_recursive(uid, gid):
66
78
  for root, dirs, files in os.walk(INSTALL_DIR):