github.com/swiftstack/ProxyFS@v0.0.0-20210203235616-4017c267d62f/saio/bin/start_proxyfs_and_swift (about)

     1  #!/bin/bash
     2  
     3  # Copyright (c) 2015-2021, NVIDIA CORPORATION.
     4  # SPDX-License-Identifier: Apache-2.0
     5  
     6  # A simple script to start the swift services only
     7  # The PATH, etc should already be setup by systemctl environment
     8  
     9  function await_proxyfsd_startup {
    10      while true
    11      do
    12          /usr/bin/systemctl -q is-active proxyfsd
    13          if [ $? -ne 0 ]
    14          then
    15              echo "ProxyFS failed to start. Exiting..."
    16              exit 1
    17          fi
    18          curl http://127.0.0.1:15346/ 2>/dev/null >/dev/null
    19          if [ $? -eq 0 ]
    20          then
    21              break
    22          fi
    23          sleep 1
    24      done
    25  }
    26  
    27  function await_swift_startup {
    28      while true
    29      do
    30          curl http://127.0.0.1:8090/info 2>/dev/null >/dev/null
    31          if [ $? -eq 0 ]
    32          then
    33              break
    34          fi
    35          echo "Waiting for Swift to be started..."
    36          sleep 1
    37      done
    38  }
    39  
    40  function format_volume_if_necessary {
    41      sudo /vagrant/bin/mkproxyfs -I $1 /vagrant/src/github.com/swiftstack/ProxyFS/saio/proxyfs.conf SwiftClient.RetryLimit=1
    42      if [ $? -ne 0 ]
    43      then
    44          echo "Could not pre-format $1"
    45          exit 1
    46      fi
    47  }
    48  
    49  sudo mount -a
    50  
    51  echo "Shutting down services and mount points..."
    52  /vagrant/src/github.com/swiftstack/ProxyFS/saio/bin/unmount_and_stop_pfs
    53  echo
    54  echo "Bringing up services..."
    55  if [ -f /usr/bin/systemctl ]; then
    56      # Centos
    57      sudo /usr/bin/systemctl start memcached
    58      sudo /usr/bin/swift-init main start
    59      await_swift_startup
    60      format_volume_if_necessary CommonVolume
    61      sudo /usr/bin/systemctl start proxyfsd
    62      await_proxyfsd_startup
    63  else
    64      # Ubuntu (not tested!)
    65      sudo /usr/sbin/service memcached start
    66      sudo /usr/bin/swift-init main start
    67      await_swift_startup
    68      format_volume_if_necessary CommonVolume
    69      sudo /usr/sbin/service proxyfsd start
    70      await_proxyfsd_startup
    71  fi