mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
syncthing: Extend setup process to recover from manual config errors
There are configuration items that users of syncthing can accidentally set, resulting in the UI becoming unavailable. Previously, if such a thing happened, the FreedomBox admin would have to ssh into the server and edit the xml manually or reinstall/restore the app. With this patch, it is enough to re-run the setup to make the UI accesible again. - Remove http basic authentication from the settings (gui/user and gui/password. This is unnecessary as FreedomBox already provides authentication. - Make sure these options are properly set: - 'Use HTTPS for GUI' is off - 'GUI Listen Address' is 127.0.0.1:8384 - GUI is enabled There is a forum discussion that inspired these changes: https://discuss.freedombox.org/t/solved-cant-access-syncthing-administration-panel/2137 Tests done: - Fresh install: after the setup, confirm the UI is working properly and the xml is configured with the expected values. - Make the changes to break the Syncthing UI, then re-run setup. Confirm the UI is back online. Signed-off-by: Benedek Nagy <contact@nbenedek.me> [sunil: Initialize conf_changed variable to prevent failures accessing it] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
0df112a006
commit
f4f417cbb6
@ -73,16 +73,35 @@ def setup_config():
|
|||||||
|
|
||||||
# disable authentication missing notification as FreedomBox itself
|
# disable authentication missing notification as FreedomBox itself
|
||||||
# provides authentication
|
# provides authentication
|
||||||
auth_conf = ('/configuration/options/unackedNotificationID'
|
# also make sure no authentication is required on top of FreedomBox's
|
||||||
'[#text="authenticationUserAndPassword"]')
|
configs_to_remove = (
|
||||||
conf_changed = bool(aug.remove('/files' + conf_file_in_use + auth_conf))
|
'options/unackedNotificationID[#text="authenticationUserAndPassword"]',
|
||||||
|
'gui/user/#text', 'gui/password/#text')
|
||||||
|
conf_changed = False
|
||||||
|
for config in configs_to_remove:
|
||||||
|
removed = bool(
|
||||||
|
aug.remove('/files' + conf_file_in_use +
|
||||||
|
f'/configuration/{config}'))
|
||||||
|
if removed:
|
||||||
|
conf_changed = True
|
||||||
|
|
||||||
# disable usage reporting notification by declining reporting
|
configs = {
|
||||||
# if the user has not made a choice yet
|
# disable usage reporting notification by declining reporting
|
||||||
usage_conf = '/configuration/options/urAccepted/#text'
|
# if the user has not made a choice yet
|
||||||
if aug.get('/files' + conf_file_in_use + usage_conf) == '0':
|
'options/urAccepted/#text': '-1',
|
||||||
aug.set('/files' + conf_file_in_use + usage_conf, '-1')
|
# Set all the values that, misconfigured from the Syncthing UI,
|
||||||
conf_changed = True
|
# can make the UI inaccessible. Such misconfigurations can be
|
||||||
|
# corrected if the user re-runs the setup.
|
||||||
|
# https://discuss.freedombox.org/t/solved-cant-access-syncthing-administration-panel/2137
|
||||||
|
'gui/#attribute/tls': 'false',
|
||||||
|
'gui/#attribute/enabled': 'true',
|
||||||
|
'gui/address/#text': '127.0.0.1:8384'
|
||||||
|
}
|
||||||
|
for key, value in configs.items():
|
||||||
|
config = f'/configuration/{key}'
|
||||||
|
if aug.get('/files' + conf_file_in_use + config) != value:
|
||||||
|
aug.set('/files' + conf_file_in_use + config, value)
|
||||||
|
conf_changed = True
|
||||||
|
|
||||||
aug.save()
|
aug.save()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user