Add support for turn for netplay. Still needs testing.

This commit is contained in:
2026-01-08 12:56:41 -05:00
parent 3f9cab66f5
commit 51935bbb09
4 changed files with 197 additions and 5 deletions

View File

@@ -4,7 +4,27 @@ set -eu
mkdir -p /app/data/library /app/data/config /app/data/assets /app/data/resources
mkdir -p /tmp/vite-temp /tmp/vite /tmp/cache
touch /app/data/config/config.yml
CONFIG_TEMPLATE_FILE="/app/pkg/config.yml.template"
CONFIG_FILE="/app/data/config/config.yml"
# Check if config file exists in /app/data/config
if [ -f "$CONFIG_FILE" ]; then
echo "config.yml already exists in $CONFIG_FILE"
else
# Copy the template to the target location
echo "Copying $CONFIG_TEMPLATE_FILE to $CONFIG_FILE"
cp "$CONFIG_TEMPLATE_FILE" "$CONFIG_FILE"
# Add in TURN
readonly time=$(date +%s)
readonly expiry=512640 # one year in seconds
export turn_username=$(( $time + $expiry ))
export turn_password=$(echo -n $turn_username | openssl dgst -binary -sha1 -hmac ${CLOUDRON_TURN_SECRET} | openssl base64)
envsubst < $CONFIG_TEMPLATE_FILE > $CONFIG_FILE
echo "Successfully created $CONFIG_FILE from template"
fi
# ensure that data directory is owned by 'cloudron' user
chown -R cloudron:cloudron /app/data /tmp/vite-temp /tmp/vite /tmp/cache
@@ -31,7 +51,7 @@ export REDIS_PORT=${CLOUDRON_REDIS_PORT}
export ROMM_BASE_PATH=/app/data
export ROMM_TMP_PATH=/tmp
TEMPLATE_FILE="/app/pkg/env.sh.template"
ENV_TEMPLATE_FILE="/app/pkg/env.sh.template"
ENV_FILE="/app/data/env.sh"
# Check if env.sh exists in /app/data
@@ -39,8 +59,8 @@ if [ -f "$ENV_FILE" ]; then
echo "env.sh already exists in $ENV_FILE"
else
# Copy the template to the target location
echo "Copying $TEMPLATE_FILE to $ENV_FILE"
cp "$TEMPLATE_FILE" "$ENV_FILE"
echo "Copying $ENV_TEMPLATE_FILE to $ENV_FILE"
cp "$ENV_TEMPLATE_FILE" "$ENV_FILE"
chmod +x "$ENV_FILE"
# Generate a new secret key using openssl