Skip to content

Commit 14f02e7

Browse files
authored
Merge pull request #290 from hackthedev/dev
Ptero Test 2
2 parents b71bce9 + 4e92671 commit 14f02e7

3 files changed

Lines changed: 88 additions & 2 deletions

File tree

ptero/DCTS/egg-dcts.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"scripts": {
2424
"installation": {
25-
"script": "#!/bin/bash\r\n# DCTS\r\n#\r\n# Server Files: /mnt/server\r\n# All required packages are installed in the used install image \r\n\r\nexport HOME=/mnt/server\r\nmkdir -p /mnt/server\r\ncd /mnt/server\r\n\r\ngit config --global --add safe.directory /mnt/server\r\n\r\nif [ ! -d \".git\" ]; then\r\n echo \"Cloning from github...\"\r\n git clone -b beta https://github.com/hackthedev/dcts-shipping.git .\r\nelse\r\n echo \"Updating existing installation...\"\r\n git fetch origin beta\r\n git reset --hard origin/beta\r\nfi\r\n\r\necho -e \"Preparing directories and fixing permissions...\"\r\n\r\nmkdir -p sv configs public/uploads public/emojis plugins themes\r\n\r\necho -e \"Installation completed.\\nDependencies will be installed on first start.\"",
25+
"script": "#!/bin/bash\nexport HOME=/mnt/server\nmkdir -p /mnt/server\ncd /mnt/server\n\ngit config --global --add safe.directory /mnt/server\n\nif [ ! -d \".git\" ]; then\n echo \"Cloning from github...\"\n git clone -b beta https://github.com/hackthedev/dcts-shipping.git .\nelse\n echo \"Updating existing installation...\"\n git fetch origin beta\n git reset --hard origin/beta\nfi\n\necho -e \"Preparing directories and fixing permissions...\"\nmkdir -p sv configs public/uploads public/emojis plugins themes Livekit\n\necho \"Fetching latest LiveKit release...\"\nLATEST_VERSION=$(curl -s https://api.github.com/repos/livekit/livekit/releases/latest | grep '\"tag_name\":' | head -n 1 | sed -E 's/.*\"v([^\"]+)\".*/\\1/')\necho \"Installing LiveKit v${LATEST_VERSION}...\"\ncurl -sL \"https://github.com/livekit/livekit/releases/latest/download/livekit_${LATEST_VERSION}_linux_amd64.tar.gz\" -o livekit_linux_amd64.tar.gz\ntar -xzf livekit_linux_amd64.tar.gz livekit-server\nmv livekit-server Livekit/livekit-server\nrm livekit_linux_amd64.tar.gz\nchmod +x Livekit/livekit-server\n\necho -e \"Installation completed.\\nDependencies will be installed on first start.\"",
2626
"container": "ghcr.io/pterodactyl/installers:debian",
2727
"entrypoint": "bash"
2828
}
@@ -147,6 +147,36 @@
147147
"user_editable": true,
148148
"rules": "required|string|in:true,false",
149149
"field_type": "text"
150+
},
151+
{
152+
"name": "LiveKit API Port (HTTP)",
153+
"description": "Port used for internal LiveKit signaling.",
154+
"env_variable": "LIVEKIT_PORT",
155+
"default_value": "7880",
156+
"user_viewable": true,
157+
"user_editable": false,
158+
"rules": "required|integer",
159+
"field_type": "text"
160+
},
161+
{
162+
"name": "LiveKit RTC TCP Port",
163+
"description": "Secondary port used for LiveKit TCP WebRTC signaling.",
164+
"env_variable": "RTC_TCP_PORT",
165+
"default_value": "7881",
166+
"user_viewable": true,
167+
"user_editable": true,
168+
"rules": "required|integer",
169+
"field_type": "text"
170+
},
171+
{
172+
"name": "LiveKit RTC UDP Port",
173+
"description": "Port used for direct LiveKit UDP WebRTC media streaming.",
174+
"env_variable": "RTC_UDP_PORT",
175+
"default_value": "7882",
176+
"user_viewable": true,
177+
"user_editable": true,
178+
"rules": "required|integer",
179+
"field_type": "text"
150180
}
151181
]
152182
}

