mirror of
https://github.com/RustyRaptor/clone-hero-server-docker.git
synced 2026-12-03 15:45:20 -07:00
Allow server configuration via environment variables
This commit is contained in:
1 parent
2000e0c63f
commit
baf225e13f
4 files changed
+45
-27
No files matched your search
@@ -2,10 +2,21 @@
|
||||
|
||||
Docker image for Clone Hero dedicated server software. Available on [Docker Hub](https://hub.docker.com/r/corysanin/clone-hero-server).
|
||||
|
||||
```$ docker run --rm -p 14242:14242/udp corysanin/clone-hero-server:latest```
|
||||
Clone the repository and start the server with Docker Compose:
|
||||
|
||||
The Docker image exposes port 14242 for network communication by default. This can be configured in `settings.ini`
|
||||
```bash
|
||||
docker compose up
|
||||
```
|
||||
|
||||
`settings.ini` is stored in `/usr/src/config`. So if you want to modify it, create a `config` directory and use:
|
||||
Server settings can be customised with environment variables:
|
||||
|
||||
```$ docker run --rm -p 14242:14242/udp -v $(pwd)/config:/usr/src/config corysanin/clone-hero-server:latest```
|
||||
- `SERVER_NAME` – name shown in the server browser (default `clone-hero-server-docker`)
|
||||
- `SERVER_PASSWORD` – password required to join the server
|
||||
- `CONNECT_IP` – IP address to bind (default `0.0.0.0`)
|
||||
- `CONNECT_PORT` – UDP port to listen on (default `14242`)
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
SERVER_NAME="My Server" SERVER_PASSWORD="secret" docker compose up
|
||||
```
|
||||
@@ -1,5 +1,5 @@
|
||||
[online]
|
||||
serverName = clone-hero-server-docker
|
||||
connectPort =
|
||||
connectPort = 14242
|
||||
connectip = 0.0.0.0
|
||||
connectPassword =
|
||||
connectPassword = password
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
version: '3'
|
||||
services:
|
||||
clone-hero-server:
|
||||
build:
|
||||
context: .
|
||||
build: .
|
||||
ports:
|
||||
- "127.0.0.1:14242:14242"
|
||||
volumes:
|
||||
- ./config:/usr/src/clonehero/config
|
||||
container_name: clone-hero-server
|
||||
- "14242:14242/udp"
|
||||
environment:
|
||||
- DEBIAN_FRONTEND=noninteractive
|
||||
SERVER_NAME: ${SERVER_NAME:-clone-hero-server-docker}
|
||||
SERVER_PASSWORD: ${SERVER_PASSWORD:-password}
|
||||
CONNECT_IP: ${CONNECT_IP:-0.0.0.0}
|
||||
CONNECT_PORT: ${CONNECT_PORT:-14242}
|
||||
container_name: clone-hero-server
|
||||
restart: unless-stopped
|
||||
+21
-14
@@ -1,21 +1,28 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
function get_property {
|
||||
sed -n "s/^$2 *= *//p" "$1"
|
||||
# Helper to read values from the legacy ini file if present
|
||||
get_property() {
|
||||
sed -n "s/^$2 *= *//p" "$1" 2>/dev/null
|
||||
}
|
||||
|
||||
NAME=$(get_property ./server-settings.ini serverName)
|
||||
PASSWORD=$(get_property ./server-settings.ini connectPassword)
|
||||
IP=$(get_property ./server-settings.ini connectip)
|
||||
PORT=$(get_property ./server-settings.ini connectPort)
|
||||
# Allow configuration via environment variables with optional fallbacks to
|
||||
# `server-settings.ini` for backwards compatibility.
|
||||
NAME=${SERVER_NAME:-$(get_property ./server-settings.ini serverName)}
|
||||
PASSWORD=${SERVER_PASSWORD:-$(get_property ./server-settings.ini connectPassword)}
|
||||
IP=${CONNECT_IP:-$(get_property ./server-settings.ini connectip)}
|
||||
PORT=${CONNECT_PORT:-$(get_property ./server-settings.ini connectPort)}
|
||||
|
||||
if [ -z "$NAME" ] || [ -z "$PASSWORD" ] || [ -z "$IP" ] || [ -z "$PORT" ]; then
|
||||
echo "One or more properties not found in server-settings.ini"
|
||||
exit 1
|
||||
fi
|
||||
# Validate required values
|
||||
: "${NAME:?SERVER_NAME not set and serverName missing in server-settings.ini}" \
|
||||
"${PASSWORD:?SERVER_PASSWORD not set and connectPassword missing in server-settings.ini}" \
|
||||
"${IP:?CONNECT_IP not set and connectip missing in server-settings.ini}" \
|
||||
"${PORT:?CONNECT_PORT not set and connectPort missing in server-settings.ini}"
|
||||
|
||||
echo $NAME
|
||||
echo $PASSWORD
|
||||
echo "Starting Clone Hero server with:"
|
||||
echo " Name: $NAME"
|
||||
echo " IP: $IP"
|
||||
echo " Port: $PORT"
|
||||
|
||||
# Assuming cloneheroserver is in your PATH, you can directly run it
|
||||
cloneheroserver -n "PANGuitarHero" -d -ps password
|
||||
# Run the dedicated server
|
||||
exec cloneheroserver -n "$NAME" -ip "$IP" -p "$PORT" -ps "$PASSWORD" -d
|
||||
Reference in new issue
Block a user