get_ps_servers.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. # Copyright Epic Games, Inc. All Rights Reserved.
  3. BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
  4. pushd "${BASH_LOCATION}" > /dev/null
  5. print_help() {
  6. echo "
  7. Tool for fetching PixelStreaming Infrastructure. If no flags are set specifying a version to fetch,
  8. the recommended version will be chosen as a default.
  9. Usage:
  10. ${0} [-h] [-v <UE version>] [-b <branch>] [-t <tag>]
  11. Where:
  12. -v Specify a version of Unreal Engine to download the recommended
  13. release for
  14. -b Specify a specific branch for the tool to download from repo
  15. -t Specify a specific tag for the tool to download from repo
  16. -h Display this help message
  17. "
  18. exit 1
  19. }
  20. while(($#)) ; do
  21. case "$1" in
  22. -h ) print_help;;
  23. -v ) UEVersion="$2"; shift 2;;
  24. -b ) PSInfraTagOrBranch="$2"; IsTag=0; shift 2;;
  25. -t ) PSInfraTagOrBranch="$2"; IsTag=1; shift 2;;
  26. * ) echo "Unknown command: $1"; shift;;
  27. esac
  28. done
  29. # Name and version of ps-infra that we are downloading
  30. PSInfraOrg=EpicGames
  31. PSInfraRepo=PixelStreamingInfrastructure
  32. # If a UE version is supplied set the right branch or tag to fetch for that version of UE
  33. if [ ! -z "$UEVersion" ]
  34. then
  35. if [ "$UEVersion" = "4.26" ]
  36. then
  37. PSInfraTagOrBranch=UE4.26
  38. IsTag=0
  39. fi
  40. if [ "$UEVersion" = "4.27" ]
  41. then
  42. PSInfraTagOrBranch=UE4.27
  43. IsTag=0
  44. fi
  45. if [ "$UEVersion" = "5.0" ]
  46. then
  47. PSInfraTagOrBranch=UE5.0
  48. IsTag=0
  49. fi
  50. fi
  51. # If no arguments select a specific version, fetch the appropriate default
  52. if [ -z "$PSInfraTagOrBranch" ]
  53. then
  54. PSInfraTagOrBranch=UE5.1
  55. IsTag=0
  56. fi
  57. # Whether the named reference is a tag or a branch affects the URL we fetch it on
  58. if [ "$IsTag" -eq 1 ]
  59. then
  60. RefType=tags
  61. else
  62. RefType=heads
  63. fi
  64. # Look for a SignallingWebServer directory next to this script
  65. if [ -d SignallingWebServer ]
  66. then
  67. echo "SignallingWebServer directory found...skipping install."
  68. else
  69. echo "SignallingWebServer directory not found...beginning ps-infra download."
  70. # Download ps-infra and follow redirects.
  71. curl -L https://github.com/$PSInfraOrg/$PSInfraRepo/archive/refs/$RefType/$PSInfraTagOrBranch.tar.gz > ps-infra.tar.gz
  72. # Unarchive the .tar
  73. tar -xmf ps-infra.tar.gz || $(echo "bad archive, contents:" && head --lines=20 ps-infra.tar.gz && exit 0)
  74. # Move the server folders into the current directory (WebServers) and delete the original directory
  75. mv PixelStreamingInfrastructure-*/* .
  76. # Copy any files and folders beginning with dot (ignored by * glob) and discard errors regarding to not being able to move "." and ".."
  77. mv PixelStreamingInfrastructure-*/.* . 2>/dev/null || :
  78. rm -rf PixelStreamingInfrastructure-*
  79. # Delete the downloaded tar
  80. rm ps-infra.tar.gz
  81. fi