From b63993e487454c938bce2ed750413fd7efa83ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 8 Dec 2021 01:37:42 +0100 Subject: [PATCH] Support setting NEXTCLOUD_AUTH_TOKEN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows to set up the nextcloud auth token during install. Purpose is to make the install smoother by exposing it and have server info and metrics available to verify the status of the install. As this is only supported in v22 and later, for now a version check is included. Signed-off-by: Manuel RĂ¼ger --- 21/apache/entrypoint.sh | 5 +++++ 21/fpm-alpine/entrypoint.sh | 5 +++++ 21/fpm/entrypoint.sh | 5 +++++ 22/apache/entrypoint.sh | 5 +++++ 22/fpm-alpine/entrypoint.sh | 5 +++++ 22/fpm/entrypoint.sh | 5 +++++ 23/apache/entrypoint.sh | 5 +++++ 23/fpm-alpine/entrypoint.sh | 5 +++++ 23/fpm/entrypoint.sh | 5 +++++ README.md | 1 + docker-entrypoint.sh | 5 +++++ 11 files changed, 51 insertions(+) diff --git a/21/apache/entrypoint.sh b/21/apache/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/21/apache/entrypoint.sh +++ b/21/apache/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/21/fpm-alpine/entrypoint.sh b/21/fpm-alpine/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/21/fpm-alpine/entrypoint.sh +++ b/21/fpm-alpine/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/21/fpm/entrypoint.sh b/21/fpm/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/21/fpm/entrypoint.sh +++ b/21/fpm/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/22/apache/entrypoint.sh b/22/apache/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/22/apache/entrypoint.sh +++ b/22/apache/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/22/fpm-alpine/entrypoint.sh b/22/fpm-alpine/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/22/fpm-alpine/entrypoint.sh +++ b/22/fpm-alpine/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/22/fpm/entrypoint.sh b/22/fpm/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/22/fpm/entrypoint.sh +++ b/22/fpm/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/23/apache/entrypoint.sh b/23/apache/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/23/apache/entrypoint.sh +++ b/23/apache/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/23/fpm-alpine/entrypoint.sh b/23/fpm-alpine/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/23/fpm-alpine/entrypoint.sh +++ b/23/fpm-alpine/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/23/fpm/entrypoint.sh b/23/fpm/entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/23/fpm/entrypoint.sh +++ b/23/fpm/entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi diff --git a/README.md b/README.md index 28edcce96f..9f99820e7b 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ If you set any group of values (i.e. all of `MYSQL_DATABASE`, `MYSQL_USER`, `MYS - `NEXTCLOUD_ADMIN_USER` Name of the Nextcloud admin user. - `NEXTCLOUD_ADMIN_PASSWORD` Password for the Nextcloud admin user. +- `NEXTCLOUD_AUTH_TOKEN` Authentication token to access server info. If you want, you can set the data directory, otherwise default value will be used. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index b6da893b07..4e7b16ce4a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -174,6 +174,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi + file_env NEXTCLOUD_AUTH_TOKEN + if [ -n "${NEXTCLOUD_AUTH_TOKEN+x}" ] && version_greater "$image_version" "21.99.99.99"; then + echo "setting auth token" + run_as "php /var/www/html/occ config:app:set serverinfo token --value $NEXTCLOUD_AUTH_TOKEN" + fi else echo "running web-based installer on first connect!" fi