Skip to content

Commit bfdccae

Browse files
authored
Merge pull request #13092 from nextcloud/enh/noid/standardize-occ-command
standardize occ command documentation
2 parents 2785bbc + 7ba5846 commit bfdccae

35 files changed

+275
-249
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check occ command syntax
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.rst'
7+
8+
jobs:
9+
check-occ-command:
10+
name: Check occ command syntax
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Run script
16+
run: |
17+
RST_FILE="$(find ./ -name '*.rst')"
18+
mapfile -t RST_FILE <<< "$RST_FILE"
19+
for file in "${RST_FILE[@]}"; do
20+
if [ "$(grep "php occ" "$file" | grep -v "sudo -E -u www-data php occ" | wc -l)" -gt 0 ]; then
21+
printf "%b%s%b\n" "\e[0;31m" "$file does not use the 'sudo -E -u www-data php occ' syntax in some places which is required." "\e[0m"
22+
echo "See $(grep "php occ" "$file" | grep -v "sudo -E -u www-data php occ")"
23+
FAIL=1
24+
fi
25+
done
26+
if [ -n "$FAIL" ]; then
27+
exit 1
28+
fi

admin_manual/ai/app_assistant.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can install the *assistant* app via the "Apps" page in Nextcloud, or by exec
1717

1818
.. code-block::
1919
20-
php occ app:enable assistant
20+
sudo -E -u www-data php occ app:enable assistant
2121
2222
App store
2323
---------

admin_manual/ai/app_summary_bot.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ After cloning this app *manually* (cloned via git to your apps directory) you wi
8787

8888
.. code-block::
8989
90-
sudo -u <the_user_the_webserver_is_running_as> php /path/to/your/nextcloud/webroot/occ app_api:app:unregister summary_bot
90+
sudo -E -u www-data php occ app_api:app:unregister summary_bot
9191
9292
9393
5. Register the Summary Bot so that your Nextcloud instance is aware of it
@@ -96,7 +96,7 @@ After cloning this app *manually* (cloned via git to your apps directory) you wi
9696

9797
.. code-block::
9898
99-
sudo -u <the_user_the_webserver_is_running_as> php ./occ app_api:app:register summary_bot manual_install --json-info '{ "id": "summary_bot", "name": "Summary Bot", "daemon_config_name": "manual_install", "version": "1.0.0", "secret": "12345", "host": "0.0.0.0", "port": 9031, "scopes": ["AI_PROVIDERS", "TALK", "TALK_BOT"], "protocol": "http"}' --force-scopes --wait-finish
99+
sudo -E -u www-data php occ app_api:app:register summary_bot manual_install --json-info '{ "id": "summary_bot", "name": "Summary Bot", "daemon_config_name": "manual_install", "version": "1.0.0", "secret": "12345", "host": "0.0.0.0", "port": 9031, "scopes": ["AI_PROVIDERS", "TALK", "TALK_BOT"], "protocol": "http"}' --force-scopes --wait-finish
100100
101101
102102
6. Enable the *Summary Bot* for the selected Chatroom via the three dots menu of the Chatroom (The Bots settings are located inside the *Bots* section)

admin_manual/ai/overview.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ It would be best to run one command per screen session or per tmux window/pane t
218218

219219
.. code-block::
220220
221-
set -e; while true; do sudo -u www-data occ background-job:worker -v -t 60 "OC\TaskProcessing\SynchronousBackgroundJob"; done
221+
set -e; while true; do sudo -E -u www-data php occ background-job:worker -v -t 60 "OC\TaskProcessing\SynchronousBackgroundJob"; done
222222
223223
For Nextcloud-AIO you should use this command on the host server.
224224

225225
.. code-block::
226226
227-
set -e; while true; do docker exec -u www-data -it nextcloud-aio-nextcloud php occ background-job:worker -v -t 60 "OC\TaskProcessing\SynchronousBackgroundJob"; done
227+
set -e; while true; do docker exec -it nextcloud-aio-nextcloud sudo -E -u www-data php occ background-job:worker -v -t 60 "OC\TaskProcessing\SynchronousBackgroundJob"; done
228228
229229
You may want to adjust the number of workers and the timeout (in seconds) to your needs.
230230
The logs of the worker can be checked by attaching to the screen or tmux session.
@@ -256,7 +256,7 @@ Systemd service
256256
#!/bin/sh
257257
echo "Starting Nextcloud AI Worker $1"
258258
cd /path/to/nextcloud
259-
sudo -u www-data php occ background-job:worker -t 60 'OC\TaskProcessing\SynchronousBackgroundJob'
259+
sudo -E -u www-data php occ background-job:worker -t 60 'OC\TaskProcessing\SynchronousBackgroundJob'
260260
261261
You may want to adjust the timeout to your needs (in seconds).
262262

admin_manual/configuration_database/bigint_identifiers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ and activity table has to be triggered manually by a console command.
99

1010
The command can safely be executed. It will show a success message when there is nothing to do::
1111

12-
sudo -u www-data php occ db:convert-filecache-bigint
12+
sudo -E -u www-data php occ db:convert-filecache-bigint
1313
All tables already up to date!
1414

