Fix issue with key/secret on multinode

This commit is contained in:
Micke Nordin 2023-02-27 18:01:38 +01:00
parent 1588d5869b
commit 88f7c95679
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257

View file

@ -24,14 +24,20 @@ fi
echo "$(date): Start executing create_bucket.sh ${1} ${2} ${3}" echo "$(date): Start executing create_bucket.sh ${1} ${2} ${3}"
key=$(grep access_key_id /opt/nextcloud/rclone.conf | awk '{print $3}') rclone_config="/opt/nextcloud/rclone.conf"
secret=$(grep secret_access_key /opt/nextcloud/rclone.conf | awk '{print $3}') if [[ "${container}" != "nextcloud_app_1" ]]; then
endpoint=$(grep endpoint /opt/nextcloud/rclone.conf | awk '{print $3}') customer=$(echo "${container}" | sed -e 's/^nextcloud//' -e 's/_app_1$//')
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/multinode/${customer}/rclone.conf"
fi
if [[ "x${preexisting}" == "x" ]]; then key=$(grep access_key_id "${rclone_config}" | awk '{print $3}')
docker exec -u www-data -i ${container} php --define apc.enable_cli=1 /var/www/html/occ files_external:create ${user_bucket_name} \ secret=$(grep secret_access_key "${rclone_config}"| awk '{print $3}')
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 \ 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} 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 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 docker exec -u www-data -i ${container} php --define apc.enable_cli=1 /var/www/html/occ files_external:option ${shareid} enable_sharing true