diff --git a/nextcloud/root/etc/cont-init.d/61-trusted_domains b/nextcloud/root/etc/cont-init.d/61-trusted_domains new file mode 100644 index 000000000..755c7c5c5 --- /dev/null +++ b/nextcloud/root/etc/cont-init.d/61-trusted_domains @@ -0,0 +1,43 @@ +#!/usr/bin/with-contenv bashio + + #################### + # Initialization # + #################### + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then +LAUNCHER=`find / -name "occ" -print -quit` +fi + +bashio::log.info "Currently set trusted domains :" +$LAUNCHER config:system:get trusted_domains || bashio::log.info "Please first define an admin user before adding additional trusted domains." && exit + +if bashio::config.has_value 'trusted_domains'; then + bashio::log.info "Trusted domains set in the configuration. Refreshing domains." && \ + ################################### + # Remove previous trusted domains # + ################################### + bashio::log.info "... removing previously added trusted domain (except for first one created)" + i=2 + until [ $i -gt 5 ] + do + $LAUNCHER config:system:delete trusted_domains $i && \ + ((i=i+1)) + done + + ########################### + # Add new trusted domains # + ########################### + TRUSTEDDOMAINS=$(bashio::config 'trusted_domains') + bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}" && \ + i=2 + for domain in $TRUSTEDDOMAINS + do + bashio::log.info "... adding ${domain}" && \ + $LAUNCHER config:system:set trusted_domains $i --value=${domain} && \ + ((i=i+1)) + done +fi + +bashio::log.info "Remaining configurated trusted domains :" +bashio::log.info `$LAUNCHER config:system:get trusted_domains`