From 2c2c46424d13c6221850a6cf49ba1807978b0ced Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 17 Jan 2024 15:59:49 +0100 Subject: [PATCH] new: dev: [nextcloud] rewrite all database values in config file This is dubious as if we need to change more than the password, than usually this means we need a full reinstall mode of nextcloud. --- nextcloud/hooks/sql_database-relation-joined | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nextcloud/hooks/sql_database-relation-joined b/nextcloud/hooks/sql_database-relation-joined index 7ae6ea7..ce02631 100755 --- a/nextcloud/hooks/sql_database-relation-joined +++ b/nextcloud/hooks/sql_database-relation-joined @@ -34,8 +34,23 @@ if [ -e "$CONFIGFILE" ] && grep "^ 'dbuser' => '" "$CONFIGFILE" >/dev/null; the quoted_user="${quoted_user//\'/\\\\\'}" quoted_password="${PASSWORD//\\/\\\\\\\\\\}" quoted_password="${quoted_password//\'/\\\\\'}" + case "$TYPE" in + mysql) + nextcloud_type="mysql";; + postgres) + nextcloud_type="pgsql";; + *) + err "Unknown type '$TYPE' for database." + exit 1 + ;; + esac + sed -ri "s/^( 'dbuser' => ')(.*)(',)$/\1${quoted_user}\3/g;\ - s/^( 'dbpassword' => ')(.*)(',)$/\1${quoted_password}\3/g;" "$CONFIGFILE" + s/^( 'dbpassword' => ')(.*)(',)$/\1${quoted_password}\3/g;\ + s/^( 'dbtype' => ')(.*)(',)$/\1${nextcloud_type}\3/g;\ + s/^( 'dbhost' => ')(.*)(',)$/\1${MASTER_TARGET_SERVICE_NAME}\3/g;\ + " "$CONFIGFILE" + else ## These variable are not used by current docker image after first install