ptero/DCTS/entrypoint.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,60 @@ if [ -f "package.json" ]; then
2222
bun install --ignore-scripts --frozen-lockfile || bun install --ignore-scripts
2323
fi
2424

25+
# ==========================================
26+
# LIVEKIT INTEGRATION
27+
# ==========================================
28+
export LIVEKIT_YAML_PATH="Livekit/livekit.yaml"
29+
30+
if [ -f "Livekit/livekit-server" ]; then
31+
echo "LiveKit binary found. Setting up embedded LiveKit Server..."
32+
33+
# Generate keys if they don't exist
34+
if ! grep -q "^keys:" "${LIVEKIT_YAML_PATH}" 2>/dev/null; then
35+
echo "Generating new LiveKit keys..."
36+
OUTPUT=$(./Livekit/livekit-server generate-keys)
37+
API_KEY=$(echo "$OUTPUT" | awk '/API Key:/ {print $3}')
38+
API_SECRET=$(echo "$OUTPUT" | awk '/API Secret:/ {print $3}')
39+
40+
touch "${LIVEKIT_YAML_PATH}"
41+
/usr/local/bin/yq -i '
42+
.keys = {} |
43+
.keys["'"$API_KEY"'"] = "'"$API_SECRET"'"
44+
' "${LIVEKIT_YAML_PATH}"
45+
echo "LiveKit Keys generated."
46+
fi
47+
48+
echo "Syncing LiveKit Ports..."
49+
if [ -n "$LIVEKIT_PORT" ]; then
50+
/usr/local/bin/yq -i '.port = '"$LIVEKIT_PORT" "${LIVEKIT_YAML_PATH}"
51+
fi
52+
if [ -n "$RTC_TCP_PORT" ]; then
53+
/usr/local/bin/yq -i '.rtc.tcp_port = '"$RTC_TCP_PORT" "${LIVEKIT_YAML_PATH}"
54+
fi
55+
if [ -n "$RTC_UDP_PORT" ]; then
56+
/usr/local/bin/yq -i '.rtc.udp_port = '"$RTC_UDP_PORT" "${LIVEKIT_YAML_PATH}"
57+
fi
58+
59+
echo "Reading LiveKit Keys to sync with DCTS .env..."
60+
API_KEY=$(/usr/local/bin/yq e '.keys | keys | .[0]' "${LIVEKIT_YAML_PATH}")
61+
API_SECRET=$(/usr/local/bin/yq e '.keys | .["'"$API_KEY"'"]' "${LIVEKIT_YAML_PATH}")
62+
63+
touch .env
64+
# Remove old keys if present
65+
sed -i '/^LIVEKIT_API_KEY=/d' .env
66+
sed -i '/^LIVEKIT_API_SECRET=/d' .env
67+
68+
# Inject keys into .env
69+
echo "LIVEKIT_API_KEY=${API_KEY}" >> .env
70+
echo "LIVEKIT_API_SECRET=${API_SECRET}" >> .env
71+
72+
echo "Starting LiveKit server in the background..."
73+
./Livekit/livekit-server --config "${LIVEKIT_YAML_PATH}" &
74+
else
75+
echo "Notice: LiveKit binary not found. Running purely as chat server."
76+
fi
77+
# ==========================================
78+
2579
MODIFIED_STARTUP=$(echo "${STARTUP}" | sed -e 's/{{/${/g' -e 's/}}/}/g')
2680
MODIFIED_STARTUP=$(eval "echo \"$MODIFIED_STARTUP\"")
2781

ptero/Dockerfile.dcts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
FROM oven/bun:1-alpine
66

77
# Install dependencies and create container user
8-
RUN apk add --no-cache --update curl ca-certificates openssl git tar bash sqlite fontconfig tzdata iproute2 \
8+
RUN apk add --no-cache --update curl ca-certificates openssl git tar bash sqlite fontconfig tzdata iproute2 jq bc \
9+
&& curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/local/bin/yq \
10+
&& chmod +x /usr/local/bin/yq \
911
&& adduser -D -h /home/container container
1012

1113
RUN mkdir -p /home/container/.bun && chown -R container:container /home/container

0 commit comments

Comments
 (0)