From 42ea6e143af1c69ead3e5effac2b22497521a5f9 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Thu, 25 Apr 2024 10:46:15 +0200 Subject: [PATCH] Update import-email-to-piler service and action scripts --- imageroot/actions/get-configuration/20read | 6 ++ .../get-configuration/validate-output.json | 18 +++- .../actions/import-email-to-piler/50start | 10 +++ .../user/import-email-to-piler.service | 10 +++ ui/public/i18n/language.json | 7 +- ui/src/views/Settings.vue | 84 ++++++++++++++++++- 6 files changed, 128 insertions(+), 7 deletions(-) create mode 100755 imageroot/actions/import-email-to-piler/50start create mode 100644 imageroot/systemd/user/import-email-to-piler.service diff --git a/imageroot/actions/get-configuration/20read b/imageroot/actions/get-configuration/20read index 902fcef..677099b 100755 --- a/imageroot/actions/get-configuration/20read +++ b/imageroot/actions/get-configuration/20read @@ -43,5 +43,11 @@ is_found_auditor = "$1$SLIIIS$JMBwGqQg4lIir2P2YU1y.0" in output.stdout config['is_default_password'] = True if is_found_admin or is_found_auditor else False +import_running = subprocess.run(['systemctl', '--user', 'is-active', "import-email-to-piler.service"], capture_output=True, text=True) +config['import_email_is_running'] = True if import_running.stdout.strip() == 'active' else False + +piler_running = subprocess.run(['systemctl', '--user', 'is-active', "piler-app.service"], capture_output=True, text=True) +config['piler_is_running'] = True if piler_running.stdout.strip() == 'active' else False + # Dump the configuratio to stdout json.dump(config, fp=sys.stdout) diff --git a/imageroot/actions/get-configuration/validate-output.json b/imageroot/actions/get-configuration/validate-output.json index c226e2e..1c09a2a 100644 --- a/imageroot/actions/get-configuration/validate-output.json +++ b/imageroot/actions/get-configuration/validate-output.json @@ -9,7 +9,9 @@ "http2https": true, "lets_encrypt": true, "mail_server": "xxxxxxxxxxxxxxxxxxxxxxxxx", - "is_default_password": false + "is_default_password": false, + "import_email_is_running": false, + "piler_is_running": true } ], "type": "object", @@ -18,7 +20,9 @@ "http2https", "lets_encrypt", "mail_server", - "is_default_password" + "is_default_password", + "import_email_is_running", + "piler_is_running" ], "properties": { "host": { @@ -45,6 +49,16 @@ "type": "boolean", "title": "Default password", "description": "True if the password is the default one" + }, + "import_email_is_running": { + "type": "boolean", + "title": "Import email is running", + "description": "True if the import email is running" + }, + "piler_is_running": { + "type": "boolean", + "title": "Piler is running", + "description": "True if the piler is running" } } } diff --git a/imageroot/actions/import-email-to-piler/50start b/imageroot/actions/import-email-to-piler/50start new file mode 100755 index 0000000..b16c071 --- /dev/null +++ b/imageroot/actions/import-email-to-piler/50start @@ -0,0 +1,10 @@ +#!/bin/bash + +# +# Copyright (C) 2024 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +# If the control reaches this step, the service can be enabled and started + +systemctl --user start import-email-to-piler.service \ No newline at end of file diff --git a/imageroot/systemd/user/import-email-to-piler.service b/imageroot/systemd/user/import-email-to-piler.service new file mode 100644 index 0000000..6756f34 --- /dev/null +++ b/imageroot/systemd/user/import-email-to-piler.service @@ -0,0 +1,10 @@ +# +# Copyright (C) 2024 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# +[Unit] +Description= import emails to piler + +[Service] +Type=simple +ExecStart=/usr/local/bin/runagent import-emails diff --git a/ui/public/i18n/language.json b/ui/public/i18n/language.json index aebfb40..01e271e 100644 --- a/ui/public/i18n/language.json +++ b/ui/public/i18n/language.json @@ -43,7 +43,9 @@ "host_pattern": "Must be a valid fully qualified domain name", "host_format": "Must be a valid fully qualified domain name", "password_warning": "The passwords are the default ones", - "password_warning_description": "Please change the password in the Piler webapp for admin@local(pilerrocks) and auditor@local(auditor)" + "password_warning_description": "Please change the password in the Piler webapp for admin@local(pilerrocks) and auditor@local(auditor)", + "import_email_is_running_warning": "Import email is running", + "import_email_is_running_description": "Please wait until the import email is finished" }, "about": { "title": "About" @@ -59,7 +61,8 @@ "get-name": "Get name", "list-backup-repositories": "List backup repositories", "list-backups": "List backups", - "list-installed-modules": "List installed modules" + "list-installed-modules": "List installed modules", + "importEmailToPiler": "Import emails to Piler" }, "error": { "error": "Error", diff --git a/ui/src/views/Settings.vue b/ui/src/views/Settings.vue index 884902f..4242d0b 100644 --- a/ui/src/views/Settings.vue +++ b/ui/src/views/Settings.vue @@ -29,6 +29,16 @@ /> + + + + + @@ -94,11 +104,28 @@ ref="mail_server" > + + {{ $t("settings.import_email_to_piler") }} + + + + + +