mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
rssbridge: Completely uninstall app
* make ENABLE_LIST a constant and declare PUBLIC_ACCESS_FILE with pathlib.Path() * add PUBLIC_ACCESS_FILE to the backup manifest * Remove PUBLIC_ACCESS_FILE and ENABLE_LIST Tests: 1. Install the app and enable public access 2. Reinstall the app and confirm the public access is reset to default 3. Functional tests passed Signed-off-by: nbenedek <contact@nbenedek.me> [sunil: Update docstrings, make uninstall fail-safe] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
f11074ab9d
commit
17e062e829
@ -88,3 +88,8 @@ class RSSBridgeApp(app_module.App):
|
|||||||
super().setup(old_version)
|
super().setup(old_version)
|
||||||
privileged.setup()
|
privileged.setup()
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
|
def uninstall(self):
|
||||||
|
"""De-configure and uninstall the app."""
|
||||||
|
super().uninstall()
|
||||||
|
privileged.uninstall()
|
||||||
|
|||||||
@ -14,4 +14,8 @@ clients = [{
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
backup = {}
|
backup = {
|
||||||
|
'data': {
|
||||||
|
'files': ['/etc/rss-bridge/is_public']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -2,32 +2,38 @@
|
|||||||
"""Configure RSS-Bridge."""
|
"""Configure RSS-Bridge."""
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
from plinth import action_utils
|
|
||||||
|
|
||||||
|
from plinth import action_utils
|
||||||
from plinth.actions import privileged
|
from plinth.actions import privileged
|
||||||
|
|
||||||
PUBLIC_ACCESS_FILE = '/etc/rss-bridge/is_public'
|
PUBLIC_ACCESS_FILE = pathlib.Path('/etc/rss-bridge/is_public')
|
||||||
|
ENABLE_LIST = pathlib.Path('/etc/rss-bridge/whitelist.txt')
|
||||||
|
|
||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def setup():
|
def setup():
|
||||||
"""Configure RSS-Bridge by enable all bridges."""
|
"""Configure RSS-Bridge by enable all bridges."""
|
||||||
enable_list = pathlib.Path('/etc/rss-bridge/whitelist.txt')
|
ENABLE_LIST.write_text('*\n', encoding='utf-8')
|
||||||
enable_list.write_text('*\n', encoding='utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def set_public(enable: bool):
|
def set_public(enable: bool):
|
||||||
"""Allow/disallow public access."""
|
"""Allow/disallow public access."""
|
||||||
public_access_file = pathlib.Path(PUBLIC_ACCESS_FILE)
|
|
||||||
if enable:
|
if enable:
|
||||||
public_access_file.touch()
|
PUBLIC_ACCESS_FILE.touch()
|
||||||
else:
|
else:
|
||||||
public_access_file.unlink(missing_ok=True)
|
PUBLIC_ACCESS_FILE.unlink(missing_ok=True)
|
||||||
|
|
||||||
action_utils.service_reload('apache2')
|
action_utils.service_reload('apache2')
|
||||||
|
|
||||||
|
|
||||||
def is_public() -> bool:
|
def is_public() -> bool:
|
||||||
"""Return whether public access is enabled."""
|
"""Return whether public access is enabled."""
|
||||||
return pathlib.Path(PUBLIC_ACCESS_FILE).exists()
|
return PUBLIC_ACCESS_FILE.exists()
|
||||||
|
|
||||||
|
|
||||||
|
@privileged
|
||||||
|
def uninstall():
|
||||||
|
"""Remove config files when app is uninstalled."""
|
||||||
|
for path in PUBLIC_ACCESS_FILE, ENABLE_LIST:
|
||||||
|
path.unlink(missing_ok=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user