deluge: Run setup and enable after install.

This commit is contained in:
James Valleroy 2015-06-07 13:00:53 -04:00 committed by Sunil Mohan Adapa
parent 9c717246ee
commit fd73bcd734
2 changed files with 17 additions and 3 deletions

View File

@ -55,6 +55,9 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
# Setup deluge-web
subparsers.add_parser('setup', help='Perform first time setup operations.')
# Get whether deluge-web site is enabled
subparsers.add_parser('get-enabled',
help='Get whether deluge-web site is enabled')
@ -72,6 +75,14 @@ def parse_arguments():
return parser.parse_args()
def subcommand_setup(_):
"""Perform first time setup operations."""
setup()
start()
subprocess.check_call(['a2enconf', 'deluge-plinth'])
subprocess.check_call(['service', 'apache2', 'reload'])
def subcommand_get_enabled(_):
"""Get whether deluge-web site is enabled."""
if os.path.isfile(APACHE_CONF_ENABLED_PATH) and \
@ -83,8 +94,6 @@ def subcommand_get_enabled(_):
def subcommand_enable(_):
"""Enable deluge-web site and start deluge-web."""
setup()
start()
subprocess.check_call(['a2enconf', 'deluge-plinth'])
subprocess.check_call(['service', 'apache2', 'reload'])

View File

@ -29,8 +29,13 @@ from plinth import actions
from plinth import package
def on_install():
"""Setup deluge-web on install."""
actions.superuser_run('deluge', ['setup'])
@login_required
@package.required(['deluged', 'deluge-web'])
@package.required(['deluged', 'deluge-web'], on_install=on_install)
def index(request):
"""Serve configuration page."""
status = get_status()