github.com/swiftstack/proxyfs@v0.0.0-20201223034610-5434d919416e/cookbooks/proxyfs/files/default/usr/bin/set_up_s3api (about)

     1  #!/bin/bash
     2  
     3  PROXYSERVERCONF=/etc/swift/proxy-server.conf
     4  # [filter:s3api] is found by default in /etc/swift/proxy-server.conf, so we'll
     5  # look for one of the options that are not set by default: allow_multipart_uploads
     6  
     7  # Careful! This method is not totally safe, as [filter:swift3] also defines this
     8  # option, but we control the whole process, and this script should be run BEFORE
     9  # set_up_swift3 during Runway provisioning, so we should be fine. If anybody
    10  # else is messing with this, they should know what they're doing.
    11  grep "allow_multipart_uploads" $PROXYSERVERCONF > /dev/null 2>&1
    12  if [ $? -eq 0 ]; then
    13      echo "s3api is already set up. No need to do anything. Run enable_s3api to enable this configuration."
    14      exit 0
    15  fi
    16  
    17  set -e
    18  
    19  sed -i '/^dns_compliant_bucket_names/ s/dns_compliant_bucket_names = no/dns_compliant_bucket_names = yes/' $PROXYSERVERCONF
    20  sed -i '/^\[filter:s3api/ a allow_multipart_uploads = yes\nforce_swift_request_proxy_log = yes' $PROXYSERVERCONF
    21  
    22  # We're only setting up tempauth and the object servers during s3api set up
    23  # When we set up swift3, everything will be already in place
    24  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
    25  for i in /etc/swift/object-server/*; do
    26      if test -f "$i"; then
    27          filename=`basename $i`
    28          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
    29      fi
    30  done
    31  
    32  echo "Swift was configured successfully for s3api, but NOT ENABLED YET. In order to enable it, run:"
    33  echo "    enable_s3api"