mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Data types for cfg.py; add danube_edition entry
- Explicitly state datatype in config_items to handle them more generically - Handle boolean values correctly. Before this fix we got the string 'False' which evaluated to True (this affected the entry 'use_x_forwarded_host'). - Add the config entry 'danube_edition'. Activating it shows a voucher input field for pagekite accounts on freedombox.me during the firstboot process. Other vouchers (i.e. for VPN services) might follow. Add description and test for 'danube_edition' setting.
This commit is contained in:
parent
4a9d877724
commit
3d87c3eb3b
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user