diff --git a/HACKING b/HACKING index 6dcc5321d..fd7d461ed 100644 --- a/HACKING +++ b/HACKING @@ -18,23 +18,19 @@ 2. Plinth also support running without installing (as much as possible). Simply run it as: - $ sudo python -m plinth --no-daemon --debug + $ sudo ./run --no-daemon --debug In this mode, Plinth runs in working directory without need for - installation. It uses a different config file (plinth.conf in working - directory) instead of the regular config file (/etc/plinth/plinth.conf). It - creates all that data and runtime files in data/var/*. To make Plinth - pickup the config file in working directory, simply delete - /etc/plinth/plinth.config. + installation. It uses the plinth.conf config file in the working + directory if no regular config file (/etc/plinth/plinth.conf) is found. + It creates all that data and runtime files in data/var/*. *Note:* This mode is supported only in a limited manner. The following are the unknown issues with it: - 1. It does not work without the --debug and --no-daemon flags. + 1. Help pages are also not built. Run 'make -C doc' manaully. - 2. Help pages are also not built. Run 'make -C doc' manaully. - - 3. Actions do not work when running as normal user without 'sudo' prefix. + 2. Actions do not work when running as normal user without 'sudo' prefix. You need to add 'actions' directory to be allowed for 'sudo' commands. See data/etc/sudoers.d/plinth for a hint. diff --git a/bin/plinth b/bin/plinth old mode 100644 new mode 100755 diff --git a/plinth/__main__.py b/plinth/__main__.py index 0afabe998..c287edc3e 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -99,7 +99,8 @@ def setup_server(): # our modules to Django apps instead of reinventing the wheel. # (we'll still have to serve the static files with cherrypy though) for module in module_loader.LOADED_MODULES: - static_dir = os.path.join(cfg.file_root, 'modules', module, 'static') + static_dir = os.path.join(cfg.file_root, 'plinth', 'modules', module, + 'static') if not os.path.isdir(static_dir): continue diff --git a/plinth/modules/config/config.py b/plinth/modules/config/config.py index 602a977c9..c7691332e 100644 --- a/plinth/modules/config/config.py +++ b/plinth/modules/config/config.py @@ -136,7 +136,7 @@ def _apply_changes(request, old_status, new_status): set_hostname(new_status['hostname']) except Exception as exception: messages.error(request, _('Error setting hostname: %s') % - str(exception)) + exception) else: messages.success(request, _('Hostname set')) else: @@ -147,7 +147,7 @@ def _apply_changes(request, old_status, new_status): actions.superuser_run('timezone-change', [new_status['time_zone']]) except Exception as exception: messages.error(request, _('Error setting time zone: %s') % - str(exception)) + exception) else: messages.success(request, _('Time zone set')) else: diff --git a/plinth/modules/expert_mode/expert_mode.py b/plinth/modules/expert_mode/expert_mode.py index b55992fa9..f7c40939c 100644 --- a/plinth/modules/expert_mode/expert_mode.py +++ b/plinth/modules/expert_mode/expert_mode.py @@ -5,7 +5,7 @@ from django.template.response import TemplateResponse from gettext import gettext as _ from plinth import cfg -from plinth.modules.lib.auth import get_group +from plinth.modules.lib.auth import get_or_create_group class ExpertsForm(forms.Form): # pylint: disable-msg=W0232 @@ -51,7 +51,7 @@ def _apply_changes(request, new_status): """Apply expert mode configuration""" message = (messages.info, _('Settings unchanged')) - expert_group = get_group('Expert') + expert_group = get_or_create_group('Expert') if new_status['expert_mode']: if not expert_group in request.user.groups.all(): request.user.groups.add(expert_group) diff --git a/plinth/modules/lib/auth.py b/plinth/modules/lib/auth.py index 0ff7bb82b..7b4c19ed2 100644 --- a/plinth/modules/lib/auth.py +++ b/plinth/modules/lib/auth.py @@ -15,10 +15,10 @@ def add_user(username, passphrase, name='', email='', expert=False): user.save() if expert: - user.groups.add(get_group('Expert')) + user.groups.add(get_or_create_group('Expert')) -def get_group(name): +def get_or_create_group(name): """Return an existing or newly created group with given name""" try: group = Group.objects.get(name__exact=name) diff --git a/run b/run new file mode 100755 index 000000000..03bbcbe9a --- /dev/null +++ b/run @@ -0,0 +1,21 @@ +#!/usr/bin/python +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +import plinth.__main__ + +plinth.__main__.main()