mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
upgrades: Use new setup mechanism
This commit is contained in:
parent
065d6c4c0a
commit
b5ccada3a6
@ -21,14 +21,32 @@ Plinth module for upgrades
|
|||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from plinth import actions
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
|
|
||||||
|
|
||||||
|
version = 1
|
||||||
|
|
||||||
|
is_essential = 1
|
||||||
|
|
||||||
depends = ['system']
|
depends = ['system']
|
||||||
|
|
||||||
|
title = _('Software Upgrades')
|
||||||
|
|
||||||
|
description = [
|
||||||
|
_('Upgrades install the latest software and security updates. When '
|
||||||
|
'automatic upgrades are enabled, upgrades are automatically run every '
|
||||||
|
'night. You don\'t normally need to start the upgrade process.')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Initialize the module."""
|
"""Initialize the module."""
|
||||||
menu = cfg.main_menu.get('system:index')
|
menu = cfg.main_menu.get('system:index')
|
||||||
menu.add_urlname(_('Software Upgrades'), 'glyphicon-refresh',
|
menu.add_urlname(title, 'glyphicon-refresh', 'upgrades:index', 21)
|
||||||
'upgrades:index', 21)
|
|
||||||
|
|
||||||
|
def setup(helper, old_version=None):
|
||||||
|
"""Install and configure the module."""
|
||||||
|
helper.install(['unattended-upgrades'])
|
||||||
|
helper.call('post', actions.superuser_run, 'upgrades', ['enable-auto'])
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'app.html' %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
#
|
#
|
||||||
# This file is part of Plinth.
|
# This file is part of Plinth.
|
||||||
@ -29,17 +29,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block configuration %}
|
||||||
|
|
||||||
<h2>{{ title }}</h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{% blocktrans trimmed %}
|
|
||||||
Upgrades install the latest software and security updates. When automatic
|
|
||||||
upgrades are enabled, upgrades are automatically run every night. You
|
|
||||||
don't normally need to start the upgrade process.
|
|
||||||
{% endblocktrans %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "app.html" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
#
|
#
|
||||||
# This file is part of Plinth.
|
# This file is part of Plinth.
|
||||||
@ -21,9 +21,7 @@
|
|||||||
{% load bootstrap %}
|
{% load bootstrap %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block configuration %}
|
||||||
|
|
||||||
<h2>{{ title }}</h2>
|
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@ -21,16 +21,14 @@ Plinth module for upgrades
|
|||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.shortcuts import redirect
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||||
from django.views.decorators.http import require_POST
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .forms import ConfigureForm
|
from .forms import ConfigureForm
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth import package
|
|
||||||
from plinth.errors import ActionError
|
from plinth.errors import ActionError
|
||||||
|
from plinth.modules import upgrades
|
||||||
|
|
||||||
subsubmenu = [{'url': reverse_lazy('upgrades:index'),
|
subsubmenu = [{'url': reverse_lazy('upgrades:index'),
|
||||||
'text': ugettext_lazy('Automatic Upgrades')},
|
'text': ugettext_lazy('Automatic Upgrades')},
|
||||||
@ -41,12 +39,6 @@ LOG_FILE = '/var/log/unattended-upgrades/unattended-upgrades.log'
|
|||||||
LOCK_FILE = '/var/log/dpkg/lock'
|
LOCK_FILE = '/var/log/dpkg/lock'
|
||||||
|
|
||||||
|
|
||||||
def on_install():
|
|
||||||
"""Enable automatic upgrades after install."""
|
|
||||||
actions.superuser_run('upgrades', ['enable-auto'])
|
|
||||||
|
|
||||||
|
|
||||||
@package.required(['unattended-upgrades'], on_install=on_install)
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""Serve the configuration form."""
|
"""Serve the configuration form."""
|
||||||
status = get_status()
|
status = get_status()
|
||||||
@ -63,10 +55,12 @@ def index(request):
|
|||||||
form = ConfigureForm(initial=status, prefix='upgrades')
|
form = ConfigureForm(initial=status, prefix='upgrades')
|
||||||
|
|
||||||
return TemplateResponse(request, 'upgrades_configure.html',
|
return TemplateResponse(request, 'upgrades_configure.html',
|
||||||
{'title': _('Automatic Upgrades'),
|
{'title': upgrades.title,
|
||||||
|
'description': upgrades.description,
|
||||||
'form': form,
|
'form': form,
|
||||||
'subsubmenu': subsubmenu})
|
'subsubmenu': subsubmenu})
|
||||||
|
|
||||||
|
|
||||||
def is_package_manager_busy():
|
def is_package_manager_busy():
|
||||||
"""Return whether a package manager is running."""
|
"""Return whether a package manager is running."""
|
||||||
try:
|
try:
|
||||||
@ -85,7 +79,6 @@ def get_log():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@package.required(['unattended-upgrades'], on_install=on_install)
|
|
||||||
def upgrade(request):
|
def upgrade(request):
|
||||||
"""Serve the upgrade page."""
|
"""Serve the upgrade page."""
|
||||||
is_busy = is_package_manager_busy()
|
is_busy = is_package_manager_busy()
|
||||||
@ -99,7 +92,8 @@ def upgrade(request):
|
|||||||
messages.error(request, _('Starting upgrade failed.'))
|
messages.error(request, _('Starting upgrade failed.'))
|
||||||
|
|
||||||
return TemplateResponse(request, 'upgrades.html',
|
return TemplateResponse(request, 'upgrades.html',
|
||||||
{'title': _('Package Upgrades'),
|
{'title': upgrades.title,
|
||||||
|
'description': upgrades.description,
|
||||||
'subsubmenu': subsubmenu,
|
'subsubmenu': subsubmenu,
|
||||||
'is_busy': is_busy,
|
'is_busy': is_busy,
|
||||||
'log': get_log()})
|
'log': get_log()})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user