Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Update SignallingWebServer platform scripts to support Mac (#389)
Browse files Browse the repository at this point in the history
* Update SignallingWebServer platform scripts to support Mac x86_64 and Arm64

* Update bash scripts to default to Linux

* Update coturn URLs to use the binaries provided by the PixelStreamingInfrastructure
  • Loading branch information
Belchy06 committed Oct 19, 2023
1 parent 952b309 commit ee82bd3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ echo ""

# Hmm, plain text
realm="PixelStreaming"
process="turnserver"
process=""
if [ "$(uname)" == "Darwin" ]; then
process="${BASH_LOCATION}/coturn/bin/turnserver"
else
process="turnserver"
fi
arguments="-c turnserver.conf --allowed-peer-ip=$localip -p ${turnport} -r $realm -X $publicip -E $localip -L $localip --no-cli --no-tls --no-dtls --pidfile /var/run/turnserver.pid -f -a -v -u ${turnusername}:${turnpassword}"

# Add arguments passed to script to arguments for executable
Expand Down
66 changes: 50 additions & 16 deletions SignallingWebServer/platform_scripts/bash/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
NODE_VERSION=v18.17.0

pushd "${BASH_LOCATION}" > /dev/null

Expand Down Expand Up @@ -128,10 +129,25 @@ node_version=""
if [[ -f "${BASH_LOCATION}/node/bin/node" ]]; then
node_version=$("${BASH_LOCATION}/node/bin/node" --version)
fi
check_and_install "node" "$node_version" "v18.17.0" "curl https://nodejs.org/dist/v18.17.0/node-v18.17.0-linux-x64.tar.gz --output node.tar.xz
&& tar -xf node.tar.xz
&& rm node.tar.xz
&& mv node-v*-linux-x64 \"${BASH_LOCATION}/node\""

node_url=""
if [ "$(uname)" == "Darwin" ]; then
arch=$(uname -m)
if [[ $arch == x86_64* ]]; then
node_url="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-darwin-x64.tar.gz"
elif [[ $arch == arm* ]]; then
node_url="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-darwin-arm64.tar.gz"
else
echo 'Incompatible architecture. Only x86_64 and ARM64 are supported'
exit -1
fi
else
node_url="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-linux-x64.tar.gz"
fi
check_and_install "node" "$node_version" "$NODE_VERSION" "curl $node_url --output node.tar.xz
&& tar -xf node.tar.xz
&& rm node.tar.xz
&& mv node-v*-*-* \"${BASH_LOCATION}/node\""

PATH="${BASH_LOCATION}/node/bin:$PATH"
"${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js" install
Expand All @@ -144,20 +160,38 @@ setup_frontend

popd > /dev/null # BASH_SOURCE

#command #dep_name #get_version_string #version_min #install command
coturn_version=$(if command -v turnserver &> /dev/null; then echo 1; else echo 0; fi)
if [ $coturn_version -eq 0 ]; then
if ! command -v apt-get &> /dev/null; then
echo "Setup for the scripts is designed for use with distros that use the apt-get package manager" \
"if you are seeing this message you will have to update \"${BASH_LOCATION}/setup.sh\" with\n" \
"a package manger and the equivalent packages for your distribution. Please follow the\n" \
"instructions found at https://pkgs.org/search/?q=coturn to install Coturn for your specific distribution"
exit 1
if [ "$(uname)" == "Darwin" ]; then
if [ -d "${BASH_LOCATION}/coturn" ]; then
echo 'CoTURN directory found...skipping install.'
else
if [ `id -u` -eq 0 ]; then
check_and_install "coturn" "$coturn_version" "1" "apt-get install -y coturn"
echo 'CoTURN directory not found...beginning CoTURN download for Mac.'
coturn_url=""
if [[ $arch == x86_64* ]]; then
coturn_url="https://github.com/EpicGames/PixelStreamingInfrastructure/releases/download/v4.6.2-coturn-mac-x86_64/turnserver.zip"
elif [[ $arch == arm* ]]; then
coturn_url="https://github.com/EpicGames/PixelStreamingInfrastructure/releases/download/v4.6.2-coturn-mac-arm64/turnserver.zip"
fi
curl -L -o ./turnserver.zip "$coturn_url"
mkdir "${BASH_LOCATION}/coturn"
tar -xf turnserver.zip -C "${BASH_LOCATION}/coturn"
rm turnserver.zip
fi
else
#command #dep_name #get_version_string #version_min #install command
coturn_version=$(if command -v turnserver &> /dev/null; then echo 1; else echo 0; fi)
if [ $coturn_version -eq 0 ]; then
if ! command -v apt-get &> /dev/null; then
echo "Setup for the scripts is designed for use with distros that use the apt-get package manager" \
"if you are seeing this message you will have to update \"${BASH_LOCATION}/setup.sh\" with\n" \
"a package manger and the equivalent packages for your distribution. Please follow the\n" \
"instructions found at https://pkgs.org/search/?q=coturn to install Coturn for your specific distribution"
exit 1
else
check_and_install "coturn" "$coturn_version" "1" "sudo apt-get install -y coturn"
if [ `id -u` -eq 0 ]; then
check_and_install "coturn" "$coturn_version" "1" "apt-get install -y coturn"
else
check_and_install "coturn" "$coturn_version" "1" "sudo apt-get install -y coturn"
fi
fi
fi
fi
2 changes: 1 addition & 1 deletion SignallingWebServer/platform_scripts/cmd/setup_coturn.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if exist coturn\ (
echo CoTURN directory not found...beginning CoTURN download for Windows.

@Rem Download nodejs and follow redirects.
curl -L -o ./turnserver.zip "https://github.com/mcottontensor/coturn/releases/download/v4.5.2-windows/turnserver.zip"
curl -L -o ./turnserver.zip "https://github.com/EpicGames/PixelStreamingInfrastructure/releases/download/v4.5.2-coturn-windows/turnserver.zip"

@Rem Unarchive the .zip to a directory called "turnserver"
mkdir coturn & tar -xf turnserver.zip -C coturn
Expand Down

0 comments on commit ee82bd3

Please sign in to comment.