fixed .env.example, added auto-generate rcon_password and other vars

This commit is contained in:
2025-06-22 16:12:41 +04:00
parent 2fc4e023a1
commit 3b557b0009
4 changed files with 37 additions and 20 deletions

View File

@ -1,6 +1,5 @@
# Server vars # Server vars
SERVER_NAME=My CSDM Server SERVER_NAME="GO YASOZDAL | CSDM"
RCON_PASSWORD=changeme
PORT=27015 PORT=27015
HLTV_PORT=27020 HLTV_PORT=27020
VAC="secure" VAC="secure"
@ -9,3 +8,5 @@ SV_LAN = 0
# Gameplay settings # Gameplay settings
START_MAP="de_dust2" START_MAP="de_dust2"
MAX_PLAYERS=32 MAX_PLAYERS=32
# RCON_PASSWORD will be appended by init.sh

View File

@ -1,5 +1,5 @@
services: services:
csdm_1: csdm:
build: . build: .
container_name: csdm container_name: csdm
ports: ports:

23
init.sh
View File

@ -1,11 +1,26 @@
#!/bin/bash #!/bin/bash
ENV_FILE=".env" ENV_FILE=".env"
TEMPLATE_FILE=".env.example"
# Генерация пароля
generate_password() {
openssl rand -base64 18
}
# Создание .env на основе шаблона
if [ -f "$ENV_FILE" ]; then if [ -f "$ENV_FILE" ]; then
echo "[INFO] $ENV_FILE already exists. Skipping." echo "[INFO] $ENV_FILE already exists. Skipping creation."
else else
echo "[INFO] Creating $ENV_FILE from .env.example" echo "[INFO] Creating $ENV_FILE from $TEMPLATE_FILE..."
cp .env.example .env
echo "[OK] Now you can edit .env if needed." # Копируем шаблон
cp "$TEMPLATE_FILE" "$ENV_FILE"
# Генерируем и подставляем RCON пароль
RCON_PASSWORD=$(generate_password)
echo "RCON_PASSWORD=$RCON_PASSWORD" >> "$ENV_FILE"
echo "[OK] .env created with generated RCON_PASSWORD:"
echo "$RCON_PASSWORD"
fi fi

View File

@ -4,9 +4,10 @@ cd /hlds
./hlds_run \ ./hlds_run \
-game cstrike \ -game cstrike \
+maxplayers ${MAXPLAYERS:-16} \ -console \
+map ${MAP:-de_dust2} \ -port "$PORT" \
+sv_lan 0 \ +map "$MAP" \
+rcon_password ${RCON_PASSWORD:-changeme} \ +maxplayers "$MAX_PLAYERS" \
-port ${PORT:-27015} \ +sv_lan "$SV_LAN" \
-${VAC:-insecure} +rcon_password "$RCON_PASSWORD" \
-${VAC:+-VAC}