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

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  usage() {
     6      echo "Usage: $0 [s3 library name]"
     7      echo "s3 library name options:"
     8      echo "    s3api"
     9      echo "    swift3"
    10      exit 1
    11  }
    12  
    13  if [ $# -gt 0 ]; then
    14      LIBRARY="$1"
    15      LIBRARY=${LIBRARY,,}
    16      if [ "$LIBRARY" != "s3api" ] && [ "$LIBRARY" != "swift3" ]; then
    17          if [ "$LIBRARY" != "-h" ] && [ "$LIBRARY" != "--help" ]; then
    18              echo "Invalid argument '$1'."
    19              echo
    20          fi
    21          usage
    22      fi
    23  else
    24      usage
    25  fi
    26  
    27  PROXYSERVERCONF=/etc/swift/proxy-server.conf
    28  
    29  # Making sure there's no other s3api/swift3 already enabled
    30  sed -i '/^pipeline/ s/swift3 tempauth/tempauth/' $PROXYSERVERCONF
    31  sed -i '/^pipeline/ s/s3api tempauth/tempauth/' $PROXYSERVERCONF
    32  # Enabling s3 library
    33  sed -i "/^pipeline/ s/tempauth/${LIBRARY} tempauth/" $PROXYSERVERCONF
    34  
    35  echo "${LIBRARY} was successfully enabled. Remember to restart Swift or just run:"
    36  echo "    start_and_mount_pfs keepmounts"