diff --git a/plinth.config b/plinth.config index 1e001a7c3..0575578bd 100644 --- a/plinth.config +++ b/plinth.config @@ -37,3 +37,14 @@ port = 8000 # Leave the values blank to disable use_x_forwarded_host = True secure_proxy_ssl_header = HTTP_X_FORWARDED_PROTO + +[Misc] +# The danube_edition changes the firstboot process and offers entering a +# voucher for a freedombox.me sub-domain. This functionality requires +# additional debian packages to be installed: +# +# pagekite, python3-requests +# +# They are not added as dependencies to keep the normal installation images +# lean, but make sure to add them if you want to build danube-edition images. +danube_edition = False diff --git a/plinth/cfg.py b/plinth/cfg.py index 70d51e53c..af721ca95 100644 --- a/plinth/cfg.py +++ b/plinth/cfg.py @@ -39,6 +39,7 @@ secure_proxy_ssl_header = None debug = False no_daemon = False server_dir = '/' +danube_edition = False main_menu = Menu() @@ -66,32 +67,35 @@ def read(): }) parser.read(CONFIG_FILE) - config_items = {('Name', 'product_name'), - ('Name', 'box_name'), - ('Path', 'root'), - ('Path', 'file_root'), - ('Path', 'config_dir'), - ('Path', 'data_dir'), - ('Path', 'store_file'), - ('Path', 'actions_dir'), - ('Path', 'doc_dir'), - ('Path', 'status_log_file'), - ('Path', 'access_log_file'), - ('Path', 'pidfile'), - ('Path', 'server_dir'), - ('Network', 'host'), - ('Network', 'port'), - ('Network', 'secure_proxy_ssl_header'), - ('Network', 'use_x_forwarded_host')} + config_items = {('Name', 'product_name', 'string'), + ('Name', 'box_name', 'string'), + ('Path', 'root', 'string'), + ('Path', 'file_root', 'string'), + ('Path', 'config_dir', 'string'), + ('Path', 'data_dir', 'string'), + ('Path', 'store_file', 'string'), + ('Path', 'actions_dir', 'string'), + ('Path', 'doc_dir', 'string'), + ('Path', 'status_log_file', 'string'), + ('Path', 'access_log_file', 'string'), + ('Path', 'pidfile', 'string'), + ('Path', 'server_dir', 'string'), + ('Network', 'host', 'string'), + ('Network', 'port', 'int'), + ('Network', 'secure_proxy_ssl_header', 'string'), + ('Network', 'use_x_forwarded_host', 'bool'), + ('Misc', 'danube_edition', 'bool')} - for section, name in config_items: + for section, name, datatype in config_items: try: value = parser.get(section, name) - globals()[name] = value except (configparser.NoSectionError, configparser.NoOptionError): print('Configuration does not contain the {}.{} option.' .format(section, name)) raise - - global port # pylint: disable-msg=W0603 - port = int(port) + else: + if datatype == 'int': + value = int(value) + if datatype == 'bool': + value = value.lower() == 'true' + globals()[name] = value diff --git a/plinth/tests/test_cfg.py b/plinth/tests/test_cfg.py index e491a0a0b..869661453 100644 --- a/plinth/tests/test_cfg.py +++ b/plinth/tests/test_cfg.py @@ -223,7 +223,9 @@ class CfgTestCase(unittest.TestCase): self.assertEqual(parser.get('Network', 'secure_proxy_ssl_header'), cfg.secure_proxy_ssl_header) self.assertEqual(parser.get('Network', 'use_x_forwarded_host'), - cfg.use_x_forwarded_host) + str(cfg.use_x_forwarded_host)) + self.assertEqual(parser.get('Misc', 'danube_edition'), + str(cfg.danube_edition)) def read_temp_config_file(self, test_file): """Read the specified test configuration file."""