diff --git a/usr/lib/python3.6/vmmgr/__init__.py b/usr/lib/python3.6/vmmgr/__init__.py index d6b1647..884429a 100644 --- a/usr/lib/python3.6/vmmgr/__init__.py +++ b/usr/lib/python3.6/vmmgr/__init__.py @@ -214,10 +214,6 @@ class VMMgr: self.domain = self.conf['host']['domain'] = domain self.port = self.conf['host']['port'] = port self.conf.save() - # Restart all apps to trigger configuration refresh - for app in self.conf['apps'].copy(): - if tools.is_service_started(app): - tools.restart_service(app) # Rebuild and restart nginx if it was requested. self.rebuild_nginx() diff --git a/usr/lib/python3.6/vmmgr/tools.py b/usr/lib/python3.6/vmmgr/tools.py index d309449..d4e8ca8 100644 --- a/usr/lib/python3.6/vmmgr/tools.py +++ b/usr/lib/python3.6/vmmgr/tools.py @@ -86,14 +86,11 @@ def start_service(service): def stop_service(service): subprocess.run(['/sbin/service', service, 'stop'], check=True) -def restart_service(service): - subprocess.run(['/sbin/service', service, 'restart']) - def reload_nginx(): subprocess.run(['/usr/sbin/nginx', '-s', 'reload']) def restart_nginx(): - restart_service('nginx') + restart_service(['/sbin/service', 'nginx', 'restart']) def get_cert_info(cert): # Gather certificate data important for setup-host diff --git a/usr/lib/python3.6/vmmgr/wsgiapp.py b/usr/lib/python3.6/vmmgr/wsgiapp.py index 8e0466f..88321b4 100644 --- a/usr/lib/python3.6/vmmgr/wsgiapp.py +++ b/usr/lib/python3.6/vmmgr/wsgiapp.py @@ -90,6 +90,7 @@ class WSGIApp(object): response.status_code = 404 return response except HTTPException as e: + # Return MethodNotAllowed or RequestRedirect as they are return e def render_template(self, template_name, request, **context): @@ -118,7 +119,7 @@ class WSGIApp(object): return message.split(':', 3) def login_view(self, request, **kwargs): - redir = request.args.get('redir') + redir = request.args.get('redir', '') message = self.get_session_message(request) return self.render_html('login.html', request, redir=redir, message=message) @@ -231,8 +232,10 @@ class WSGIApp(object): domain = request.form['domain'] port = request.form['port'] self.vmmgr.update_host(domain, port) - server_name = request.environ['HTTP_X_FORWARDED_SERVER_NAME'] - url = '{}/setup-host'.format(tools.compile_url(server_name, port)) + ip = tools.get_local_ip(4) + if not ip: + ip = tools.get_local_ip(6) + url = '{}/setup-host'.format(tools.compile_url(ip, port)) response = self.render_json({'ok': request.session.lang.host_updated(url, url)}) response.call_on_close(tools.restart_nginx) return response @@ -411,6 +414,3 @@ class WSGIApp(object): def is_app_visible(self, app): return app in self.conf['apps'] and self.conf['apps'][app]['visible'] and tools.is_service_started(app) - -class InvalidRecordException(Exception): - pass diff --git a/usr/share/vmmgr/static/js/admin.js b/usr/share/vmmgr/static/js/admin.js index 1f91b4f..c20d5f6 100644 --- a/usr/share/vmmgr/static/js/admin.js +++ b/usr/share/vmmgr/static/js/admin.js @@ -27,9 +27,7 @@ $(function() { function update_host() { $('#host-submit').hide(); $('#host-message').hide(); - $('#host-wait').show(); $.post('/update-host', {'domain': $('#domain').val(), 'port': $('#port').val()}, function(data) { - $('#host-wait').hide(); if (data.error) { $('#host-message').attr('class','error').html(data.error).show(); $('#host-submit').show(); diff --git a/usr/share/vmmgr/templates/setup-host.html b/usr/share/vmmgr/templates/setup-host.html index 055efbc..eab37bb 100644 --- a/usr/share/vmmgr/templates/setup-host.html +++ b/usr/share/vmmgr/templates/setup-host.html @@ -21,10 +21,6 @@
-
-
- Provádí se změna nastavení, prosím čekejte... -