github.com/swiftstack/ProxyFS@v0.0.0-20210203235616-4017c267d62f/cookbooks/proxyfs/files/default/usr/bin/set_up_s3api (about)

     1  #!/bin/bash
     2  
     3  # Copyright (c) 2015-2021, NVIDIA CORPORATION.
     4  # SPDX-License-Identifier: Apache-2.0
     5  
     6  PROXYSERVERCONF=/etc/swift/proxy-server.conf
     7  # [filter:s3api] is found by default in /etc/swift/proxy-server.conf, so we'll
     8  # look for one of the options that are not set by default: allow_multipart_uploads
     9  
    10  # Careful! This method is not totally safe, as [filter:swift3] also defines this
    11  # option, but we control the whole process, and this script should be run BEFORE
    12  # set_up_swift3 during Runway provisioning, so we should be fine. If anybody
    13  # else is messing with this, they should know what they're doing.
    14  grep "allow_multipart_uploads" $PROXYSERVERCONF > /dev/null 2>&1
    15  if [ $? -eq 0 ]; then
    16      echo "s3api is already set up. No need to do anything. Run enable_s3api to enable this configuration."
    17      exit 0
    18  fi
    19  
    20  set -e
    21  
    22  sed -i '/^dns_compliant_bucket_names/ s/dns_compliant_bucket_names = no/dns_compliant_bucket_names = yes/' $PROXYSERVERCONF
    23  sed -i '/^\[filter:s3api/ a allow_multipart_uploads = yes\nforce_swift_request_proxy_log = yes' $PROXYSERVERCONF
    24  
    25  # We're only setting up tempauth and the object servers during s3api set up
    26  # When we set up swift3, everything will be already in place
    27  sed -i '/^\[filter:tempauth/ a user_adminreg_adminreg = adminreg .admin .reseller_admin\nuser_testreg_testerreg = testingreg .admin\nuser_test2reg_tester2reg = testing2reg .admin\nuser_testreg_tester3reg = testing3reg' $PROXYSERVERCONF
    28  for i in /etc/swift/object-server/*; do
    29      if test -f "$i"; then
    30          filename=`basename $i`
    31          sed -i '/^\[app:object-server/ a allowed_headers = Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Expires, X-Delete-At, X-Object-Manifest, X-Robots-Tag, X-Static-Large-Object' $i
    32      fi
    33  done
    34  
    35  echo "Swift was configured successfully for s3api, but NOT ENABLED YET. In order to enable it, run:"
    36  echo "    enable_s3api"