Skip to content

Commit 5965f2c

Browse files
committed
feat: agregar función de descarga de Workshop en entrypoint-user.sh y script KF2-workshop-download.sh
1 parent 25675c4 commit 5965f2c

File tree

2 files changed

+737
-36
lines changed

2 files changed

+737
-36
lines changed

entrypoint-user.sh

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,63 @@
11
#!/bin/bash
22

3+
# Descarga Workshop de KF2 si KF2_WORKSHOP contiene IDs
4+
run_workshop_download() {
5+
local script_path="/app/server-scripts/KF2-workshop-download.sh"
6+
local raw="${KF2_WORKSHOP:-}"
7+
# Saltar si no hay variable o es una lista vacía
8+
if [ -z "$raw" ] || [ "$raw" = "[]" ]; then
9+
echo -e "ℹ️ KF2_WORKSHOP vacío; no se ejecuta descarga de Workshop"
10+
return 0
11+
fi
12+
if [ ! -x "$script_path" ] && [ -f "$script_path" ]; then
13+
chmod +x "$script_path" || true
14+
fi
15+
if [ -f "$script_path" ]; then
16+
echo -e "🛠️ Ejecutando descarga de Workshop…"
17+
QUIET=1 VERY_QUIET=1 FORCE_STEAM_HOME_IN_WORKDIR=1 bash "$script_path" || \
18+
echo -e "⚠️ Descarga de Workshop finalizó con errores (se continúa)"
19+
else
20+
echo -e "ℹ️ Script de Workshop no encontrado en $script_path"
21+
fi
22+
}
23+
324
# Function to run KF2 configuration scripts
425
run_kf2_config_scripts() {
5-
local server_scripts_dir="/app/server-scripts"
6-
7-
if [ ! -d "${server_scripts_dir}" ]; then
8-
echo -e "ℹ️ No server-scripts directory found"
9-
return 0
10-
fi
11-
12-
echo -e "🔧 Running KF2 configuration scripts..."
13-
14-
if ls "${server_scripts_dir}"/*.sh 1> /dev/null 2>&1; then
15-
for script in "${server_scripts_dir}"/*.sh; do
16-
script_name=$(basename "${script}")
17-
echo -e "▶️ Executing: ${script_name}"
18-
19-
# Make executable and run
20-
chmod +x "${script}"
21-
if bash "${script}"; then
22-
echo -e "${script_name} completed successfully"
23-
else
24-
echo -e "⚠️ ${script_name} failed with exit code: $?"
25-
fi
26-
done
27-
else
28-
echo -e "ℹ️ No .sh files found in ${server_scripts_dir}"
29-
fi
30-
31-
echo -e "🎯 KF2 configuration completed"
26+
local server_scripts_dir="/app/server-scripts"
27+
28+
if [ ! -d "${server_scripts_dir}" ]; then
29+
echo -e "ℹ️ No server-scripts directory found"
30+
return 0
31+
fi
32+
33+
echo -e "🔧 Running KF2 configuration scripts..."
34+
35+
if ls "${server_scripts_dir}"/*.sh 1> /dev/null 2>&1; then
36+
for script in "${server_scripts_dir}"/*.sh; do
37+
script_name=$(basename "${script}")
38+
# Evitar ejecutar el downloader aquí; se invoca explícitamente en puntos controlados
39+
if [ "$script_name" = "KF2-workshop-download.sh" ]; then
40+
echo -e "⏭️ Omitiendo en lote: ${script_name} (se ejecuta aparte)"
41+
continue
42+
fi
43+
echo -e "▶️ Executing: ${script_name}"
44+
chmod +x "${script}" || true
45+
if bash "${script}"; then
46+
echo -e "${script_name} completed successfully"
47+
else
48+
echo -e "⚠️ ${script_name} failed with exit code: $?"
49+
fi
50+
done
51+
else
52+
echo -e "ℹ️ No .sh files found in ${server_scripts_dir}"
53+
fi
54+
55+
echo -e "🎯 KF2 configuration completed"
3256
}
3357

3458
exit_handler_user() {
35-
# Execute the shutdown commands
3659
echo -e "Stopping ${GAMESERVER}"
37-
./"${GAMESERVER}" stop
60+
./${GAMESERVER} stop
3861
exitcode=$?
3962
exit ${exitcode}
4063
}
@@ -97,7 +120,7 @@ fi
97120
if [ "${LGSM_GITHUBBRANCH}" != "master" ]; then
98121
echo -e "not master branch, clearing modules directory"
99122
rm -rf /app/lgsm/modules/*
100-
./"${GAMESERVER}" update-lgsm
123+
./${GAMESERVER} update-lgsm
101124
elif [ -d "/app/lgsm/modules" ]; then
102125
echo -e "ensure all modules are executable"
103126
chmod +x /app/lgsm/modules/*
@@ -106,20 +129,22 @@ fi
106129
# Enable developer mode
107130
if [ "${LGSM_DEV}" == "true" ]; then
108131
echo -e "developer mode enabled"
109-
./"${GAMESERVER}" developer
132+
./${GAMESERVER} developer
110133
fi
111134

112135
# Install game server
113136
if [ -z "$(ls -A -- "/data/serverfiles" 2> /dev/null)" ]; then
114137
echo -e ""
115138
echo -e "Installing ${GAMESERVER}"
116139
echo -e "================================="
117-
./"${GAMESERVER}" auto-install
140+
./${GAMESERVER} auto-install
118141
install=1
142+
# Tras instalación inicial, descargar Workshop si aplica
143+
run_workshop_download
119144
else
120145
echo -e ""
121146
# Sponsor to display LinuxGSM logo
122-
./"${GAMESERVER}" sponsor
147+
./${GAMESERVER} sponsor
123148
fi
124149

125150
if [ -n "${UPDATE_CHECK}" ] && [ "${UPDATE_CHECK}" != "0" ]; then
@@ -137,14 +162,14 @@ fi
137162
# Update or validate game server
138163
if [ -z "${install}" ]; then
139164
echo -e ""
140-
if [ "${VALIDATE_ON_START,,}" = "true" ]; then
165+
if [ "${VALIDATE_ON_START,,}" = "true" ]; then
141166
echo -e "Validating ${GAMESERVER}"
142167
echo -e "================================="
143-
./"${GAMESERVER}" validate
168+
./${GAMESERVER} validate
144169
else
145170
echo -e "Checking for Update ${GAMESERVER}"
146171
echo -e "================================="
147-
./"${GAMESERVER}" update
172+
./${GAMESERVER} update
148173
fi
149174
fi
150175

@@ -153,6 +178,11 @@ echo -e "KF2 Configuration Check"
153178
echo -e "========================"
154179
run_kf2_config_scripts
155180

181+
echo -e ""
182+
echo -e "Workshop download (pre-start)"
183+
echo -e "============================"
184+
run_workshop_download
185+
156186
echo -e ""
157187
echo -e "Starting ${GAMESERVER}"
158188
echo -e "================================="

0 commit comments

Comments
 (0)