1515
or otherwise ask for confirmation, before performing the heavy actions::
1616

17-
sudo -u www-data php occ db:convert-filecache-bigint
17+
sudo -E -u www-data php occ db:convert-filecache-bigint
1818
This can take up to hours, depending on the number of files in your instance!
1919
Continue with the conversion (y/n)? [n]
2020

2121
to suppress the confirmation message append ``--no-interaction`` to the argument list::
2222

23-
sudo -u www-data php occ db:convert-filecache-bigint --no-interaction
23+
sudo -E -u www-data php occ db:convert-filecache-bigint --no-interaction
2424

2525

2626
.. note:: Similar to a normal update, you should shutdown your Apache or nginx server or enable maintenance

admin_manual/configuration_database/db_conversion.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The ``occ db:convert-type`` command handles all the tasks of the conversion. The
3434

3535
::
3636

37-
php occ db:convert-type [options] type username hostname database
37+
sudo -E -u www-data php occ db:convert-type [options] type username hostname database
3838

3939
``type`` should be the target database type. The same values are available here as for the ``config.php`` ``dbtype`` parameter. It should be one of: ``mysql`` for MariaDB/MySQL,
4040
``pgsql`` for PostgreSQL, or ``oci`` for Oracle.
@@ -55,7 +55,7 @@ Let's convert our existing (functioning) sqlite3 installation to be MariaDB/MySQ
5555

5656
::
5757

58-
php occ db:convert-type --password="<password>" --port="3306" --all-apps mysql <username> <hostname> nextcloud
58+
sudo -E -u www-data php occ db:convert-type --password="<password>" --port="3306" --all-apps mysql <username> <hostname> nextcloud
5959

6060
.. note:: It was unnecessary to specify the port in this example because ``3306`` is already the default. We did so
6161
merely for demonstration purposes and completeness in case the reader is using a non-standard port on their target
@@ -68,7 +68,7 @@ If you are converting to a MySQL/MariaDB database, you will also want to set ``m
6868

6969
::
7070

71-
php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
71+
sudo -E -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
7272

7373
If you like, you can view the changes that were made by looking for the ``db*`` parameters in your ``config.php`` (you could also use this command before
7474
doing the conversion to compare your configuration before/after):

admin_manual/configuration_database/mysql_4byte_support.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The result should look like this::
4343
3. Open a shell, change dir (adjust ``/var/www/nextcloud`` to your nextcloud location if needed), and put your nextcloud instance in maintenance mode, if it isn't already::
4444

4545
$ cd /var/www/nextcloud
46-
$ sudo -u www-data php occ maintenance:mode --on
46+
$ sudo -E -u www-data php occ maintenance:mode --on
4747

4848
4. Change your databases character set and collation:
4949

@@ -53,19 +53,19 @@ The result should look like this::
5353
5454
5. Set the ``mysql.utf8mb4`` config to true in your config.php::
5555

56-
$ sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
56+
$ sudo -E -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
5757

5858
6. Convert all existing tables to the new collation by running the repair step::
5959

60-
$ sudo -u www-data php occ maintenance:repair
60+
$ sudo -E -u www-data php occ maintenance:repair
6161

6262
.. note::
6363

6464
This will also change the `ROW_FORMAT` to `DYNAMIC` for your tables.
6565

6666
7. Disable maintenance mode::
6767

68-
$ sudo -u www-data php occ maintenance:mode --off
68+
$ sudo -E -u www-data php occ maintenance:mode --off
6969

7070
Now you should be able to use Emojis in your file names, calendar events, comments and many more.
7171

admin_manual/configuration_files/big_file_upload_configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Adjust chunk size on Nextcloud side
159159

160160
For upload performance improvements in environments with high upload bandwidth, the server's upload chunk size may be adjusted::
161161

162-
sudo -u www-data php occ config:system:set --type int --value 20971520 files.chunked_upload.max_size
162+
sudo -E -u www-data php occ config:system:set --type int --value 20971520 files.chunked_upload.max_size
163163

164164
Put in a value in bytes (in this example, 20MB). Set ``--value 0`` for no chunking at all.
165165

admin_manual/configuration_files/external_storage/local.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ are on Ubuntu Linux::
1717

1818
Important: If you use consecutive commands, make sure, you are user ``www-data``::
1919

20-
sudo -u www-data bash
20+
sudo -E -u www-data bash
2121
cd /path/to/localdir
2222
mkdir data
2323

admin_manual/configuration_files/external_storage_configuration_gui.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Nextcloud may not always be able to find out what has been
158158
changed remotely (files changed without going through Nextcloud), especially
159159
when it's very deep in the folder hierarchy of the external storage.
160160

161-
You might need to setup a cron job that runs ``sudo -u www-data php occ files:scan --all``
161+
You might need to setup a cron job that runs ``sudo -E -u www-data php occ files:scan --all``
162162
(or replace ``--all`` with the user name, see also :doc:`../occ_command`)
163163
to trigger a rescan of the user's files periodically (for example every 15 minutes), which includes
164164
the mounted external storage.

0 commit comments

Comments
 (0)