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