diff --git a/contrib/dokku-installer.py b/contrib/dokku-installer.py index 99e297f24..b09e961d5 100755 --- a/contrib/dokku-installer.py +++ b/contrib/dokku-installer.py @@ -4,6 +4,7 @@ import cgi import json import os import re +import shutil try: import SimpleHTTPServer import SocketServer @@ -143,20 +144,31 @@ class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): 'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': self.headers['Content-Type']}) - vhost_enable = 'false' dokku_root = os.getenv('DOKKU_ROOT', '/home/dokku') + dokku_user = os.getenv('DOKKU_SYSTEM_GROUP', 'dokku') + dokku_group = os.getenv('DOKKU_SYSTEM_USER', 'dokku') + + vhost_enable = 'false' + vhost_filename = '{0}/VHOST'.format(dokku_root) + if 'vhost' in params and params['vhost'].value == 'true': vhost_enable = 'true' - with open('{0}/VHOST'.format(dokku_root), 'w') as f: + with open(vhost_filename, 'w') as f: f.write(params['hostname'].value) + shutil.chown(vhost_filename, dokku_user, dokku_group) else: try: - os.remove('{0}/VHOST'.format(dokku_root)) + os.remove(vhost_filename) except OSError: pass - with open('{0}/HOSTNAME'.format(dokku_root), 'w') as f: + + hostname_filename = '{0}/HOSTNAME'.format(dokku_root) + + with open(hostname_filename, 'w') as f: f.write(params['hostname'].value) + shutil.chown(hostname_filename, dokku_user, dokku_group) + for (index, key) in enumerate(params['keys'].value.splitlines(), 1): user = 'admin' if self.admin_user_exists() is not None: