Skip to content

Commit a075300

Browse files
authored
feat(check-update): add new command check-update for steamcmd game servers (#3146)
1 parent efa159d commit a075300

File tree

7 files changed

+384
-321
lines changed

7 files changed

+384
-321
lines changed

lgsm/functions/alert.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ fn_alert_update(){
6060
alertbody="${gamename} received update"
6161
}
6262

63+
fn_alert_check_update(){
64+
fn_script_log_info "Sending alert: Update available"
65+
alertsubject="Alert - ${selfname} - Update available"
66+
alertemoji="🎮"
67+
alertsound="1"
68+
alerturl="not enabled"
69+
alertbody="${gamename} update available"
70+
}
71+
6372
fn_alert_permissions(){
6473
fn_script_log_info "Sending alert: Permissions error"
6574
alertsubject="Alert - ${selfname}: Permissions error"
@@ -88,6 +97,8 @@ elif [ "${alert}" == "test" ]; then
8897
fn_alert_test
8998
elif [ "${alert}" == "update" ]; then
9099
fn_alert_update
100+
elif [ "${alert}" == "check-update" ]; then
101+
fn_alert_check_update
91102
elif [ "${alert}" == "config" ]; then
92103
fn_alert_config
93104
fi

lgsm/functions/check_steamcmd.sh

Lines changed: 2 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -6,145 +6,8 @@
66

77
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
88

9-
fn_install_steamcmd(){
10-
if [ "${shortname}" == "ark" ]&&[ "${installsteamcmd}" == "1" ]; then
11-
steamcmddir="${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux"
12-
fi
13-
if [ ! -d "${steamcmddir}" ]; then
14-
mkdir -p "${steamcmddir}"
15-
fi
16-
remote_fileurl="${1}"
17-
remote_fileurl_backup="${2}"
18-
remote_fileurl_name="${3}"
19-
remote_fileurl_backup_name="${4}"
20-
local_filedir="${5}"
21-
local_filename="${6}"
22-
chmodx="${7:-0}"
23-
run="${8:-0}"
24-
forcedl="${9:-0}"
25-
md5="${10:-0}"
26-
fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "" "" "" "${tmpdir}" "steamcmd_linux.tar.gz" "" "norun" "noforce" "nomd5"
27-
fn_dl_extract "${tmpdir}" "steamcmd_linux.tar.gz" "${steamcmddir}"
28-
chmod +x "${steamcmddir}/steamcmd.sh"
29-
}
30-
31-
fn_check_steamcmd_user(){
32-
# Checks if steamuser is setup.
33-
if [ "${steamuser}" == "username" ]; then
34-
fn_print_fail_nl "Steam login not set. Update steamuser in ${configdirserver}"
35-
echo -e " * Change steamuser=\"username\" to a valid steam login."
36-
if [ -d "${lgsmlogdir}" ]; then
37-
fn_script_log_fatal "Steam login not set. Update steamuser in ${configdirserver}"
38-
fi
39-
core_exit.sh
40-
fi
41-
# Anonymous user is set if steamuser is missing.
42-
if [ -z "${steamuser}" ]; then
43-
if [ -d "${lgsmlogdir}" ]; then
44-
fn_script_log_info "Using anonymous Steam login"
45-
fi
46-
steamuser="anonymous"
47-
steampass=''
48-
fi
49-
}
50-
51-
fn_check_steamcmd(){
52-
# Checks if SteamCMD exists when starting or updating a server.
53-
# Only install if steamcmd package is missing or steamcmd dir is missing.
54-
if [ ! -f "${steamcmddir}/steamcmd.sh" ]&&[ -z "$(command -v steamcmd 2>/dev/null)" ]; then
55-
if [ "${commandname}" == "INSTALL" ]; then
56-
fn_install_steamcmd
57-
else
58-
fn_print_warn_nl "SteamCMD is missing"
59-
fn_script_log_warn "SteamCMD is missing"
60-
fn_install_steamcmd
61-
fi
62-
elif [ "${commandname}" == "INSTALL" ]; then
63-
fn_print_information "SteamCMD is already installed..."
64-
fn_print_ok_eol_nl
65-
fi
66-
}
67-
68-
fn_check_steamcmd_dir(){
69-
# Worksround that pre-installs the correct steam directories to ensure all packages use the correct Standard.
70-
# https://github.com/ValveSoftware/steam-for-linux/issues/6976#issuecomment-610446347
71-
72-
# Create Steam installation directory.
73-
if [ ! -d "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
74-
mkdir -p "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam"
75-
fi
76-
77-
# Create common Steam directory.
78-
if [ ! -d "${HOME}/.steam" ]; then
79-
mkdir -p "${HOME}/.steam"
80-
fi
81-
82-
# Symbolic links to Steam installation directory.
83-
if [ ! -L "${HOME}/.steam/root" ]; then
84-
if [ -d "${HOME}/.steam/root" ]; then
85-
rm "${HOME}/.steam/root"
86-
fi
87-
ln -s "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" "${HOME}/.steam/root"
88-
fi
89-
90-
if [ ! -L "${HOME}/.steam/steam" ]; then
91-
if [ -d "${HOME}/.steam/steam" ]; then
92-
rm -rf "${HOME}/.steam/steam"
93-
fi
94-
ln -s "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" "${HOME}/.steam/steam"
95-
fi
96-
}
97-
98-
fn_check_steamcmd_dir_legacy(){
99-
# Remove old Steam installation directories ~/Steam and ${rootdir}/steamcmd
100-
if [ -d "${rootdir}/steamcmd" ]&&[ "${steamcmddir}" == "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
101-
rm -rf "${rootdir:?}/steamcmd"
102-
fi
103-
104-
if [ -d "${HOME}/Steam" ]&&[ "${steamcmddir}" == "${XDG_DATA_HOME:="${HOME}/.local/share"}/Steam" ]; then
105-
rm -rf "${HOME}/Steam"
106-
fi
107-
}
108-
109-
fn_check_steamcmd_ark(){
110-
# Checks if SteamCMD exists in
111-
# Engine/Binaries/ThirdParty/SteamCMD/Linux
112-
# to allow ark mods to work
113-
if [ ! -f "${serverfiles}/Engine/Binaries/ThirdParty/SteamCMD/Linux/steamcmd.sh" ]; then
114-
installsteamcmd=1
115-
if [ "${commandname}" == "INSTALL" ]; then
116-
fn_install_steamcmd
117-
else
118-
fn_print_warn_nl "ARK mods SteamCMD is missing"
119-
fn_script_log_warn "ARK mods SteamCMD is missing"
120-
fn_install_steamcmd
121-
fi
122-
elif [ "${commandname}" == "INSTALL" ]; then
123-
fn_print_information "ARK mods SteamCMD is already installed..."
124-
fn_print_ok_eol_nl
125-
fi
126-
}
127-
128-
fn_check_steamcmd_clear(){
129-
# Will remove steamcmd dir if steamcmd package is installed.
130-
if [ "$(command -v steamcmd 2>/dev/null)" ]&&[ -d "${rootdir}/steamcmd" ]; then
131-
rm -rf "${steamcmddir:?}"
132-
exitcode=$?
133-
if [ "${exitcode}" != 0 ]; then
134-
fn_script_log_fatal "Removing ${rootdir}/steamcmd"
135-
else
136-
fn_script_log_pass "Removing ${rootdir}/steamcmd"
137-
fi
138-
fi
139-
}
140-
141-
fn_check_steamcmd_exec(){
142-
if [ "$(command -v steamcmd 2>/dev/null)" ]; then
143-
steamcmdcommand="steamcmd"
144-
else
145-
steamcmdcommand="./steamcmd.sh"
146-
fi
147-
}
9+
# init steamcmd functions
10+
core_steamcmd.sh
14811

14912
fn_check_steamcmd_clear
15013
fn_check_steamcmd
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# LinuxGSM command_check_update.sh function
3+
# Author: Daniel Gibbs
4+
# Website: https://linuxgsm.com
5+
# Description: Handles updating of servers.
6+
7+
commandname="CHECK-UPDATE"
8+
commandaction="check for Update"
9+
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
10+
fn_firstcommand_set
11+
12+
fn_print_dots ""
13+
check.sh
14+
core_logs.sh
15+
16+
core_steamcmd.sh
17+
18+
check_steamcmd.sh
19+
20+
fn_update_steamcmd_localbuild
21+
fn_update_steamcmd_remotebuild
22+
fn_update_steamcmd_compare
23+
24+
core_exit.sh

lgsm/functions/core_functions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ functionfile="${FUNCNAME[0]}"
5353
fn_fetch_function
5454
}
5555

56+
core_steamcmd.sh(){
57+
functionfile="${FUNCNAME[0]}"
58+
fn_fetch_function
59+
}
60+
5661
# Commands
5762

5863
command_backup.sh(){
@@ -599,6 +604,11 @@ functionfile="${FUNCNAME[0]}"
599604
fn_fetch_function
600605
}
601606

607+
command_check_update.sh(){
608+
functionfile="${FUNCNAME[0]}"
609+
fn_fetch_function
610+
}
611+
602612
update_ts3.sh(){
603613
functionfile="${FUNCNAME[0]}"
604614
fn_fetch_function

lgsm/functions/core_getopt.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cmd_console=( "c;console" "command_console.sh" "Access server console." )
2727
cmd_debug=( "d;debug" "command_debug.sh" "Start server directly in your terminal." )
2828
# Update servers only.
2929
cmd_update=( "u;update" "command_update.sh" "Check and apply any server updates." )
30+
cmd_check_update=( "cu;check-update" "command_check_update.sh" "Check if a gameserver update is available" )
3031
cmd_force_update=( "fu;force-update;update-restart;ur" "forceupdate=1; command_update.sh" "Apply server updates bypassing check." )
3132
# SteamCMD servers only.
3233
cmd_validate=( "v;validate" "command_validate.sh" "Validate server files with SteamCMD." )
@@ -72,9 +73,9 @@ if [ "${shortname}" == "jk2" ]||[ "${engine}" != "idtech3" ];then
7273
fi
7374
fi
7475

75-
# Validate command.
76+
# Validate and check-update command.
7677
if [ "${appid}" ]; then
77-
currentopt+=( "${cmd_validate[@]}" )
78+
currentopt+=( "${cmd_validate[@]}" "${cmd_check_update[@]}" )
7879
fi
7980

8081
# Backup.

0 commit comments

Comments
 (0)