From 88f7c956792f27291f069a4157c94117f7c3c8c3 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 27 Feb 2023 18:01:38 +0100 Subject: [PATCH] Fix issue with key/secret on multinode --- templates/scriptreceiver/create_bucket.erb.sh | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/templates/scriptreceiver/create_bucket.erb.sh b/templates/scriptreceiver/create_bucket.erb.sh index a64a8f8..b21f487 100755 --- a/templates/scriptreceiver/create_bucket.erb.sh +++ b/templates/scriptreceiver/create_bucket.erb.sh @@ -24,14 +24,20 @@ fi echo "$(date): Start executing create_bucket.sh ${1} ${2} ${3}" -key=$(grep access_key_id /opt/nextcloud/rclone.conf | awk '{print $3}') -secret=$(grep secret_access_key /opt/nextcloud/rclone.conf | awk '{print $3}') -endpoint=$(grep endpoint /opt/nextcloud/rclone.conf | awk '{print $3}') -preexisting="$(docker exec -u www-data -i ${container} php --define apc.enable_cli=1 /var/www/html/occ files_external:list --output json ${user} | jq -r '.[] | .configuration.bucket' | grep ${bucket})" +rclone_config="/opt/nextcloud/rclone.conf" +if [[ "${container}" != "nextcloud_app_1" ]]; then + customer=$(echo "${container}" | sed -e 's/^nextcloud//' -e 's/_app_1$//') + rclone_config="/opt/multinode/${customer}/rclone.conf" +fi -if [[ "x${preexisting}" == "x" ]]; then - docker exec -u www-data -i ${container} php --define apc.enable_cli=1 /var/www/html/occ files_external:create ${user_bucket_name} \ - amazons3 -c bucket=${bucket} -c key=${key} -c secret=${secret} -c hostname=${endpoint} -c use_ssl=true -c use_path_style=true -c region=us-east-1 \ +key=$(grep access_key_id "${rclone_config}" | awk '{print $3}') +secret=$(grep secret_access_key "${rclone_config}"| awk '{print $3}') +endpoint=$(grep endpoint "${rclone_config}" | awk '{print $3}') +preexisting="$(docker exec -u www-data -i "${container}" php --define apc.enable_cli=1 /var/www/html/occ files_external:list --output json "${user}" | jq -r '.[] | .configuration.bucket' | grep "${bucket}")" + +if [[ -z ${preexisting} ]]; then + docker exec -u www-data -i "${container}" php --define apc.enable_cli=1 /var/www/html/occ files_external:create "${user_bucket_name}" \ + amazons3 -c bucket="${bucket}" -c key="${key}" -c secret="${secret}" -c hostname="${endpoint}" -c use_ssl=true -c use_path_style=true -c region=us-east-1 \ amazons3::accesskey --user ${user} for shareid in $(docker exec -u www-data -i ${container} php --define apc.enable_cli=1 /var/www/html/occ files_external:export ${user} | jq -r '.[].mount_id'); do docker exec -u www-data -i ${container} php --define apc.enable_cli=1 /var/www/html/occ files_external:option ${shareid} enable_sharing true