From 6b046ec27d4e7b6a3a9a31f6be2844fde1170684 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 14 Apr 2024 17:55:21 -0700 Subject: [PATCH] nextcloud: Ship instead of create cron timer related units Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- .../system/nextcloud-cron-freedombox.service | 8 ++++ .../system/nextcloud-cron-freedombox.timer | 11 +++++ plinth/modules/nextcloud/privileged.py | 40 ------------------- 3 files changed, 19 insertions(+), 40 deletions(-) create mode 100644 plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.service create mode 100644 plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.timer diff --git a/plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.service b/plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.service new file mode 100644 index 000000000..5f24bb040 --- /dev/null +++ b/plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.service @@ -0,0 +1,8 @@ +[Unit] +Description=Nextcloud cron.php job +Documentation=https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/background_jobs_configuration.html#systemd + +[Service] +ExecCondition=/usr/bin/podman exec --user www-data nextcloud-freedombox /var/www/html/occ status -e +ExecStart=/usr/bin/podman exec --user www-data nextcloud-freedombox php -f /var/www/html/cron.php +KillMode=process diff --git a/plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.timer b/plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.timer new file mode 100644 index 000000000..3a5e8bd18 --- /dev/null +++ b/plinth/modules/nextcloud/data/usr/lib/systemd/system/nextcloud-cron-freedombox.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run Nextcloud cron.php every 5 minutes +Documentation=https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/background_jobs_configuration.html#systemd + +[Timer] +OnBootSec=5min +OnUnitActiveSec=5min +Unit=nextcloud-cron-freedombox.service + +[Install] +WantedBy=timers.target diff --git a/plinth/modules/nextcloud/privileged.py b/plinth/modules/nextcloud/privileged.py index 7bfc24e7c..74efb2e56 100644 --- a/plinth/modules/nextcloud/privileged.py +++ b/plinth/modules/nextcloud/privileged.py @@ -27,9 +27,6 @@ GUI_ADMIN = 'nextcloud-admin' REDIS_DB = 8 # Don't clash with other redis apps _data_path = pathlib.Path('/var/lib/nextcloud/') -_systemd_location = pathlib.Path('/etc/systemd/system/') -_cron_service_file = _systemd_location / 'nextcloud-cron-freedombox.service' -_cron_timer_file = _systemd_location / 'nextcloud-cron-freedombox.timer' DB_BACKUP_FILE = pathlib.Path( '/var/lib/plinth/backups-data/nextcloud-database.sql') @@ -67,8 +64,6 @@ def setup(): _configure_ldap() - _configure_systemd() - def _run_in_container( *args, capture_output: bool = False, check: bool = True, @@ -254,39 +249,6 @@ def _configure_ldap(): _run_occ('ldap:set-config', 's01', key, value) -def _configure_systemd(): - """Create systemd units files for container and cron jobs.""" - # Create service and timer for running periodic php jobs. - doc = 'https://docs.nextcloud.com/server/stable/admin_manual/' \ - 'configuration_server/background_jobs_configuration.html#systemd' - nextcloud_cron_service_content = f''' -[Unit] -Description=Nextcloud cron.php job -Documentation={doc} - -[Service] -ExecCondition=/usr/bin/podman exec --user www-data {CONTAINER_NAME} /var/www/html/occ status -e -ExecStart=/usr/bin/podman exec --user www-data {CONTAINER_NAME} php -f /var/www/html/cron.php -KillMode=process -''' # noqa: E501 - nextcloud_cron_timer_content = '''[Unit] -Description=Run Nextcloud cron.php every 5 minutes -Documentation={doc} - -[Timer] -OnBootSec=5min -OnUnitActiveSec=5min -Unit=nextcloud-cron-freedombox.service - -[Install] -WantedBy=timers.target -''' - _cron_service_file.write_text(nextcloud_cron_service_content) - _cron_timer_file.write_text(nextcloud_cron_timer_content) - - action_utils.service_daemon_reload() - - @privileged def uninstall(): """Uninstall Nextcloud""" @@ -295,8 +257,6 @@ def uninstall(): volume_name=VOLUME_NAME, image_name=IMAGE_NAME, volume_path=str(_data_path)) - for path in [_cron_service_file, _cron_timer_file]: - path.unlink(missing_ok=True) def _drop_database():