From aa2cb7fe511892a4c307e9f8b2395c917ab0ff9b Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 11:54:59 +0200 Subject: [PATCH 1/7] feat(configure): add import_app_config helper for batched config import Introduces import_app_config() which pipes a JSON string to `occ config:import`, allowing multiple app/system config values to be set in a single PHP process invocation instead of one occ call per key. --- configure.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configure.sh b/configure.sh index 2214ea8..a240792 100755 --- a/configure.sh +++ b/configure.sh @@ -221,6 +221,20 @@ check_dependencies() { fi } +# Import app/system configuration from a JSON string via occ config:import. +# Equivalent to piping a config:export-formatted JSON into occ config:import. +# Usage: import_app_config +import_app_config() { + if [ "${VERBOSE_OCC_LOGGING}" = "true" ]; then + echo "[i] Executing OCC command: config:import" >&2 + echo "occ config:import" >> "${OCC_LOG_FILE}" 2>&1 + fi + if ! echo "${1}" | php occ config:import; then + log_error "Failed to execute OCC command: config:import" + return 1 + fi +} + # Verify Nextcloud Workspace installation status # Usage: verify_nextcloud_installation verify_nextcloud_installation() { From 0f449068e63475a679211528df81908085733965 Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 11:55:15 +0200 Subject: [PATCH 2/7] refactor(configure): migrate richdocuments config to occ config:import Replace 5-6 individual config:app:set calls in configure_collabora_app() with a single import_app_config call built via jq. Sensitive-free values (wopi_url, enabled, cert verification, allowlist) are batched into one JSON import. app:disable, app:enable and richdocuments:activate-config remain as individual OCC calls. --- configure.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/configure.sh b/configure.sh index a240792..646c294 100755 --- a/configure.sh +++ b/configure.sh @@ -291,22 +291,31 @@ configure_collabora_app() { # Configure and enable Collabora execute_occ_command app:enable richdocuments - execute_occ_command config:app:set richdocuments wopi_url --value="${COLLABORA_WOPI_URL}" - execute_occ_command config:app:set richdocuments public_wopi_url --value="${COLLABORA_WOPI_URL}" - execute_occ_command config:app:set richdocuments enabled --value='yes' + + _cert_verify="no" + if [ "${COLLABORA_SELF_SIGNED}" = "true" ]; then + _cert_verify="yes" + fi + + _config=$(jq -n \ + --arg wopi_url "${COLLABORA_WOPI_URL}" \ + --arg cert_verify "${_cert_verify}" \ + '{apps: {richdocuments: { + wopi_url: $wopi_url, + public_wopi_url: $wopi_url, + enabled: "yes", + disable_certificate_verification: $cert_verify + }}}') if [ "${COLLABORA_WOPI_ALLOWLIST}" ]; then - execute_occ_command config:app:set richdocuments wopi_allowlist --value="${COLLABORA_WOPI_ALLOWLIST}" + _config=$(echo "${_config}" | jq \ + --arg allowlist "${COLLABORA_WOPI_ALLOWLIST}" \ + '.apps.richdocuments.wopi_allowlist = $allowlist') else log_warning "COLLABORA_WOPI_ALLOWLIST environment variable is not set. Collabora WOPI allowlist will not be configured." fi - # Configure SSL certificate verification - if [ "${COLLABORA_SELF_SIGNED}" = "true" ]; then - execute_occ_command config:app:set richdocuments disable_certificate_verification --value="yes" - else - execute_occ_command config:app:set richdocuments disable_certificate_verification --value="no" - fi + import_app_config "${_config}" execute_occ_command richdocuments:activate-config } From aa3bf1bf75e2b98d7d3ec9d3dbde5c0b49cbc5ba Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 11:55:27 +0200 Subject: [PATCH 3/7] refactor(configure): migrate files_antivirus config to occ config:import Replace 5 individual config:app:set calls in configure_files_antivirus_app() with a single import_app_config call built via jq. --- configure.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/configure.sh b/configure.sh index 646c294..351db6a 100755 --- a/configure.sh +++ b/configure.sh @@ -354,11 +354,18 @@ configure_files_antivirus_app() { fi # Configure clamav with validated values - execute_occ_command config:app:set files_antivirus av_mode --value="daemon" - execute_occ_command config:app:set files_antivirus av_host --value="${CLAMAV_HOST:-clamav.clamav}" - execute_occ_command config:app:set files_antivirus av_port --value="${CLAMAV_PORT:-3310}" - execute_occ_command config:app:set files_antivirus av_max_file_size --value="${CLAMAV_MAX_FILE_SIZE:-314572800}" - execute_occ_command config:app:set files_antivirus av_stream_max_length --value="${CLAMAV_MAX_STREAM_LENGTH:-314572800}" + import_app_config "$(jq -n \ + --arg host "${CLAMAV_HOST:-clamav.clamav}" \ + --arg port "${CLAMAV_PORT:-3310}" \ + --arg max_file_size "${CLAMAV_MAX_FILE_SIZE:-314572800}" \ + --arg max_stream "${CLAMAV_MAX_STREAM_LENGTH:-314572800}" \ + '{apps: {files_antivirus: { + av_mode: "daemon", + av_host: $host, + av_port: $port, + av_max_file_size: $max_file_size, + av_stream_max_length: $max_stream + }}}')" execute_occ_command app:enable files_antivirus From 46eaec90461ae052953463a971af91c8b64dc703 Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 11:55:38 +0200 Subject: [PATCH 4/7] refactor(configure): migrate mail config to occ config:import Replace 2 non-sensitive config:app:set calls in configure_ionos_mailconfig_api() with a single import_app_config call. ionos_mailconfig_api_auth_pass remains as an individual --sensitive call. --- configure.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/configure.sh b/configure.sh index 351db6a..0100a44 100755 --- a/configure.sh +++ b/configure.sh @@ -583,8 +583,13 @@ configure_ionos_mailconfig_api() { log_info "EXT_REF: ${EXT_REF}" log_info "CUSTOMER_DOMAIN: ${CUSTOMER_DOMAIN}" - execute_occ_command config:app:set --value "${IONOS_MAILCONFIG_API_URL}" --type string mail ionos_mailconfig_api_base_url - execute_occ_command config:app:set --value "${IONOS_MAILCONFIG_API_USER}" --type string mail ionos_mailconfig_api_auth_user + import_app_config "$(jq -n \ + --arg url "${IONOS_MAILCONFIG_API_URL}" \ + --arg user "${IONOS_MAILCONFIG_API_USER}" \ + '{apps: {mail: { + ionos_mailconfig_api_base_url: $url, + ionos_mailconfig_api_auth_user: $user + }}}')" execute_occ_command config:app:set --value "${IONOS_MAILCONFIG_API_PASS}" --sensitive --type string mail ionos_mailconfig_api_auth_pass execute_occ_command config:app:set --value yes --type string mail ionos-mailconfig-enabled From 077d0e9af54568d52e91e1732d71affcac989c35 Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 11:55:56 +0200 Subject: [PATCH 5/7] refactor(configure): migrate integration_openai config to occ config:import Replace 5 config:app:set calls and 2 set_app_config_typed calls (each with an extra config:list read) in configure_ionos_ai_model_hub() with a single import_app_config call. Also batches ai.taskprocessing_guests (settings app). api_key remains as an individual --sensitive call. --- configure.sh | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/configure.sh b/configure.sh index 0100a44..170220e 100755 --- a/configure.sh +++ b/configure.sh @@ -610,29 +610,26 @@ configure_ionos_ai_model_hub() { # Configure AI Model Hub settings for integration_openai app # Using Bearer token authentication (JWT format) - execute_occ_command config:app:set --value "${IONOSAI_URL}" --type string integration_openai url + import_app_config "$(jq -n \ + --arg url "${IONOSAI_URL}" \ + --arg max_tokens "${IONOSAI_MAX_TOKENS:-1000}" \ + --arg use_max "${IONOSAI_USE_MAX_COMPLETION_TOKENS_PARAM:-0}" \ + --arg text_model "${IONOSAI_TEXT_MODEL:-openai/gpt-oss-120b}" \ + --arg image_model "${IONOSAI_IMAGE_MODEL:-black-forest-labs/FLUX.1-schnell}" \ + '{apps: { + integration_openai: { + url: $url, + max_tokens: $max_tokens, + use_max_completion_tokens_param: $use_max, + default_completion_model_id: $text_model, + default_image_model_id: $image_model + }, + settings: {"ai.taskprocessing_guests": "false"} + }}')" execute_occ_command config:app:set --value "${IONOSAI_TOKEN}" --sensitive --type string integration_openai api_key - # Configure max_tokens (app stores as string internally) - _max_tokens="${IONOSAI_MAX_TOKENS:-1000}" - set_app_config_typed integration_openai max_tokens "${_max_tokens}" string - - # Set use_max_completion_tokens_param (1=enabled, 0=disabled) - # Default is 0 for non-OpenAI services (app stores as string '1' or '0') - _use_max_completion_tokens_param="${IONOSAI_USE_MAX_COMPLETION_TOKENS_PARAM:-0}" - set_app_config_typed integration_openai use_max_completion_tokens_param "${_use_max_completion_tokens_param}" string - - # Configure default text-to-text model - _text_model="${IONOSAI_TEXT_MODEL:-openai/gpt-oss-120b}" - execute_occ_command config:app:set --value "${_text_model}" --type string integration_openai default_completion_model_id - - # Configure default text-to-image model - _image_model="${IONOSAI_IMAGE_MODEL:-black-forest-labs/FLUX.1-schnell}" - execute_occ_command config:app:set --value "${_image_model}" --type string integration_openai default_image_model_id - # Set AI assistant settings log_info "Configuring AI Assistant settings... " - execute_occ_command config:app:set --value false settings ai.taskprocessing_guests _deactivated_tasks=" core:generateemoji From 5501e29bd635c2ac376b714bfb07d6b344c659bf Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 12:18:00 +0200 Subject: [PATCH 6/7] feat(configure): add enable_apps helper for batch app enabling Introduces enable_apps() which passes all arguments to a single `occ app:enable` call, allowing multiple apps to be enabled in one PHP process invocation. --- configure.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/configure.sh b/configure.sh index 170220e..c141f4e 100755 --- a/configure.sh +++ b/configure.sh @@ -209,6 +209,13 @@ enable_app() { execute_occ_command app:enable "${_app_name}" } +# Enable multiple Nextcloud apps in a single OCC call +# Usage: enable_apps ... +enable_apps() { + log_info "Enabling apps: ${*}" + execute_occ_command app:enable "${@}" +} + # Check if required dependencies are available # Usage: check_dependencies check_dependencies() { From 8ce0645bfbbd2a7bc4c449d28627575f98eb7f98 Mon Sep 17 00:00:00 2001 From: "Misha M.-Kupriyanov" Date: Tue, 31 Mar 2026 12:18:17 +0200 Subject: [PATCH 7/7] refactor(configure): batch app:enable calls in configure_apps() Replace 17 individual enable_app() calls with 2 enable_apps() calls, reducing OCC invocations from 17 to 2 for app activation. Apps with surrounding conditional logic (richdocuments, notify_push, files_antivirus, spreed) remain as individual enables in their own configure_*() functions. --- configure.sh | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/configure.sh b/configure.sh index c141f4e..9504bd1 100755 --- a/configure.sh +++ b/configure.sh @@ -727,17 +727,10 @@ configure_apps() { log_info "Configuring Nextcloud apps..." # Enable core productivity apps - enable_app calendar "Calendar" - enable_app circles "Circles" - enable_app activity "Activity" - enable_app contacts "Contacts" - enable_app twofactor_totp "Two-Factor AuthenticationTOTP" - enable_app end_to_end_encryption "End-to-End Encryption" - enable_app mail "Mail" - enable_app notifications "Notifications" - enable_app tasks "Tasks" - enable_app text "Text" - enable_app ncw_apps_menu "NCW Apps Menu" + enable_apps \ + calendar circles activity contacts twofactor_totp \ + end_to_end_encryption mail notifications tasks text \ + ncw_apps_menu # Configure specialized apps @@ -751,12 +744,9 @@ configure_apps() { configure_spreed_app # Enable additional apps - enable_app ncw_mailtemplate "NCW Mail Template" - enable_app groupfolders "Group Folders" - enable_app assistant "Assistant" - enable_app integration_openai "OpenAI Integration" - enable_app ncw_tools "Task Processing" - enable_app files_pdfviewer "Files-PdfViewer" + enable_apps \ + ncw_mailtemplate groupfolders assistant \ + integration_openai ncw_tools files_pdfviewer # Configure admin features configure_admin_delegation