From b026fb0cf95a24bae8091c6316ac4b902eaf1410 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Tue, 20 Jun 2023 09:55:56 +0300 Subject: [PATCH 1/5] Add new coturn deployment file --- .../ams-with-turn-server/ams-k8s-coturn.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml b/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml index 53375d56..ce00679e 100644 --- a/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml +++ b/kubernetes/ams-with-turn-server/ams-k8s-coturn.yaml @@ -21,7 +21,7 @@ spec: app.kubernetes.io/instance: coturn app.kubernetes.io/version: 0.0.1 spec: - # hostNetwork: true + hostNetwork: true containers: - name: coturn image: coturn/coturn @@ -41,11 +41,14 @@ spec: hostPort: 3478 protocol: TCP args: - # - --stun-only - - -v - - --user "{username}:{password}" - - --external-ip="$(detect-external-ip)/$MY_POD_IP" - - --realm="$(detect-external-ip)" + - "-a" + - "-f" + - "--user=username:password" + - "-p" + - "3478" + - "-v" + - "--external-ip=$(detect-external-ip)/$MY_POD_IP" + - "--realm=$(detect-external-ip)" --- @@ -73,4 +76,4 @@ spec: selector: app.kubernetes.io/name: coturn app.kubernetes.io/instance: coturn - app.kubernetes.io/version: 0.0.1 + app.kubernetes.io/version: 0.0.1 \ No newline at end of file From 9ebdc1d9799bf4431122e5d983a1e332fc2dd638 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Tue, 20 Jun 2023 12:38:11 +0300 Subject: [PATCH 2/5] Update coturn installation script --- install_turn-server.sh | 104 ++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/install_turn-server.sh b/install_turn-server.sh index 43ef9521..c22c9615 100644 --- a/install_turn-server.sh +++ b/install_turn-server.sh @@ -1,32 +1,82 @@ #!/bin/bash -# -# Turn Server Installation Script -# - -IP=`curl http://checkip.amazonaws.com` -USERNAME=$(openssl rand -hex 6) -PASSWORD=$(openssl rand -hex 12) - -check() { - OUT=$? - if [ $OUT -ne 0 ]; then - echo "There is a problem in installing the turn server. Please send the log of this console to support@antmedia.io" - exit $OUT - fi + +# Check if user is running as root +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root." + exit 1 +fi + +# Function to install Coturn +install_coturn() { + apt-get update + apt-get install -y coturn + truncate -s 0 /etc/turnserver.conf +} + +# Function to generate random username +generate_credentials() { + username=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 8 | head -n 1) + password=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1) + echo "Username: $username" + echo "Password: $password" + echo "lt-cred-mech" >> /etc/turnserver.conf + echo "user=$username:$password" >> /etc/turnserver.conf +} + +# Function to configure Coturn for NAT network +configure_nat() { + # Add necessary configuration options for NAT network + echo 'TURNSERVER_ENABLED=1' >> /etc/default/coturn + # Get public IP + public_ip=$(curl -s http://checkip.amazonaws.com) + + # Get private IP + private_ip=$(hostname -I | awk '{print $1}') + + # Add external IP configuration to turnserver.conf + echo "external-ip=$public_ip/$private_ip" >> /etc/turnserver.conf + echo "realm=$public_ip" >> /etc/turnserver.conf } -sudo apt-get update && apt-get install coturn -y -check -echo "TURNSERVER_ENABLED=1" > /etc/default/coturn -echo "realm=$IP" >> /etc/turnserver.conf -echo "user=$USERNAME:$PASSWORD" >> /etc/turnserver.conf -sudo systemctl enable coturn && sudo systemctl restart coturn -check -echo "" -echo "Username: $USERNAME" -echo "Password: $PASSWORD" -echo "Turn Server Address: $IP" -echo "Please check this guide to enable the Turn Server: https://antmedia.io/docs/guides/advanced-usage/turn-and-stun-installation/coTURN-quick-installation/#how-to-add-turn-server-to-ant-media-sample-pages" -echo "" +# Function to configure Coturn for public IP +configure_public_ip() { + # Add necessary configuration options for public IP + echo 'TURNSERVER_ENABLED=1' >> /etc/default/coturn + + # Get public IP + public_ip=$(curl -s http://checkip.amazonaws.com) + + # Add external IP configuration to turnserver.conf + echo "realm=$public_ip" >> /etc/turnserver.conf +} + +# Main script + +# Prompt user for configuration option +echo "Choose the configuration option:" +echo "1. Behind NAT network (e.g., AWS)" +echo "2. Directly accessible public IP" +read -p "Enter your choice (1 or 2): " option + +case $option in + 1) + install_coturn + generate_credentials + configure_nat + ;; + 2) + install_coturn + generate_credentials + configure_public_ip + ;; + *) + echo "Invalid choice. Exiting." + exit 1 + ;; +esac +# Start and enable Coturn service +systemctl restart coturn +systemctl enable coturn +echo "Coturn installation and configuration completed." From 60a50f94d2c23b204fa0339c48e5f9d37f08c72c Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Thu, 22 Jun 2023 09:09:13 +0300 Subject: [PATCH 3/5] Add -r parameter "do not allow backslashes to escape any characters" --- install_turn-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_turn-server.sh b/install_turn-server.sh index c22c9615..7fc331c6 100644 --- a/install_turn-server.sh +++ b/install_turn-server.sh @@ -56,7 +56,7 @@ configure_public_ip() { echo "Choose the configuration option:" echo "1. Behind NAT network (e.g., AWS)" echo "2. Directly accessible public IP" -read -p "Enter your choice (1 or 2): " option +read -r -p "Enter your choice (1 or 2): " option case $option in 1) From 1c161291a24873be973c9b6a67f4a7127676f60d Mon Sep 17 00:00:00 2001 From: murat Date: Fri, 7 Jul 2023 10:36:59 +0300 Subject: [PATCH 4/5] Add JVM memory options --- docker/Dockerfile_Process | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/Dockerfile_Process b/docker/Dockerfile_Process index f25b2dec..ce386620 100644 --- a/docker/Dockerfile_Process +++ b/docker/Dockerfile_Process @@ -8,6 +8,9 @@ ARG AntMediaServer ARG BranchName=master +# Set -Xms and -Xmx +# ENV JVM_MEMORY_OPTIONS="-Xms1g -Xmx4g" + #Running update and install makes the builder not to use cache which resolves some updates RUN apt-get update && apt-get install -y curl wget iproute2 cron logrotate From b240af434d4aba0fcca80fe0827f8ce5073eb0f4 Mon Sep 17 00:00:00 2001 From: murat Date: Wed, 25 Oct 2023 14:10:51 +0300 Subject: [PATCH 5/5] Add curl package for the minimal OS installations --- install_ant-media-server.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install_ant-media-server.sh b/install_ant-media-server.sh index fd668965..9c42fe1a 100755 --- a/install_ant-media-server.sh +++ b/install_ant-media-server.sh @@ -238,11 +238,12 @@ fi if [ -z "$ANT_MEDIA_SERVER_ZIP_FILE" ]; then if [ "$ID" == "ubuntu" ]; then + #Added curl package for the minimal OS installations. $SUDO apt-get update - $SUDO apt-get install jq -y + $SUDO apt-get install jq curl -y check elif [ "$ID" == "centos" ] || [ "$ID" == "almalinux" ] || [ "$ID" == "rocky" ] || [ "$ID" == "rhel" ]; then - $SUDO yum -y install jq + $SUDO yum -y install jq curl fi if [ -z "${LICENSE_KEY}" ]; then echo "Downloading the latest version of Ant Media Server Community Edition."