diff --git a/actions/pagekite b/actions/pagekite index 56b692a86..e1a974c8e 100755 --- a/actions/pagekite +++ b/actions/pagekite @@ -54,6 +54,7 @@ def parse_arguments(): subparsers.add_parser('is-running', help='Get whether PakeKite is running') subparsers.add_parser('start-and-enable', help='Enable PageKite service') subparsers.add_parser('stop-and-disable', help='Disable PageKite service') + subparsers.add_parser('restart', help='Restart PageKite service') # Frontend subparsers.add_parser('get-frontend', help='Get pagekite frontend') @@ -95,6 +96,12 @@ def subcommand_is_running(_): print 'yes' if util.service_is_running('pagekite') else 'no' +def subcommand_restart(_): + """Restart the pagekite service""" + _service('restart') + print 'restarted' + + def subcommand_start_and_enable(_): aug.remove(PATHS['abort_not_configured']) aug.save() diff --git a/plinth/modules/pagekite/forms.py b/plinth/modules/pagekite/forms.py index 1228b9d5e..6407a2934 100644 --- a/plinth/modules/pagekite/forms.py +++ b/plinth/modules/pagekite/forms.py @@ -70,15 +70,18 @@ for your account if no secret is set on the kite')) if old != new: + config_changed = False if old['kite_name'] != new['kite_name'] or \ old['kite_secret'] != new['kite_secret']: _run(['set-kite', '--kite-name', new['kite_name'], '--kite-secret', new['kite_secret']]) messages.success(request, _('Kite details set')) + config_changed = True if old['server'] != new['server']: _run(['set-frontend', new['server']]) messages.success(request, _('Pagekite server set')) + config_changed = True if old['enabled'] != new['enabled']: if new['enabled']: @@ -88,6 +91,11 @@ for your account if no secret is set on the kite')) _run(['stop-and-disable']) messages.success(request, _('PageKite disabled')) + # Restart the service if the config was changed while the service + # was running, so the changes take effect. + elif config_changed and new['enabled']: + _run(['restart']) + class DefaultServiceForm(forms.Form): """Creates a form out of PREDEFINED_SERVICES"""