#!/bin/bash

# Print all commands and their arguments as they are executed.
set -x

# Set the Redis configuration
php /var/www/html/occ --no-warnings config:system:set redis host --value="nextcloud-redis"
php /var/www/html/occ --no-warnings config:system:set redis port --value="6379"
php /var/www/html/occ --no-warnings config:system:set memcache.local --value="\OC\Memcache\APCu"
php /var/www/html/occ --no-warnings config:system:set memcache.distributed --value="\OC\Memcache\Redis"
php /var/www/html/occ --no-warnings config:system:set memcache.locking --value="\OC\Memcache\Redis"

# Set trusted proxies
php /var/www/html/occ --no-warnings config:system:set trusted_proxies 0 --value="172.16.0.0/12"
php /var/www/html/occ --no-warnings config:system:set trusted_proxies 1 --value="192.168.0.0/16"
php /var/www/html/occ --no-warnings config:system:set trusted_proxies 2 --value="10.0.0.0/8"

# Set trusted domains. Add more domains as needed, i.e. for reverse proxy, etc.
php /var/www/html/occ --no-warnings config:system:set trusted_domains 0 --value="localhost"
php /var/www/html/occ --no-warnings config:system:set trusted_domains 1 --value="my.domain.tld"
php /var/www/html/occ --no-warnings config:system:set trusted_domains 3 --value="nextcloud-reverse-proxy"
php /var/www/html/occ --no-warnings config:system:set trusted_domains 4 --value="onlyoffice-documentserver"
php /var/www/html/occ --no-warnings config:system:set trusted_domains 5 --value="nextcloud"

# Set the default phone region
php /var/www/html/occ --no-warnings config:system:set default_phone_region --value="DE"

# Set maintenance time
php /var/www/html/occ --no-warnings config:system:set maintenance_window_start --type=integer --value=1

# Set the CLI URL
php /var/www/html/occ --no-warnings config:system:set overwrite.cli.url --value="https://my.domain.tld"
