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

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