diff --git a/debian/control b/debian/control
index c6128f01c..90898791e 100644
--- a/debian/control
+++ b/debian/control
@@ -51,6 +51,7 @@ Depends: ${python3:Depends}
, ${misc:Depends}
, ${plinth:Depends}
, adduser
+ , debconf
, augeas-tools
, e2fsprogs
, fonts-lato
diff --git a/debian/postinst b/debian/postinst
index 8f2c869cf..06b9ccf8a 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -2,6 +2,9 @@
set -e
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
daemonuser=plinth
daemongroup=plinth
@@ -12,11 +15,20 @@ daemongroup=plinth
sed -ie 's+-:ALL EXCEPT root fbx (admin) (sudo):ALL+-:ALL EXCEPT root fbx plinth (admin) (sudo):ALL+' /etc/security/access.conf
case "$1" in
-configure)
- addgroup --system --quiet plinth
- adduser --system --quiet --ingroup plinth --no-create-home --home /var/lib/plinth plinth
- chown -R plinth: /var/lib/plinth /var/log/plinth
- ;;
+ configure)
+ addgroup --system --quiet plinth
+ adduser --system --quiet --ingroup plinth --no-create-home --home /var/lib/plinth plinth
+ chown -R plinth: /var/lib/plinth /var/log/plinth
+
+ if [ ! -e '/var/lib/freedombox/is-freedombox-disk-image' ]; then
+ umask 377
+ cat /dev/urandom | base64 | head -c16 > /var/lib/plinth/firstboot-wizard-secret
+ chown plinth:plinth /var/lib/plinth/firstboot-wizard-secret
+ db_subst plinth/firstboot_wizard_secret secret $(cat /var/lib/plinth/firstboot-wizard-secret)
+ db_input high plinth/firstboot_wizard_secret || true
+ db_go
+ fi
+ ;;
esac
#DEBHELPER#
diff --git a/debian/templates b/debian/templates
new file mode 100644
index 000000000..ec65f82bd
--- /dev/null
+++ b/debian/templates
@@ -0,0 +1,8 @@
+Template: plinth/firstboot_wizard_secret
+Type: note
+Description: FreedomBox first wizard secret - ${secret}
+ Please save this string. You will be asked to enter this in the first screen
+ after you launch the FreedomBox interface. In case you lose it, you can find
+ it in the file /var/lib/plinth/firstboot-wizard-secret.
+ .
+ ${secret}
diff --git a/plinth/modules/first_boot/__init__.py b/plinth/modules/first_boot/__init__.py
index 7a08970ce..eaea06270 100644
--- a/plinth/modules/first_boot/__init__.py
+++ b/plinth/modules/first_boot/__init__.py
@@ -19,10 +19,11 @@ FreedomBox app for first boot wizard.
"""
import operator
+import os
from django.urls import reverse
-from plinth import module_loader
+from plinth import cfg, module_loader
from plinth.signals import post_setup
version = 1
@@ -140,3 +141,14 @@ def set_completed():
global _is_completed
_is_completed = True
kvstore.set('firstboot_completed', 1)
+
+
+def get_secret_file_path():
+ """Returns the path to the first boot wizard secret file."""
+ return os.path.join(cfg.data_dir, 'firstboot-wizard-secret')
+
+
+def firstboot_wizard_secret_exists():
+ """Return whether a firstboot wizard secret exists."""
+ secret_file = get_secret_file_path()
+ return os.path.exists(secret_file) and os.path.getsize(secret_file) > 0
diff --git a/plinth/modules/first_boot/forms.py b/plinth/modules/first_boot/forms.py
new file mode 100644
index 000000000..8cd9596f0
--- /dev/null
+++ b/plinth/modules/first_boot/forms.py
@@ -0,0 +1,47 @@
+#
+# This file is part of FreedomBox.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
-
-
+ - {% blocktrans trimmed %} - To complete the setup of your {{ box_name }}, please provide - some basic information. - {% endblocktrans %} -
{% endblock %} diff --git a/plinth/modules/first_boot/templatetags/firstboot_extras.py b/plinth/modules/first_boot/templatetags/firstboot_extras.py index 2484e4c78..0c22c1c31 100644 --- a/plinth/modules/first_boot/templatetags/firstboot_extras.py +++ b/plinth/modules/first_boot/templatetags/firstboot_extras.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see