Skip to content

Commit 88d82c0

Browse files
dgibbs64Copilot
andauthored
feat(bb): add BrainBread server update functionality (#4912)
* feat(bb): add BrainBread server update functionality * Implemented `update_bb.sh` to handle updates for BrainBread servers. * Integrated new update checks in `command_check_update.sh` and `command_update.sh`. * Updated `install_server_files.sh` to include BrainBread server installation logic. Co-authored-by: Copilot <copilot@github.com> * feat(bb): enhance BrainBread update process * Updated `fn_update_dl` to use `remotebuildhash` for file integrity. * Added handling for missing `remotebuildhash` to default to "nohash". * Included `update_steamcmd.sh` call to ensure both Steam app and GitHub package updates are performed. Co-authored-by: Copilot <copilot@github.com> * fix(steamcmd): ensure core HL1 files are present after appid 90 update * Added checks to verify the presence of core HL1 files after updating appid 90. * If files are missing, an update is forced and errors are logged. * Exits the script if files are still missing after the retry. * fix(steamcmd): update error messages for GoldSrc engine * Changed appid 90 references to GoldSrc for clarity. * Updated error messages to reflect the correct engine context. * Ensures users are informed about missing core HL1 files after GoldSrc updates. Co-authored-by: Copilot <copilot@github.com> * feat(serverlist): add Military Conflict: Vietnam server entry * Introduced new server entry for `Military Conflict: Vietnam` in `serverlist.csv`. * Enhances the variety of game servers available for users. --------- Co-authored-by: Copilot <copilot@github.com>
1 parent 25ff41b commit 88d82c0

8 files changed

Lines changed: 212 additions & 9 deletions

File tree

lgsm/data/serverlist.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ l4d,l4dserver,Left 4 Dead,ubuntu-24.04
6767
l4d2,l4d2server,Left 4 Dead 2,ubuntu-24.04
6868
mc,mcserver,Minecraft,ubuntu-24.04
6969
mcb,mcbserver,Minecraft Bedrock,ubuntu-24.04
70+
mcv,mcvserver,Military Conflict: Vietnam,ubuntu-24.04
7071
mh,mhserver,MORDHAU,ubuntu-24.04
7172
mohaa,mohaaserver,Medal of Honor: Allied Assault,ubuntu-24.04
7273
mta,mtaserver,Multi Theft Auto,ubuntu-24.04

lgsm/modules/command_check_update.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ elif [ "${shortname}" == "jk2" ]; then
3030
update_jk2.sh
3131
elif [ "${shortname}" == "vints" ]; then
3232
update_vints.sh
33+
elif [ "${shortname}" == "bb" ]; then
34+
update_bb.sh
3335
elif [ "${shortname}" == "ut99" ]; then
3436
update_ut99.sh
3537
elif [ "${shortname}" == "xnt" ]; then

lgsm/modules/command_update.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ elif [ "${shortname}" == "jk2" ]; then
3131
update_jk2.sh
3232
elif [ "${shortname}" == "vints" ]; then
3333
update_vints.sh
34+
elif [ "${shortname}" == "bb" ]; then
35+
update_bb.sh
3436
elif [ "${shortname}" == "ut99" ]; then
3537
update_ut99.sh
3638
elif [ "${shortname}" == "xnt" ]; then

lgsm/modules/core_dl.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ fn_dl_steamcmd() {
139139
fn_print_failure_nl "${commandaction} ${selfname}: ${remotelocation}: Not enough disk space to download server files"
140140
fn_script_log_fail "${commandaction} ${selfname}: ${remotelocation}: Not enough disk space to download server files"
141141
core_exit.sh
142+
# Invalid platform for app/update request.
143+
elif [ -n "$(grep -i "Invalid platform" "${steamcmdlog}" | tail -1)" ]; then
144+
fn_print_failure_nl "${commandaction} ${selfname}: ${remotelocation}: Invalid platform for AppID ${appid}"
145+
fn_print_nl "Check steamcmdforcewindows setting and system architecture (x86_64 required for most servers)"
146+
fn_script_log_fail "${commandaction} ${selfname}: ${remotelocation}: Invalid platform for AppID ${appid}"
147+
core_exit.sh
142148
# Need tp purchase game.
143149
elif [ -n "$(grep "No subscription" "${steamcmdlog}" | tail -1)" ]; then
144150
fn_print_failure_nl "${commandaction} ${selfname}: ${remotelocation}: Steam account does not have a license for the required game"

lgsm/modules/core_modules.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,11 @@ update_ut99.sh() {
710710
fn_fetch_module
711711
}
712712

713+
update_bb.sh() {
714+
modulefile="${FUNCNAME[0]}"
715+
fn_fetch_module
716+
}
717+
713718
update_vints.sh() {
714719
modulefile="${FUNCNAME[0]}"
715720
fn_fetch_module

lgsm/modules/core_steamcmd.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,21 @@ fn_check_steamcmd_appmanifest() {
427427
fn_dl_steamcmd
428428
fi
429429
fi
430+
431+
# GoldSrc can occasionally report success while core HL1 files are incomplete.
432+
if [ "${engine}" == "goldsrc" ]; then
433+
if [ ! -f "${serverfiles}/hlds_run" ] || [ ! -f "${serverfiles}/engine_i486.so" ] || [ ! -d "${serverfiles}/valve" ]; then
434+
fn_print_error_nl "Core HL1 files missing after GoldSrc update"
435+
fn_script_log_error "Core HL1 files missing after GoldSrc update"
436+
fn_print_info_nl "Forcing update to correct issue"
437+
fn_script_log_info "Forcing update to correct issue"
438+
fn_dl_steamcmd
439+
440+
if [ ! -f "${serverfiles}/hlds_run" ] || [ ! -f "${serverfiles}/engine_i486.so" ] || [ ! -d "${serverfiles}/valve" ]; then
441+
fn_print_fail_nl "Core HL1 files are still missing after retry"
442+
fn_script_log_fail "Core HL1 files are still missing after retry"
443+
core_exit.sh
444+
fi
445+
fi
446+
fi
430447
}

lgsm/modules/install_server_files.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@ fn_install_server_files() {
3232
run="norun"
3333
force="noforce"
3434
md5="e3b4962cdd9d41e23c6fed65101bccde"
35-
elif [ "${shortname}" == "bb" ]; then
36-
remote_fileurl="http://linuxgsm.download/BrainBread/brainbread-v1.2-linuxserver.tar.xz"
37-
local_filedir="${tmpdir}"
38-
local_filename="brainbread-v1.2-linuxserver.tar.xz"
39-
chmodx="nochmodx"
40-
run="norun"
41-
force="noforce"
42-
md5="55f227183b736397806d5b6db6143f15"
35+
4336
elif [ "${shortname}" == "cod" ]; then
4437
remote_fileurl="http://linuxgsm.download/CallOfDuty/cod-lnxded-1.5b-full.tar.xz"
4538
local_filedir="${tmpdir}"
@@ -267,14 +260,16 @@ elif [ "${shortname}" == "jk2" ]; then
267260
update_jk2.sh
268261
elif [ "${shortname}" == "vints" ]; then
269262
update_vints.sh
263+
elif [ "${shortname}" == "bb" ]; then
264+
update_bb.sh
270265
elif [ "${shortname}" == "ut99" ]; then
271266
fn_install_server_files
272267
update_ut99.sh
273268
elif [ "${shortname}" == "xnt" ]; then
274269
update_xnt.sh
275270
elif [ "${shortname}" == "etl" ]; then
276271
update_etl.sh
277-
elif [ -z "${appid}" ] || [ "${shortname}" == "ahl" ] || [ "${shortname}" == "bb" ] || [ "${shortname}" == "q4" ] || [ "${shortname}" == "ns" ] || [ "${shortname}" == "sfc" ] || [ "${shortname}" == "ts" ] || [ "${shortname}" == "vs" ] || [ "${shortname}" == "zmr" ]; then
272+
elif [ -z "${appid}" ] || [ "${shortname}" == "ahl" ] || [ "${shortname}" == "q4" ] || [ "${shortname}" == "ns" ] || [ "${shortname}" == "sfc" ] || [ "${shortname}" == "ts" ] || [ "${shortname}" == "vs" ] || [ "${shortname}" == "zmr" ]; then
278273
if [ "${shortname}" == "ut" ]; then
279274
install_eula.sh
280275
fi

lgsm/modules/update_bb.sh

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#!/bin/bash
2+
# LinuxGSM update_bb.sh module
3+
# Author: Daniel Gibbs
4+
# Contributors: https://linuxgsm.com/contrib
5+
# Website: https://linuxgsm.com
6+
# Description: Handles updating of BrainBread servers.
7+
8+
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
9+
10+
fn_update_dl() {
11+
# Download and extract files to serverfiles.
12+
fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "nochmodx" "norun" "force" "${remotebuildhash}"
13+
fn_dl_extract "${tmpdir}" "${remotebuildfilename}" "${serverfiles}"
14+
echo "${remotebuild}" > "${serverfiles}/build.txt"
15+
fn_clear_tmp
16+
}
17+
18+
fn_update_localbuild() {
19+
# Gets local build info.
20+
fn_print_dots "Checking local build: ${remotelocation}"
21+
# Uses build file to get local build.
22+
localbuild=$(head -n 1 "${serverfiles}/build.txt" 2> /dev/null)
23+
if [ -z "${localbuild}" ]; then
24+
fn_print_error "Checking local build: ${remotelocation}: missing local build info"
25+
fn_script_log_error "Missing local build info"
26+
fn_script_log_error "Set localbuild to 0"
27+
localbuild="0"
28+
else
29+
fn_print_ok "Checking local build: ${remotelocation}"
30+
fn_script_log_pass "Checking local build"
31+
fi
32+
}
33+
34+
fn_update_remotebuild() {
35+
# Gets remote build info.
36+
apiurl="https://api.github.com/repos/IronOak-Studios/BrainBread/releases/latest"
37+
remotebuildresponse=$(curl -s "${apiurl}")
38+
remotebuildfilename=$(echo "${remotebuildresponse}" | jq -r '.assets[] | select(.name | test("linuxserver\\.tar\\.gz$")) | .name' | head -n 1)
39+
remotebuildurl=$(echo "${remotebuildresponse}" | jq -r '.assets[] | select(.name | test("linuxserver\\.tar\\.gz$")) | .browser_download_url' | head -n 1)
40+
remotebuildhash=$(echo "${remotebuildresponse}" | jq -r '.assets[] | select(.name | test("linuxserver\\.tar\\.gz$")) | .digest' | sed 's/^sha256://g' | head -n 1)
41+
remotebuild=$(echo "${remotebuildresponse}" | jq -r '.tag_name')
42+
if [ -z "${remotebuildhash}" ] || [ "${remotebuildhash}" == "null" ]; then
43+
remotebuildhash="nohash"
44+
fi
45+
46+
if [ "${firstcommandname}" != "INSTALL" ]; then
47+
fn_print_dots "Checking remote build: ${remotelocation}"
48+
# Checks if remotebuild variable has been set.
49+
if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ] || [ -z "${remotebuildurl}" ] || [ "${remotebuildurl}" == "null" ] || [ -z "${remotebuildfilename}" ] || [ "${remotebuildfilename}" == "null" ]; then
50+
fn_print_fail "Checking remote build: ${remotelocation}"
51+
fn_script_log_fail "Checking remote build"
52+
core_exit.sh
53+
else
54+
fn_print_ok "Checking remote build: ${remotelocation}"
55+
fn_script_log_pass "Checking remote build"
56+
fi
57+
else
58+
# Checks if remotebuild variable has been set.
59+
if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ] || [ -z "${remotebuildurl}" ] || [ "${remotebuildurl}" == "null" ] || [ -z "${remotebuildfilename}" ] || [ "${remotebuildfilename}" == "null" ]; then
60+
fn_print_failure "Unable to get remote build"
61+
fn_script_log_fail "Unable to get remote build"
62+
core_exit.sh
63+
fi
64+
fi
65+
}
66+
67+
fn_update_compare() {
68+
fn_print_dots "Checking for update: ${remotelocation}"
69+
# Update has been found or force update.
70+
if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then
71+
# Create update lockfile.
72+
date '+%s' > "${lockdir:?}/update.lock"
73+
fn_print_ok_nl "Checking for update: ${remotelocation}"
74+
fn_print "\n"
75+
fn_print_nl "${bold}${underline}Update${default} available"
76+
fn_print_nl "* Local build: ${red}${localbuild}${default}"
77+
fn_print_nl "* Remote build: ${green}${remotebuild}${default}"
78+
if [ -n "${branch}" ]; then
79+
fn_print_nl "* Branch: ${branch}"
80+
fi
81+
if [ -f "${rootdir}/.dev-debug" ]; then
82+
fn_print_nl "Remote build info"
83+
fn_print_nl "* apiurl: ${apiurl}"
84+
fn_print_nl "* remotebuildfilename: ${remotebuildfilename}"
85+
fn_print_nl "* remotebuildurl: ${remotebuildurl}"
86+
fn_print_nl "* remotebuildhash: ${remotebuildhash}"
87+
fn_print_nl "* remotebuild: ${remotebuild}"
88+
fi
89+
fn_print "\n"
90+
fn_script_log_info "Update available"
91+
fn_script_log_info "Local build: ${localbuild}"
92+
fn_script_log_info "Remote build: ${remotebuild}"
93+
if [ -n "${branch}" ]; then
94+
fn_script_log_info "Branch: ${branch}"
95+
fi
96+
fn_script_log_info "${localbuild} > ${remotebuild}"
97+
98+
if [ "${commandname}" == "UPDATE" ]; then
99+
date +%s > "${lockdir:?}/last-updated.lock"
100+
unset updateonstart
101+
check_status.sh
102+
# If server stopped.
103+
if [ "${status}" == "0" ]; then
104+
fn_update_dl
105+
if [ "${localbuild}" == "0" ]; then
106+
exitbypass=1
107+
command_start.sh
108+
fn_firstcommand_reset
109+
exitbypass=1
110+
fn_sleep_time_5
111+
command_stop.sh
112+
fn_firstcommand_reset
113+
fi
114+
# If server started.
115+
else
116+
fn_print_restart_warning
117+
exitbypass=1
118+
command_stop.sh
119+
fn_firstcommand_reset
120+
exitbypass=1
121+
fn_update_dl
122+
exitbypass=1
123+
command_start.sh
124+
fn_firstcommand_reset
125+
fi
126+
unset exitbypass
127+
alert="update"
128+
elif [ "${commandname}" == "CHECK-UPDATE" ]; then
129+
alert="check-update"
130+
fi
131+
alert.sh
132+
else
133+
fn_print_ok_nl "Checking for update: ${remotelocation}"
134+
fn_print "\n"
135+
fn_print_nl "${bold}${underline}No update${default} available"
136+
fn_print_nl "* Local build: ${green}${localbuild}${default}"
137+
fn_print_nl "* Remote build: ${green}${remotebuild}${default}"
138+
if [ -n "${branch}" ]; then
139+
fn_print_nl "* Branch: ${branch}"
140+
fi
141+
fn_print "\n"
142+
fn_script_log_info "No update available"
143+
fn_script_log_info "Local build: ${localbuild}"
144+
fn_script_log_info "Remote build: ${remotebuild}"
145+
if [ -n "${branch}" ]; then
146+
fn_script_log_info "Branch: ${branch}"
147+
fi
148+
if [ -f "${rootdir}/.dev-debug" ]; then
149+
fn_print_nl "Remote build info"
150+
fn_print_nl "* apiurl: ${apiurl}"
151+
fn_print_nl "* remotebuildfilename: ${remotebuildfilename}"
152+
fn_print_nl "* remotebuildurl: ${remotebuildurl}"
153+
fn_print_nl "* remotebuildhash: ${remotebuildhash}"
154+
fn_print_nl "* remotebuild: ${remotebuild}"
155+
fi
156+
fi
157+
}
158+
159+
# The location where the builds are checked and downloaded.
160+
remotelocation="github.com"
161+
162+
if [ "${firstcommandname}" == "INSTALL" ]; then
163+
fn_update_remotebuild
164+
fn_update_dl
165+
else
166+
# BrainBread requires both Steam app updates and GitHub package updates.
167+
update_steamcmd.sh
168+
169+
fn_print_dots "Checking for update"
170+
fn_print_dots "Checking for update: ${remotelocation}"
171+
fn_script_log_info "Checking for update: ${remotelocation}"
172+
fn_update_localbuild
173+
fn_update_remotebuild
174+
fn_update_compare
175+
fi

0 commit comments

Comments
 (0)