From 2dc160b8f5119f278eb5281827172df5896268d8 Mon Sep 17 00:00:00 2001 From: Lee Garrett Date: Tue, 24 Jan 2023 13:13:39 +0100 Subject: [PATCH 1/2] Document `occ status` and `-e` option Signed-off-by: Lee Garrett --- .../background_jobs_configuration.rst | 3 + .../configuration_server/occ_command.rst | 61 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/admin_manual/configuration_server/background_jobs_configuration.rst b/admin_manual/configuration_server/background_jobs_configuration.rst index 69568564b..cb40805c8 100644 --- a/admin_manual/configuration_server/background_jobs_configuration.rst +++ b/admin_manual/configuration_server/background_jobs_configuration.rst @@ -127,11 +127,14 @@ This approach requires two files: **nextcloudcron.service** and **nextcloudcron. [Service] User=www-data + ExecCondition=php -f /var/www/nextcloud/occ status -e ExecStart=/usr/bin/php -f /var/www/nextcloud/cron.php KillMode=process Replace the user ``www-data`` with the user of your http server and ``/var/www/nextcloud/cron.php`` with the location of **cron.php** in your nextcloud directory. +The `ExecCondition` checks that the nextcloud instance is operating normally before running the background job, and skips it if otherwise. + The ``KillMode=process`` setting is necessary for external programs that are started by the cron job to keep running after the cron job has finished. Note that the **.service** unit file does not need an ``[Install]`` section. Please check your setup because we recommended it in earlier versions of this admin manual. diff --git a/admin_manual/configuration_server/occ_command.rst b/admin_manual/configuration_server/occ_command.rst index d24f19167..9901ba603 100644 --- a/admin_manual/configuration_server/occ_command.rst +++ b/admin_manual/configuration_server/occ_command.rst @@ -1100,6 +1100,67 @@ Remove a certificate:: .. _trashbin_label: +Status +------ + +Use the status command to retrieve information about the current installation:: + + $ sudo -u www-data php occ status + - installed: true + - version: 25.0.2.3 + - versionstring: 25.0.2 + - edition: + - maintenance: false + - needsDbUpgrade: false + - productname: Nextcloud + - extendedSupport: false + +This information can also be formatted via JSON instead of plain text:: + + $ php occ status --output=json_pretty + { + "installed": true, + "version": "25.0.2.3", + "versionstring": "25.0.2", + "edition": "", + "maintenance": false, + "needsDbUpgrade": false, + "productname": "Nextcloud", + "extendedSupport": false + } + +And finally, the ``-e`` (for exit code) parameter can be used to check +the state of the nextcloud installation via return code:: + + $ php occ status -e + $ echo $? + 0 + $ php occ maintenance:mode --on + Maintenance mode enabled + $ php occ status -e + $ echo $? + 1 + $ php occ maintenance:mode --off + Maintenance mode disabled + $ php occ status -e + $ echo $? + 0 + +Note that by default there is no output when run with ``-e``. This is +intentional, so it can be used in scripts, monitoring checks, and systemd +units. + ++-------------+--------------------------------------------------------+ +| Return code | Description | ++=============+========================================================+ +| 0 | normal operation | ++-------------+--------------------------------------------------------+ +| 1 | maintenance mode is enabled; the instance is currently | +| | unavailable to users. | ++-------------+--------------------------------------------------------+ +| 2 | ``php occ upgrade`` is required | ++-------------+--------------------------------------------------------+ + Trashbin -------- From 1d35260acc0534c7993d57f146cedc4a9efdf3b9 Mon Sep 17 00:00:00 2001 From: Lee Garrett Date: Tue, 21 Feb 2023 14:48:13 +0100 Subject: [PATCH 2/2] Add heading and also fix label Signed-off-by: Lee Garrett --- admin_manual/configuration_server/occ_command.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/admin_manual/configuration_server/occ_command.rst b/admin_manual/configuration_server/occ_command.rst index 9901ba603..e0550fd8c 100644 --- a/admin_manual/configuration_server/occ_command.rst +++ b/admin_manual/configuration_server/occ_command.rst @@ -1098,8 +1098,6 @@ Remove a certificate:: sudo -u www-data php occ security:certificates:remove [certificate name] -.. _trashbin_label: - Status ------ @@ -1129,6 +1127,9 @@ This information can also be formatted via JSON instead of plain text:: "extendedSupport": false } +Status return code +^^^^^^^^^^^^^^^^^^ + And finally, the ``-e`` (for exit code) parameter can be used to check the state of the nextcloud installation via return code:: @@ -1161,6 +1162,8 @@ units. | 2 | ``php occ upgrade`` is required | +-------------+--------------------------------------------------------+ +.. _trashbin_label: + Trashbin --------