diff --git a/actions/pagekite b/actions/pagekite index b2d27a381..c913857c5 100755 --- a/actions/pagekite +++ b/actions/pagekite @@ -49,15 +49,18 @@ def parse_arguments(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') - # Start/Stop PageKite - subparsers.add_parser('start', help='Start PageKite service') - subparsers.add_parser('stop', help='Stop PageKite service') + # Start/Stop/Restart PageKite service daemon + # it's called daemon to avoid confusing it with pagekite services + daemon = subparsers.add_parser('daemon', + help='start/stop/restart PageKite') + daemon.add_argument('action', choices=['start', 'stop', 'restart']) - # Get/set status + # Enable/disable the pagekite service subparsers.add_parser('is-enabled', help='Get whether PakeKite is enabled') subparsers.add_parser('enable', help='Enable PageKite service') subparsers.add_parser('disable', help='Disable PageKite service') + # get/set using the default pagekite.net frontend subparsers.add_parser('get-pagekitenet-frontend-status', help='Get whether pagekite.net frontend is enabled') @@ -81,32 +84,28 @@ def parse_arguments(): help='Name of the kite (eg: mybox.pagekite.me)') set_kite.add_argument('--kite-secret', help='Secret for the kite') - # Services + # Add/remove pagekite services (service_on entries) subparsers.add_parser('get-services', help='Get list of enabled services') add_service = subparsers.add_parser('add-service', help='Add a pagekite service') - add_service.add_argument('--service', help='":"-separated service \ - parameters') + add_service.add_argument('--service', help='":"-separated service string') remove_service = subparsers.add_parser('remove-service', help='Remove a pagekite service') remove_service.add_argument('--service', help='":"-separated service \ - parameters') + string') return parser.parse_args() -def subcommand_start(_): - """Start PageKite service""" - status = subprocess.call(['service', 'pagekite', 'start']) - if status: - raise Exception('Unable to start PageKite server') +def subcommand_daemon(arguments): + """Start/stop/restart the pagekite daemon""" + _daemon(arguments.action) -def subcommand_stop(_): - """Stop PageKite service""" - status = subprocess.call(['service', 'pagekite', 'stop']) - if status: - raise Exception('Unable to stop PageKite server') +def _daemon(action): + error = subprocess.call(['service', 'pagekite', action]) + if error: + raise Exception('Unable to %s PageKite server' % action) def subcommand_is_enabled(_): @@ -206,6 +205,7 @@ def subcommand_remove_service(arguments): file.writelines(lines) # abort to only allow deleting one service break + _daemon('restart') def get_existing_service_paths(service): @@ -232,6 +232,7 @@ def subcommand_add_service(arguments): with open(path, 'a') as servicefile: line = "\nservice_on = %s\n" % convert_service_to_string(service) servicefile.write(line) + _daemon('restart') def convert_augeas_path_to_filepath(augpath, prefix='/files', diff --git a/plinth/modules/pagekite/forms.py b/plinth/modules/pagekite/forms.py index c4b8d54a9..2cd7ad7e9 100644 --- a/plinth/modules/pagekite/forms.py +++ b/plinth/modules/pagekite/forms.py @@ -69,7 +69,7 @@ for your account if no secret is set on the kite')) LOGGER.info('New status is - %s', new) if old != new: - _run(['stop']) + _run(['daemon', 'stop']) if old['enabled'] != new['enabled']: if new['enabled']: @@ -94,7 +94,7 @@ for your account if no secret is set on the kite')) messages.success(request, _('Pagekite server set')) if old != new: - _run(['start']) + _run(['daemon', 'start']) class DefaultServiceForm(forms.Form): @@ -167,7 +167,9 @@ class CustomServiceForm(forms.Form): def save(self, request): service = self.convert_form_data_to_service_string(self.cleaned_data) _run(['add-service', '--service', service]) + messages.success(request, _('Added custom service')) def delete(self, request): service = self.convert_form_data_to_service_string(self.cleaned_data) _run(['remove-service', '--service', service]) + messages.success(request, _('Deleted custom service')) diff --git a/plinth/modules/pagekite/templates/pagekite_custom_services.html b/plinth/modules/pagekite/templates/pagekite_custom_services.html index ee0ff9ca3..6f41e5f97 100644 --- a/plinth/modules/pagekite/templates/pagekite_custom_services.html +++ b/plinth/modules/pagekite/templates/pagekite_custom_services.html @@ -41,6 +41,11 @@ {% block content %}
Exposing services makes them accessible and attackable from the evil - internet. Be cautious!
+ internet.+
Exposing SSH with the default password for 'fbx' is a very bad idea.
+