github.com/swiftstack/ProxyFS@v0.0.0-20210203235616-4017c267d62f/cookbooks/proxyfs/files/default/usr/bin/start_proxyfsd_only (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 or stop proxyfsd
     7  # The PATH, etc should already be setup by systemctl environment
     8  
     9  function await_proxyfsd_startup {
    10      /usr/bin/systemctl -q is-active proxyfsd
    11      if [ $? -ne 0 ]
    12      then
    13          echo "ProxyFS failed to start. Exiting..."
    14          exit 1
    15      fi
    16      while true
    17      do
    18          curl http://127.0.0.1:15346/ 2>/dev/null >/dev/null
    19          if [ $? -eq 0 ]
    20          then
    21              break
    22          fi
    23          echo "Waiting for ProxyFS to be started..."
    24          sleep 1
    25      done
    26  }
    27  
    28  function await_pfsagentd_shutdown {
    29      while true
    30      do
    31          pidof pfsagentd > /dev/null
    32          if [ $? -ne 0 ]
    33          then
    34              break
    35          fi
    36          echo "Waiting for PFSAgent to be stopped..."
    37          sleep 1
    38      done
    39  }
    40  
    41  if [ -f /usr/bin/systemctl ]; then
    42      # Centos
    43      sudo /usr/bin/systemctl stop pfsagentd
    44      await_pfsagentd_shutdown
    45      sudo /usr/bin/systemctl start proxyfsd
    46      await_proxyfsd_startup
    47  else
    48      # Ubuntu (not tested!)
    49      sudo /usr/sbin/service proxyfsd start
    50      await_proxyfsd_startup
    51  fi