diff --git a/actions/snapshot b/actions/snapshot
index 778f54de0..69445cec9 100755
--- a/actions/snapshot
+++ b/actions/snapshot
@@ -38,6 +38,7 @@ def parse_arguments():
subparsers.add_parser('setup', help='Configure snapper')
subparsers.add_parser('list', help='List snapshots')
subparsers.add_parser('create', help='Create snapshot')
+ subparsers.add_parser('get-config', help='Configurations of snapshot')
subparser = subparsers.add_parser('delete',
help='Delete a snapshot by number')
@@ -46,6 +47,10 @@ def parse_arguments():
subparser = subparsers.add_parser('delete-all',
help='Delete all the snapshots')
+ subparser = subparsers.add_parser('configure',
+ help='Configure automatic snapshots')
+ subparser.add_argument('config')
+
subparser = subparsers.add_parser('rollback', help='Rollback to snapshot')
subparser.add_argument('number', help='Number of snapshot to rollback to')
@@ -163,6 +168,22 @@ def subcommand_delete_all(_):
subprocess.run(command, check=True)
+def subcommand_configure(arguments):
+ command = ['snapper', 'set-config', arguments.config]
+ subprocess.run(command, check=True)
+
+
+def subcommand_get_config(_):
+ command = ['snapper', 'get-config']
+ process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
+ lines = process.stdout.decode().splitlines()
+ config = {}
+ for line in lines[2:]:
+ parts = [part.strip() for part in line.split('|')]
+ config[parts[0]] = parts[1]
+ print(json.dumps(config))
+
+
def subcommand_rollback(arguments):
"""Rollback to snapshot."""
command = [
diff --git a/plinth/modules/snapshot/__init__.py b/plinth/modules/snapshot/__init__.py
index 647e47f33..d19bc4d92 100644
--- a/plinth/modules/snapshot/__init__.py
+++ b/plinth/modules/snapshot/__init__.py
@@ -23,6 +23,7 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth.menu import main_menu
+import json
version = 1
@@ -58,3 +59,11 @@ def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(managed_packages)
helper.call('post', actions.superuser_run, 'snapshot', ['setup'])
+
+
+def is_timeline_snapshots_enabled():
+ """Return whether timeline snapshots are enabled."""
+ output = actions.superuser_run('snapshot', ['get-config'])
+ output = json.loads(output)
+ return output['TIMELINE_CREATE'] == "yes"
+
diff --git a/plinth/modules/snapshot/forms.py b/plinth/modules/snapshot/forms.py
new file mode 100644
index 000000000..60d7a31e0
--- /dev/null
+++ b/plinth/modules/snapshot/forms.py
@@ -0,0 +1,29 @@
+#
+# This file is part of Plinth.
+#
+# 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
-