github.com/rohankumardubey/proxyfs@v0.0.0-20210108201508-653efa9ab00e/sait/bin/start_proxyfs_and_swift (about) 1 #!/bin/bash 2 3 if [ "$1" == "1" ] 4 then 5 PRIVATE_IP_ADDR="192.168.22.114" 6 VOLUME_TO_SERVE="CommonVolume" 7 elif [ "$1" == "2" ] 8 then 9 PRIVATE_IP_ADDR="192.168.22.115" 10 VOLUME_TO_SERVE="" 11 elif [ "$1" == "3" ] 12 then 13 PRIVATE_IP_ADDR="192.168.22.116" 14 VOLUME_TO_SERVE="" 15 else 16 echo Arg1 is unexpected: $1 17 exit 1 18 fi 19 20 SAIT_DIR=sait$1 21 22 function await_proxyfsd_startup { 23 while true 24 do 25 /usr/bin/systemctl -q is-active proxyfsd 26 if [ $? -ne 0 ] 27 then 28 echo "ProxyFS failed to start. Exiting..." 29 exit 1 30 fi 31 curl http://$PRIVATE_IP_ADDR:15346/ 2>/dev/null >/dev/null 32 if [ $? -eq 0 ] 33 then 34 break 35 fi 36 sleep 1 37 done 38 } 39 40 function await_swift_startup { 41 while true 42 do 43 curl http://127.0.0.1:8090/info 2>/dev/null >/dev/null 44 if [ $? -eq 0 ] 45 then 46 break 47 fi 48 echo "Waiting for Swift to be started..." 49 sleep 1 50 done 51 } 52 53 function format_volume_if_necessary { 54 if [ "" != "$1" ] 55 then 56 sudo /vagrant/bin/mkproxyfs -I $1 /vagrant/src/github.com/swiftstack/ProxyFS/sait/$SAIT_DIR/proxyfs.conf SwiftClient.RetryLimit=1 57 if [ $? -ne 0 ] 58 then 59 echo "Could not pre-format $1" 60 exit 1 61 fi 62 fi 63 } 64 65 sudo mount -a 66 67 echo "Shutting down services and mount points..." 68 /vagrant/src/github.com/swiftstack/ProxyFS/sait/bin/unmount_and_stop_pfs 69 echo 70 echo "Bringing up services..." 71 if [ -f /usr/bin/systemctl ]; then 72 # Centos 73 sudo /usr/bin/systemctl start memcached 74 sudo /usr/bin/swift-init main start 75 await_swift_startup 76 format_volume_if_necessary $VOLUME_TO_SERVE 77 sudo /usr/bin/systemctl start proxyfsd 78 await_proxyfsd_startup 79 else 80 # Ubuntu (not tested!) 81 sudo /usr/sbin/service memcached start 82 sudo /usr/bin/swift-init main start 83 await_swift_startup 84 format_volume_if_necessary $VOLUME_TO_SERVE 85 sudo /usr/sbin/service proxyfsd start 86 await_proxyfsd_startup 87 fi