### Install Specific Features (Whitelist - Windows MSI) Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Installs only the specified features, excluding others. In this example, only the Start Menu shortcuts are installed, as the Client feature is always included by default. ```bash msiexec /passive /i Nextcloud-x.y.z-x64.msi ADDDEFAULT=StartMenuShortcuts ``` -------------------------------- ### Run Setup Checks Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_system.rst Executes the setup checks from the command line to verify the installation and configuration of your Nextcloud instance. ```bash sudo -E -u www-data php occ setupchecks ``` -------------------------------- ### Setup Check Run Function Implementation Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/setup_checks.rst Implement the `run` function to perform the actual test and return a `SetupResult`. This example checks if debug mode is enabled and returns a warning if it is. ```php public function run(): SetupResult { if ($this->config->getSystemValueBool('debug', false)) { return SetupResult::warning($this->l10n->t('This instance is running in debug mode. Only enable this for local development and not in production environments.')); } else { return SetupResult::success($this->l10n->t('Debug mode is disabled.')); } } ``` -------------------------------- ### Install the Client Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/desktop/building.rst Optionally install the compiled Nextcloud client to the default system path using 'make install'. ```bash make install ``` -------------------------------- ### Compile and Install Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/desktop/building.rst Compile the project using make and install the necessary files. ```bash % make install ``` -------------------------------- ### Enable and start httpd service Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/example_openbsd.rst Enables the httpd service to start on boot and starts the service immediately. ```bash # rcctl enable httpd # rcctl start httpd ``` -------------------------------- ### Display Help for Maintenance Install Command Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_system.rst Show the available options and usage instructions for the maintenance:install command. This command is used during the initial setup of Nextcloud. ```bash sudo -E -u www-data php /var/www/nextcloud/occ maintenance:install --help ``` -------------------------------- ### Install and Use Sphinx Autobuild Source: https://github.com/nextcloud/documentation/blob/master/README.rst Install sphinx-autobuild for live preview during development. Ensure openapi-spec is built if needed, then navigate to the documentation directory and start the autobuild process. ```bash pip install sphinx-autobuild make openapi-spec cd user_manual make SPHINXBUILD=sphinx-autobuild html ``` -------------------------------- ### Define a Debug Mode Setup Check Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/setup_checks.rst Implement the `ISetupCheck` interface to create a custom setup check. This example checks if the Nextcloud instance is running in debug mode. ```php l10n->t('Debug mode'); } public function getCategory(): string { return 'system'; } public function run(): SetupResult { if ($this->config->getSystemValueBool('debug', false)) { return SetupResult::warning($this->l10n->t('This instance is running in debug mode. Only enable this for local development and not in production environments.')); } else { return SetupResult::success($this->l10n->t('Debug mode is disabled.')); } } } ``` -------------------------------- ### Enable and Start MariaDB Service Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/example_centos.rst Configures the MariaDB service to start on boot and starts the service. ```bash systemctl enable mariadb.service systemctl start mariadb.service ``` -------------------------------- ### Install Nextcloud Client with Default Features (Windows MSI) Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Installs the Nextcloud client with default features enabled in the default location. Use this for standard automated installations. ```bash msiexec /passive /i Nextcloud-x.y.z-x64.msi ``` -------------------------------- ### Install Client Dependencies Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/desktop/building.rst Install all client dependencies using KDE Craft. ```winbatch craft --install-deps nextcloud-client ``` -------------------------------- ### Enable and Start Apache Service Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/example_centos.rst Configures the Apache web service to start automatically on boot and starts the service immediately. ```bash systemctl enable httpd.service systemctl start httpd.service ``` -------------------------------- ### Install Redis Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/example_centos.rst Installs the Redis in-memory data structure store and enables/starts its service. ```bash dnf install -y redis systemctl enable redis.service systemctl start redis.service ``` -------------------------------- ### Example PHP-FPM Configuration (dynamic mode) Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/server_tuning.rst A recommended starting configuration for PHP-FPM in dynamic process manager mode, suitable for servers with moderate RAM dedicated to PHP. Adjust 'pm.max_children' based on measured worker RSS. ```ini pm = dynamic pm.max_children = 30 pm.start_servers = 8 pm.min_spare_servers = 4 pm.max_spare_servers = 16 pm.max_requests = 500 ``` -------------------------------- ### Enable and Start Systemd Timer Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/background_jobs_configuration.rst Command to enable the Nextcloud systemd timer to start on boot and immediately start the timer. ```bash systemctl enable --now nextcloudcron.timer ``` -------------------------------- ### Launch Client After Installation Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Automatically launch the Nextcloud client after installation by setting the LAUNCH property to "1". This also removes the user's option to decide during non-passive installations. ```bash msiexec /i Nextcloud-x.y.z-x64.msi LAUNCH="1" ``` -------------------------------- ### Install Only the Client Feature (Windows MSI) Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Installs only the core Nextcloud client feature, excluding other default features. Use this to minimize the installation footprint. ```bash msiexec /passive /i Nextcloud-x.y.z-x64.msi ADDDEFAULT=Client ``` -------------------------------- ### Install Nextcloud with MySQL Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_system.rst Installs Nextcloud using a MySQL database. Ensure the database and user are pre-configured. ```bash sudo -E -u www-data php occ maintenance:install \ --database mysql \ --database-name nextcloud \ --database-host 127.0.0.1 \ --database-user nextcloud \ --database-pass secret \ --admin-user admin \ --admin-pass password ``` -------------------------------- ### Example URL Formatting Source: https://github.com/nextcloud/documentation/blob/master/style_guide.rst Use double-backticks for example URLs to prevent them from becoming live hyperlinks. ```text ``https://example.com`` ``` -------------------------------- ### Launch Webhook Worker (Nextcloud-AIO) Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/webhook_listeners/index.rst Use this command on the host server for Nextcloud-AIO installations to start a webhook worker. Ensure the container names are correct for your setup. ```bash set -e; while true; do sudo docker exec -it nextcloud-aio-nextcloud docker exec -it nextcloud-aio-nextcloud sudo -E -u www-data php occ background-job:worker -v -t 60 "OCA\WebhookListeners\BackgroundJobs\WebhookCall"; done ``` -------------------------------- ### Example: Map Network Drive via Command Line (Windows) Source: https://github.com/nextcloud/documentation/blob/master/user_manual/files/access_webdav.rst An example of mapping a Nextcloud instance to the Z drive using a specific URL and user credentials. ```bash net use Z: https://example.com/nextcloud/remote.php/dav/files/USERNAME/ /user:youruser yourpassword ``` -------------------------------- ### Set up Local Build Environment with Python Virtual Environment Source: https://github.com/nextcloud/documentation/blob/master/CONTRIBUTING.md Clone the repository, create and activate a Python virtual environment, install dependencies, and build the HTML documentation. ```bash git clone https://github.com/nextcloud/documentation.git cd documentation python3 -m venv venv source venv/bin/activate # on Windows: venv\Scripts\activate pip install -r requirements.txt make html ``` -------------------------------- ### Get Nextcloud Installation Status Return Code Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_system.rst Use the '-e' flag with the 'status' command to get a machine-readable exit code reflecting the installation state. This is suitable for scripts and monitoring checks. ```bash sudo -E -u www-data php occ status -e echo $? ``` -------------------------------- ### Install ClamAV on Debian/Ubuntu Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/antivirus_configuration.rst Use apt-get to install ClamAV and its daemon on Debian-based systems. The installer automatically sets up configuration files and starts the necessary daemons. ```bash apt-get install clamav clamav-daemon ``` -------------------------------- ### Instance ID Configuration Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/config_sample_php_parameters.rst The 'instanceid' is a unique identifier for your Nextcloud installation, automatically generated by the installer. This example is for documentation purposes only. ```php 'instanceid' => '', ``` -------------------------------- ### Windows Mass Deployment Example Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Use this command to provision a Nextcloud desktop client account on Windows non-interactively. Ensure all parameters are correct for successful provisioning. ```powershell "C:\Program Files\Nextcloud\nextcloud.exe" ^ --userid admin ^ --apppassword Jliy12356785jxnHa2ZCiZ9MX48ncECwDso95Pq3a5HABjY34ZvhZiXrPfpKWUg7aOHAX5 ^ --serverurl https://cloud.example.com ^ --localdirpath "D:\Nextcloud-sync-folder" ^ --remotedirpath /Music ^ --isvfsenabled 1 ``` -------------------------------- ### Inline Code and Command Examples Source: https://github.com/nextcloud/documentation/blob/master/style_guide.rst Use double-backticks for inline code and command examples in documentation. ```text ``sudo -E -u www-data php occ files:scan --help`` ``` ```text ``maintenance:install`` ``` -------------------------------- ### Ping Pong Endpoint Example Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/client_apis/ClientIntegration/index.rst An example endpoint demonstrating a simple GET request for client integration, used for testing connectivity or basic interaction. ```APIDOC ## GET /ocs/v2.php/apps/pingpong/ping/{fileId} ### Description Responds with a 'Pong' message, typically used for testing client-server communication. ### Method GET ### Endpoint /ocs/v2.php/apps/pingpong/ping/{fileId} ### Parameters #### Path Parameters - **fileId** (integer) - Optional - The ID of the file associated with the ping request. Defaults to 1. ### Request Example (No request body example provided in source) ### Response #### Success Response (200) - **version** (number) - The API version, currently 0.1. - **tooltip** (string) - A confirmation message, e.g., "Pong file [fileId]". ``` -------------------------------- ### Start FRP Client Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/exapps_management/DeployConfigurations.rst Executes the FRP client binary using the specified configuration file. Ensure the frpc binary is in the system's PATH or provide the full path. ```bash frpc -c /path/to/frpc.toml ``` -------------------------------- ### Get Single App Configuration Value Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_apps.rst Retrieve the version of an installed app. ```bash sudo -E -u www-data php occ config:app:get activity installed_version ``` -------------------------------- ### Example String Configuration Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/config_sample_php_parameters.rst Illustrates how to set string values in the config.php file, such as for a logo URL, retention policy, or timezone. ```php 'logo_url' => 'https://example.org', ``` ```php 'versions_retention_obligation' => 'auto, D', ``` ```php 'logtimezone' => 'Europe/Berlin', ``` -------------------------------- ### macOS Mass Deployment Example Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Use this command to provision a Nextcloud desktop client account on macOS non-interactively. Ensure correct parameters for server, user, and paths. ```bash nextcloud \ --userid admin \ --apppassword Jliy12356785jxnHa2ZCiZ9MX48ncECwDso95Pq3a5HABjY34ZvhZiXrPfpKWUg7aOHAX5 \ --serverurl https://cloud.example.com \ --localdirpath "/Users/admin/Nextcloud-sync-folder" \ --remotedirpath /Music \ --isvfsenabled 1 ``` -------------------------------- ### Build and Lint Commands Source: https://github.com/nextcloud/documentation/blob/master/AGENTS.md Provides commands for setting up a virtual environment, installing dependencies, building HTML documentation, and running linters. ```bash python3 -m venv venv && source venv/bin/activate pip install -r requirements.txt make html # all manuals cd user_manual && make html # single manual cd user_manual && make SPHINXBUILD=sphinx-autobuild html # live-reload sphinx-lint path/to/file.rst # RST lint codespell path/to/file.rst # spell check ``` -------------------------------- ### Get OCC Status in JSON Format Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_command.rst Use the --output=json option to retrieve the status of your Nextcloud installation in JSON format. This is useful for programmatic access to installation details. ```bash sudo -E -u www-data php occ status --output=json ``` ```json {"installed":true,"version":"19.0.0.9","versionstring":"19.0.0","edition":""} ``` -------------------------------- ### Build and Install Nextcloud Client (Windows) Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/desktop/building.rst Configure the build using CMake with specific generator and paths, then build and install the client. ```winbatch cd mkdir build cd build cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=. -DCMAKE_PREFIX_PATH=C:\CraftRoot -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build . --target install ``` -------------------------------- ### PHPUnit Test Case Example Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/server/unit-testing.rst An example of a simple PHPUnit test case. Ensure your test class extends \Test\TestCase and calls parent methods in setUp() and tearDown() if overridden. ```php testMe = new \OCA\Myapp\TestMe(); } public function testAddTwo(){ $this->assertEquals(5, $this->testMe->addTwo(3)); } } ``` -------------------------------- ### Example Array Configuration Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/config_sample_php_parameters.rst Provides examples of array values for configuration parameters, such as a list of domains to check connectivity against or enabled preview providers. ```php 'connectivity_check_domains' => [ 'www.nextcloud.com', 'www.eff.org', ], ``` ```php 'enabledPreviewProviders' => [ 'OC\Previewmp', 'OC\\\Preview\\GIF', 'OC\\Preview\\JPEG', ], ``` -------------------------------- ### Get ExApps List Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/exapp_development/tech_details/api/exapp.rst Retrieves a list of installed ExApps, either all or only the enabled ones. ```APIDOC ## GET /apps/app_api/api/v1/ex-app/{list} ### Description Retrieves a list of installed ExApps. The `list` parameter can be either `enabled` to list only enabled ExApps or `all` to list all ExApps. ### Method GET ### Endpoint /apps/app_api/api/v1/ex-app/{list} ### Parameters #### Path Parameters - **list** (string) - Required - Specifies whether to list 'enabled' or 'all' ExApps. ### Response #### Success Response (200) - **id** (string) - App ID of the ExApp. - **name** (string) - Name of the ExApp. - **version** (string) - Version of the ExApp. - **enabled** (boolean) - True if the ExApp is enabled, false otherwise. - **last_check_time** (timestamp) - Timestamp of the last successful Nextcloud to ExApp connection check. ### Response Example ```json { "id": "appid of the ExApp", "name": "name of the ExApp", "version": "version of the ExApp", "enabled": true, "last_check_time": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Get Nextcloud Installation Status in JSON Format Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_system.rst Retrieve Nextcloud installation status in a machine-readable JSON format using the '--output=json_pretty' flag. This is useful for scripting and automated checks. ```bash sudo -E -u www-data php occ status --output=json_pretty ``` -------------------------------- ### Get list of apps Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/apps_management_api.rst Returns a list of apps installed on the Nextcloud server. Supports filtering by enabled or disabled status. ```APIDOC ## GET ocs/v1.php/cloud/apps ### Description Returns a list of apps installed on the Nextcloud server. Authentication is done by sending a Basic HTTP Authorization header. ### Method GET ### Endpoint /ocs/v1.php/cloud/apps/ ### Parameters #### Query Parameters - **filter** (string) - Optional - Can be set to ``enabled`` or ``disabled`` to filter the list. ### Response #### Success Response (100) - **ocs.meta.statuscode** (integer) - 100 - **ocs.meta.status** (string) - ok - **ocs.data.apps** (array) - A list of app elements. ### Request Example ```bash curl -X GET http://admin:secret@example.com/ocs/v1.php/cloud/apps?filter=enabled -H "OCS-APIRequest: true" ``` ### Response Example ```xml 100 ok files provisioning_api ``` ``` -------------------------------- ### Start Client with Log Directory and Expiration Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/troubleshooting.rst Use command-line arguments to specify the log directory and how long log files should be retained. ```bash nextcloud --logdir /tmp/nextcloud_logs --logexpire 48 ``` -------------------------------- ### Get a file by ID Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/client_apis/WebDAV/search.rst Example of a WebDAV search request to retrieve a specific file using its unique file ID. ```APIDOC ## Get a file by id. ```xml /files/test infinity 12345 ``` ``` -------------------------------- ### Get all PNG and JPG files over 10MB Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/client_apis/WebDAV/search.rst Example of a WebDAV search request to find all PNG and JPG files larger than 10MB. ```APIDOC ## Get all png and jpg files over 10MB. ```xml /files/test ``` -------------------------------- ### Example ConfigLexicon.php Implementation Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/config/lexicon.rst Implement the ILexicon interface to define app configurations, including strictness, app configs, and user configs. ```php use OCP\Config\Lexicon\Entry; use OCP\Config\Lexicon\ILexicon; use OCP\Config\Lexicon\Strictness; use OCP\Config\ValueType; class Lexicon implements ILexicon { public function getStrictness(): Strictness { return Strictness::WARNING; } public function getAppConfigs(): array { return [ new Entry('key1', ValueType::STRING, 'abcde', 'test key', true, IAppConfig::FLAG_SENSITIVE), new Entry('key2', ValueType::INT, 12345, 'test key', false) ]; } public function getUserConfigs(): array { return [ new Entry('key1', ValueType::STRING, 'abcde', 'test key', true, IUserConfig::FLAG_SENSITIVE), new Entry('key2', ValueType::INT, 12345, 'test key', false) ]; } } ``` -------------------------------- ### Nextcloud Configuration with MariaDB Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/config_sample_php_parameters.rst Example of a `config.php` file for a new Nextcloud installation using MariaDB as the database. This includes database connection details. ```php 'oc8c0fd71e03', 'passwordsalt' => '515a13302a6b3950a9d0fdb970191a', 'trusted_domains' => array ( 0 => 'localhost', 1 => 'studio', 2 => '192.168.10.155' ), 'datadirectory' => '/var/www/nextcloud/data', 'dbtype' => 'mysql', 'version' => '7.0.2.1', 'dbname' => 'nextcloud', 'dbhost' => 'localhost', 'dbtableprefix' => 'oc_', 'dbuser' => 'oc_carla', 'dbpassword' => '67336bcdf7630dd80b2b81a413d07', 'installed' => true, ); ``` -------------------------------- ### Get Calendar Event Owner Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/groupware/calendar_provider.rst Specifies the owner of the calendar entry. Returns null in this example, indicating no specific owner is set for the entry. ```php 'occ6f7365735', 'passwordsalt' => '2c5778476346786306303', 'trusted_domains' => array ( 0 => 'localhost', 1 => 'studio', ), 'datadirectory' => '/var/www/nextcloud/data', 'dbtype' => 'sqlite3', 'version' => '7.0.2.1', 'installed' => true, ); ``` -------------------------------- ### Match Reference Links (PHP) Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/reference.rst Implement the `matchReference` method in PHP to determine if a provider supports a given link. This example supports URLs starting with 'https://my.website.org/'. ```php public function matchReference(string $referenceText): bool { // support all URLs starting with https://my.website.org/ return str_starts_with($referenceText, 'https://my.website.org/'); } ``` -------------------------------- ### Register Repair Step in info.xml Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/repair.rst Register a repair step in the app's info.xml file to define when it should be executed. This example shows how to register a step for app installation. ```xml myapp My App A test app ... OCA\MyApp\Migration\MyRepairStep ``` -------------------------------- ### Set up SMB External Storage with Docker Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/how_to/index.rst Enable the files_external app and set up a local SMB server using Docker. This allows testing SMB external storage. ```bash occ app:enable files_external mkdir -p /tmp/samba/{public,home/{smb1,smb2}} chmod a+rw /tmp/samba/home/smb* docker run -it -p 139:139 -p 445:445 \ -v /tmp/samba/public:/smbpublic \ -v /tmp/samba/home:/smbhome \ dperson/samba \ -u "smb1;pwd1" \ -u "smb2;pwd2" \ -s "public;/smbmount;yes;no;yes" \ -s "home;/smbhome/%U;yes;no;no;all;none" ``` -------------------------------- ### Nextcloud Database Configuration Example Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_database/linux_database_configuration.rst Example of database configuration parameters in Nextcloud's config.php file. ```php "pgsql", "dbname" => "nextcloud", "dbuser" => "username", "dbpassword" => "password", "dbhost" => "localhost", "dbtableprefix" => "oc_", ``` -------------------------------- ### Get OCC Status in Pretty JSON Format Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_command.rst Use the --output=json_pretty option for a human-readable, pretty-printed JSON output of the Nextcloud installation status. This is helpful for manual inspection. ```bash sudo -E -u www-data php occ status --output=json_pretty ``` ```json { "installed": true, "version": "19.0.0.12", "versionstring": "19.0.0", "edition": "" } ``` -------------------------------- ### Open Log Window on Startup Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/troubleshooting.rst Restart the client with the --logwindow argument to open a dedicated log viewer. ```bash C:\\Program Files\\Nextcloud\\nextcloud.exe --logwindow ``` ```bash /Applications/nextcloud.app/Contents/MacOS/nextcloud --logwindow ``` ```bash nextcloud --logwindow ``` -------------------------------- ### Task Processing Script for Systemd Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/webhook_listeners/index.rst This shell script is executed by the systemd service. It navigates to the Nextcloud directory and starts the webhook worker. Adjust the path to your Nextcloud installation and the timeout value. ```bash #!/bin/sh echo "Starting Nextcloud Webhook Worker $1" cd /path/to/nextcloud sudo -E -u www-data php occ background-job:worker -t 60 'OCA\WebhookListeners\BackgroundJobs\WebhookCall' ``` -------------------------------- ### Clone and Install Dependencies Source: https://github.com/nextcloud/documentation/blob/master/README.rst Clone the documentation repository, checkout a specific branch, and install Python dependencies using pip. ```bash git clone https://github.com/nextcloud/documentation.git cd documentation git checkout pip3 install -r requirements.txt ``` -------------------------------- ### Create CAN_INSTALL file Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/example_openbsd.rst Create the CAN_INSTALL file in the config directory to activate the Nextcloud installation wizard. ```bash # touch /var/www/nextcloud/config/CAN_INSTALL ``` -------------------------------- ### Get File Properties with cURL and xml_pp Source: https://github.com/nextcloud/documentation/blob/master/user_manual/files/access_webdav.rst Retrieves properties of files in the root folder of your Nextcloud WebDAV directory. The output is formatted as XML and processed by 'xml_pp' for readability. Requires 'xml_pp' to be installed. ```bash $ curl -X PROPFIND -H "Depth: 1" -u user:pass https://example.com/nextcloud/remote.php/dav/files/USERNAME/ | xml_pp ``` ```xml /nextcloud/remote.php/dav/files/USERNAME/ Tue, 13 Oct 2015 17:07:45 GMT 163 11802275840 "561d3a6139d05" HTTP/1.1 200 OK /nextcloud/remote.php/dav/files/USERNAME/welcome.txt Tue, 13 Oct 2015 17:07:35 GMT 163 "47465fae667b2d0fee154f5e17d1f0f1" text/plain HTTP/1.1 200 OK ``` -------------------------------- ### Windows Non-Interactive Provisioning Example Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/desktop/massdeployment.rst Use this command on Windows to provision the Nextcloud client non-interactively, specifying the local sync directory and server URL. ```bash "C:\Program Files\Nextcloud\nextcloud.exe" --overridelocaldir "D:/work/nextcloud-sync-folder" --overrideserverurl https://cloud.example.com ``` -------------------------------- ### Configure Redis for Distributed and Locking Caches Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_server/caching_configuration.rst Recommended for organizations with single-server deployments. This setup uses APCu for local caching and Redis for distributed and locking caches. Ensure Redis is installed and configured. ```php 'memcache.local' => '\OC\Memcache\APCu', 'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => [ 'host' => 'localhost', 'port' => 6379, ], ``` -------------------------------- ### Get Access Control List (ACL) for Calendar Event Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/groupware/calendar_provider.rst Obtains the Access Control List (ACL) for the calendar event. This example delegates the calculation to the associated calendar class, assuming inherited ACLs. ```php calendar->getACL(); } ``` -------------------------------- ### Create Build Directory Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/desktop/building.rst Navigate to the cloned repository and create a build directory. ```bash % cd ~/Repositories/desktop % mkdir build ``` -------------------------------- ### Install GOSU and Configure Service User in Dockerfile Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/exapp_development/development_overview/ExAppHarpIntegration.rst This snippet shows how to install GOSU, create a service user, and prepare necessary directories and configuration files for the service user within a Dockerfile. It ensures that runtime files like `/frpc.toml` and `/certs/frp` are accessible and writable by the non-root user. ```dockerfile FROM python:3.12-alpine AS app ARG USER=serviceuser ENV USER=$USER ENV HOME=/home/$USER ENV GOSU_VERSION=1.19 # Install dependencies and create service user. You might want to # add additional packages depending on your app requirements. # Make sure curl and FRP are installed. RUN apk update && \ apk add --no-cache curl frp ca-certificates && \ adduser -D $USER && \ touch /frpc.toml && \ mkdir -p /certs/frp && \ chown $USER:$USER /frpc.toml && \ chown -R $USER:$USER /certs/frp && \ chmod 600 /frpc.toml # Install GOSU RUN set -eux; \ \ apk add --no-cache --virtual .gosu-deps \ ca-certificates \ dpkg \ gnupg \ ; \ \ dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ \ export GNUPGHOME="$(mktemp -d)"; \ gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ gpgconf --kill all; \ rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ \ apk del --no-network .gosu-deps; \ \ chmod +x /usr/local/bin/gosu WORKDIR /app # Copy your app code COPY --chown=$USER:$USER . # Copy the start.sh script and make it executable COPY --chown=$USER:$USER start.sh /start.sh RUN chmod +x /start.sh && \ chown -R $USER:$USER /app && \ pip install -r requirements.txt # Run the start.sh as entrypoint with non-root user and point it to your app ENTRYPOINT ["/bin/sh", "-c", "exec gosu \"$USER\" /start.sh python3 -u main.py"] ``` -------------------------------- ### ExApp Heartbeat Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/exapp_development/development_overview/ExAppLifecycle.rst The GET /heartbeat method is called periodically by Nextcloud to check the ExApp health status. It should respond with HTTP status 200. This endpoint does not require AppAPIAuth authentication and has a 10-minute timeout for the ExApp to start up. ```APIDOC ## GET /heartbeat ### Description Checks the ExApp's health status to ensure its webserver is running and receiving requests. ### Method GET ### Endpoint http://localhost:2345/heartbeat ### Parameters None ### Request Example None ### Response #### Success Response (200) AppAPI expects a response with HTTP status 200. #### Response Example None ``` -------------------------------- ### Enable PHP modules and start PHP-FPM Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/example_openbsd.rst Symlinks all available PHP modules to the active configuration directory and enables/starts the PHP-FPM service. ```bash # cd /etc/php-8.2.sample # for i in *; do ln -sf ../php-8.2.sample/$i ../php-8.2/; done # rcctl enable php82_fpm # rcctl start php82_fpm ``` -------------------------------- ### Implement a Custom Search Provider Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/search.rst Implement the ` OCP Search IProvider` interface to create a custom search provider. This example shows the basic structure, including methods for getting the provider ID, name, order, and performing the search. ```php l->t('My custom group'); } public function getOrder(string $route, array $routeParameters): int { if (str_contains($route, Application::APP_ID)) { // Active app, prefer my results return -1; } return 55; } public function search(IUser $user, ISearchQuery $query): SearchResult { return SearchResult::complete( 'My custom group', // TODO: this should be translated [ ... ] ); } } ``` -------------------------------- ### Task Creation Example Source: https://github.com/nextcloud/documentation/blob/master/developer_manual/digging_deeper/task_processing.rst Demonstrates creating a new Task object for a specific task type, providing input, app ID, user ID, and a custom ID. ```php // getAvailableTaskTypeIds is faster than getAvailableTaskTypes // (isset($textprocessingManager->getAvailableTaskTypes()[TextToTextSummary::ID]) { // if you don't need the task type metadata, prefer this: if (in_array(TextToTextSummary::ID, $textprocessingManager->getAvailableTaskTypeIds(), true) { $summaryTask = new Task(TextToTextSummary::ID, $emailText, "my_app", $userId, (string) $emailId); } else { // cannot use summarization } ``` -------------------------------- ### Copying Vector DB Logs from Docker Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/ai/app_context_chat.rst Use this command to copy PostgreSQL Vector DB logs from a running Docker container to the host system for analysis. This is useful when the automated setup fails with errors like 'pg_ctl: could not start server'. ```bash docker cp nc_app_context_chat_backend:/nc_app_context_chat_backend_data/vector_db_data/pgsql/logfile /tmp/vectordb-logfile ``` -------------------------------- ### Llama 3 Configuration Example Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/ai/app_llm2.rst Example JSON configuration for a Llama 3 model, including prompt format, loader settings, and temperature. Ensure '{system_prompt}' and '{user_prompt}' are included. ```json { "prompt": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n{system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|>\n{user_prompt}<|eot_id|>\n<|start_header_id|>assistant<|end_header_id|>\n", "loader_config": { "n_ctx": 8000, "max_tokens": 4000, "stop": ["<|eot_id|>"], "temperature": 0.3 } } ``` -------------------------------- ### Configure All Parameters for Automatic Setup Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/automatic_configuration.rst Provide all necessary parameters in the autoconfig.php file to completely bypass the Nextcloud setup screen. This includes database, admin credentials, and data directory. ```php "mysql", "dbname" => "nextcloud", "dbuser" => "username", "dbpass" => "password", "dbhost" => "localhost", "dbtableprefix" => "", "adminlogin" => "root", "adminpass" => "root-password", "directory" => "/www/htdocs/nextcloud/data", ); ``` -------------------------------- ### Configure Amazon S3 Primary Storage Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_files/primary_storage.rst Example configuration for using Amazon S3 as the primary object store. Ensure all required parameters like bucket, key, and secret are provided. Optional parameters like region, hostname, and port may need adjustment based on your S3 setup. ```php 'objectstore' => [ 'class' => '\\OC\\Files\\ObjectStore\\S3', 'arguments' => [ 'bucket' => 'my-nextcloud-store', 'hostname' => 's3.example.com', 'key' => 'EJ39ITYZEUH5BGWDRUFY', 'secret' => 'M5MrXTRjkyMaxXPe2FRXMTfTfbKEnZCu+7uRTVSj', 'port' => 8443, // required for some non-Amazon S3 implementations 'use_path_style' => true, ], ], ``` -------------------------------- ### Install an App Source: https://github.com/nextcloud/documentation/blob/master/admin_manual/occ_apps.rst Installs a specified app. Options include keeping the app disabled after installation or forcing installation regardless of Nextcloud version requirements. ```APIDOC ## Install an App Download and install an app:: sudo -E -u www-data php occ app:install twofactor_totp Install but don't enable:: sudo -E -u www-data php occ app:install --keep-disabled twofactor_totp Install regardless of the Nextcloud version requirement:: sudo -E -u www-data php occ app:install --force twofactor_totp ```