mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
ttrss: Add basic configuration
This commit is contained in:
parent
15591b79ca
commit
47a54fadd1
@ -22,29 +22,64 @@ Configuration helper for Tiny Tiny RSS.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import augeas
|
||||||
|
|
||||||
from plinth import action_utils
|
from plinth import action_utils
|
||||||
|
|
||||||
|
CONFIG_FILE = '/etc/tt-rss/config.php'
|
||||||
|
DEFAULT_FILE = '/etc/default/tt-rss'
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
"""Return parsed command line arguments as dictionary."""
|
"""Return parsed command line arguments as dictionary."""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||||
|
|
||||||
|
subparsers.add_parser('setup', help='Setup Tiny Tiny RSS configuration')
|
||||||
subparsers.add_parser('enable', help='Enable Tiny Tiny RSS site')
|
subparsers.add_parser('enable', help='Enable Tiny Tiny RSS site')
|
||||||
subparsers.add_parser('disable', help='Disable Tiny Tiny RSS site')
|
subparsers.add_parser('disable', help='Disable Tiny Tiny RSS site')
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_setup(_):
|
||||||
|
"""Setup Tiny Tiny RSS configuration."""
|
||||||
|
aug = load_augeas()
|
||||||
|
|
||||||
|
aug.set('/files' + DEFAULT_FILE + '/DISABLED', '0')
|
||||||
|
|
||||||
|
for match in aug.match('/files' + CONFIG_FILE + '/define'):
|
||||||
|
if aug.get(match) == 'SELF_URL_PATH':
|
||||||
|
aug.set(match + '/value', "'http://localhost/tt-rss/'")
|
||||||
|
|
||||||
|
aug.save()
|
||||||
|
|
||||||
|
action_utils.service_restart('tt-rss')
|
||||||
|
action_utils.webserver_enable('50-tt-rss')
|
||||||
|
|
||||||
|
|
||||||
def subcommand_enable(_):
|
def subcommand_enable(_):
|
||||||
"""Enable web configuration and reload."""
|
"""Enable web configuration and reload."""
|
||||||
|
action_utils.service_enable('tt-rss')
|
||||||
action_utils.webserver_enable('50-tt-rss')
|
action_utils.webserver_enable('50-tt-rss')
|
||||||
|
|
||||||
|
|
||||||
def subcommand_disable(_):
|
def subcommand_disable(_):
|
||||||
"""Disable web configuration and reload."""
|
"""Disable web configuration and reload."""
|
||||||
action_utils.webserver_disable('50-tt-rss')
|
action_utils.webserver_disable('50-tt-rss')
|
||||||
|
action_utils.service_disable('tt-rss')
|
||||||
|
|
||||||
|
|
||||||
|
def load_augeas():
|
||||||
|
"""Initialize Augeas."""
|
||||||
|
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||||
|
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||||
|
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||||
|
aug.set('/augeas/load/Shellvars/incl[last() + 1]', DEFAULT_FILE)
|
||||||
|
aug.set('/augeas/load/Phpvars/lens', 'Phpvars.lns')
|
||||||
|
aug.set('/augeas/load/Phpvars/incl[last() + 1]', CONFIG_FILE)
|
||||||
|
aug.load()
|
||||||
|
return aug
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@ -58,13 +58,15 @@ def init():
|
|||||||
|
|
||||||
def setup(helper, old_version=None):
|
def setup(helper, old_version=None):
|
||||||
"""Install and configure the module."""
|
"""Install and configure the module."""
|
||||||
helper.install(['tt-rss'])
|
helper.install(['tt-rss', 'postgresql', 'dbconfig-pgsql', 'php5-pgsql'])
|
||||||
|
helper.call('post', actions.superuser_run, 'ttrss', ['setup'])
|
||||||
helper.call('post', service.notify_enabled, None, True)
|
helper.call('post', service.notify_enabled, None, True)
|
||||||
|
|
||||||
|
|
||||||
def get_status():
|
def get_status():
|
||||||
"""Get the current settings."""
|
"""Get the current settings."""
|
||||||
return {'enabled': is_enabled()}
|
return {'enabled': is_enabled(),
|
||||||
|
'is_running': is_running()}
|
||||||
|
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
@ -72,6 +74,11 @@ def is_enabled():
|
|||||||
return action_utils.webserver_is_enabled('50-tt-rss')
|
return action_utils.webserver_is_enabled('50-tt-rss')
|
||||||
|
|
||||||
|
|
||||||
|
def is_running():
|
||||||
|
"""Return whether the service is running."""
|
||||||
|
return action_utils.service_is_running('tt-rss')
|
||||||
|
|
||||||
|
|
||||||
def enable(should_enable):
|
def enable(should_enable):
|
||||||
"""Enable/disable the module."""
|
"""Enable/disable the module."""
|
||||||
sub_command = 'enable' if should_enable else 'disable'
|
sub_command = 'enable' if should_enable else 'disable'
|
||||||
|
|||||||
@ -23,6 +23,18 @@
|
|||||||
|
|
||||||
{% block configuration %}
|
{% block configuration %}
|
||||||
|
|
||||||
|
<h3>{% trans "Status" %}</h3>
|
||||||
|
|
||||||
|
<p class="running-status-parent">
|
||||||
|
{% if status.is_running %}
|
||||||
|
<span class="running-status active"></span>
|
||||||
|
{% trans "Tiny Tiny RSS feed update service is running" %}
|
||||||
|
{% else %}
|
||||||
|
<span class="running-status inactive"></span>
|
||||||
|
{% trans "Tiny Tiny RSS feed update service is not running" %}
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
|
||||||
{% include "diagnostics_button.html" with module="ttrss" %}
|
{% include "diagnostics_button.html" with module="ttrss" %}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user