diff --git a/plinth/modules/upgrades/__init__.py b/plinth/modules/upgrades/__init__.py index 3312cece2..67c8dec6c 100644 --- a/plinth/modules/upgrades/__init__.py +++ b/plinth/modules/upgrades/__init__.py @@ -30,6 +30,11 @@ first_boot_steps = [ 'url': 'upgrades:backports-firstboot', 'order': 5, }, + { + 'id': 'initial_update', + 'url': 'upgrades:update-firstboot', + 'order': 6, + }, ] _description = [ diff --git a/plinth/modules/upgrades/forms.py b/plinth/modules/upgrades/forms.py index 975f859b1..667d2b8c0 100644 --- a/plinth/modules/upgrades/forms.py +++ b/plinth/modules/upgrades/forms.py @@ -33,3 +33,9 @@ class BackportsFirstbootForm(forms.Form): backports_enabled = forms.BooleanField( label=_('Activate frequent feature updates (recommended)'), required=False, initial=True) + + +class UpdateFirstbootForm(forms.Form): + """Form to run or skip initial update during first boot wizard.""" + update_now = forms.BooleanField(label=_('Update now (recommended)'), + required=False, initial=True) diff --git a/plinth/modules/upgrades/templates/update-firstboot.html b/plinth/modules/upgrades/templates/update-firstboot.html new file mode 100644 index 000000000..3c68a0f89 --- /dev/null +++ b/plinth/modules/upgrades/templates/update-firstboot.html @@ -0,0 +1,37 @@ +{% extends "base_firstboot.html" %} +{% comment %} +# SPDX-License-Identifier: AGPL-3.0-or-later +{% endcomment %} + +{% load bootstrap %} +{% load i18n %} +{% load static %} + +{% block content %} +

{% trans "Update" %}

+ +

+ {% blocktrans trimmed %} + Check for and apply the latest software and security updates. + {% endblocktrans %} +

+ +

+ {% blocktrans trimmed %} + This may take a long time to complete. During an update, + you cannot install apps. Also, this web interface may be temporarily + unavailable and show an error. In that case, refresh the page to + continue. + {% endblocktrans %} +

+ +
+ {% csrf_token %} + + {{ form|bootstrap }} + + +
+ +{% endblock %} diff --git a/plinth/modules/upgrades/urls.py b/plinth/modules/upgrades/urls.py index f6acd3d87..625485d83 100644 --- a/plinth/modules/upgrades/urls.py +++ b/plinth/modules/upgrades/urls.py @@ -14,5 +14,7 @@ urlpatterns = [ name='activate-backports'), url(r'^sys/upgrades/firstboot/backports/$', views.BackportsFirstbootView.as_view(), name='backports-firstboot'), + url(r'^sys/upgrades/firstboot/update/$', + views.UpdateFirstbootView.as_view(), name='update-firstboot'), url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'), ] diff --git a/plinth/modules/upgrades/views.py b/plinth/modules/upgrades/views.py index dfa8d124f..a7dfe68b1 100644 --- a/plinth/modules/upgrades/views.py +++ b/plinth/modules/upgrades/views.py @@ -17,7 +17,7 @@ from plinth.errors import ActionError from plinth.modules import first_boot, upgrades from plinth.views import AppView -from .forms import BackportsFirstbootForm, ConfigureForm +from .forms import BackportsFirstbootForm, ConfigureForm, UpdateFirstbootForm class UpgradesConfigurationView(AppView): @@ -172,3 +172,21 @@ class BackportsFirstbootView(FormView): upgrades.setup_repositories(None) first_boot.mark_step_done('backports_wizard') return super().form_valid(form) + + +class UpdateFirstbootView(FormView): + """View to run initial update during first boot wizard.""" + template_name = 'update-firstboot.html' + form_class = UpdateFirstbootForm + + def get_success_url(self): + """Return next firstboot step.""" + return reverse_lazy(first_boot.next_step()) + + def form_valid(self, form): + """Run update if selected, and mark step as done.""" + if form.cleaned_data['update_now']: + actions.superuser_run('upgrades', ['run']) + + first_boot.mark_step_done('initial_update') + return super().form_valid(form)