forked from GameServerManagers/LinuxGSM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_debug.sh
executable file
·134 lines (121 loc) · 4.05 KB
/
command_debug.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# LinuxGSM command_debug.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Runs the server without tmux and directly from the terminal.
commandname="DEBUG"
commandaction="Debuging"
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set
# Trap to remove lockfile on quit.
fn_lockfile_trap(){
# Remove lockfile.
rm -f "${lockdir:?}/${selfname}.lock"
# resets terminal. Servers can sometimes mess up the terminal on exit.
reset
fn_print_dots "Stopping debug"
fn_print_ok_nl "Stopping debug"
fn_script_log_pass "Stopping debug"
# remove trap.
trap - INT
core_exit.sh
}
check.sh
fix.sh
info_distro.sh
info_game.sh
# NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh.
fn_print_header
{
echo -e "${lightblue}Distro:\t\t${default}${distroname}"
echo -e "${lightblue}Arch:\t\t${default}${arch}"
echo -e "${lightblue}Kernel:\t\t${default}${kernel}"
echo -e "${lightblue}Hostname:\t\t${default}${HOSTNAME}"
echo -e "${lightblue}tmux:\t\t${default}${tmuxv}"
echo -e "${lightblue}Avg Load:\t\t${default}${load}"
echo -e "${lightblue}Free Memory:\t\t${default}${physmemfree}"
echo -e "${lightblue}Free Disk:\t\t${default}${availspace}"
} | column -s $'\t' -t
# glibc required.
if [ "${glibc}" ]; then
if [ "${glibc}" == "null" ]; then
# Glibc is not required.
:
elif [ -z "${glibc}" ]; then
echo -e "${lightblue}glibc required:\t${red}UNKNOWN${default}"
elif [ "$(printf '%s\n'${glibc}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibc}" ]; then
echo -e "${lightblue}glibc required:\t${red}${glibc} ${default}(${red}distro glibc ${glibcversion} too old${default})"
else
echo -e "${lightblue}glibc required:\t${green}${glibc}${default}"
fi
fi
# Server IP
echo -e "${lightblue}Game Server IP:\t${default}${ip}:${port}"
# External server IP.
if [ "${extip}" ]; then
if [ "${ip}" != "${extip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${extip}:${port}"
fi
fi
# Server password.
if [ "${serverpassword}" ]; then
echo -e "${lightblue}Server password:\t${default}${serverpassword}"
fi
fn_reload_startparameters
echo -e "${lightblue}Start parameters:${default}"
if [ "${engine}" == "source" ]||[ "${engine}" == "goldsrc" ]; then
echo -e "${executable} ${startparameters} -debug"
elif [ "${engine}" == "quake" ]; then
echo -e "${executable} ${startparameters} -condebug"
else
echo -e "${preexecutable} ${executable} ${startparameters}"
fi
echo -e ""
echo -e "Use for identifying server issues only!"
echo -e "Press CTRL+c to drop out of debug mode."
fn_print_warning_nl "If ${selfname} is already running it will be stopped."
echo -e ""
if ! fn_prompt_yn "Continue?" Y; then
exitcode=0
core_exit.sh
fi
fn_print_info_nl "Stopping any running servers"
fn_script_log_info "Stopping any running servers"
exitbypass=1
command_stop.sh
fn_firstcommand_reset
unset exitbypass
fn_print_dots "Starting debug"
fn_script_log_info "Starting debug"
fn_print_ok_nl "Starting debug"
# Create lockfile.
date '+%s' > "${lockdir}/${selfname}.lock"
echo "${version}" >> "${lockdir}/${selfname}.lock"
echo "${port}" >> "${lockdir}/${selfname}.lock"
fn_script_log_info "Lockfile generated"
fn_script_log_info "${lockdir}/${selfname}.lock"
if [ "${shortname}" == "av" ]; then
cd "${systemdir}" || exit
else
cd "${executabledir}" || exit
fi
# Note: do not add double quotes to ${executable} ${startparameters}.
if [ "${engine}" == "source" ]||[ "${engine}" == "goldsrc" ]; then
${executable} ${startparameters} -debug
elif [ "${shortname}" == "arma3" ]; then
# Arma3 requires semicolons in the module list, which need to
# be escaped for regular (tmux) loading, but need to be
# stripped when loading straight from the console.
${executable} ${parms//\\;/;}
elif [ "${engine}" == "quake" ]; then
${executable} ${startparameters} -condebug
else
# shellcheck disable=SC2086
${preexecutable} ${executable} ${startparameters}
fi
fn_lockfile_trap
fn_print_dots "Stopping debug"
fn_print_ok_nl "Stopping debug"
fn_script_log_info "Stopping debug"
core_exit.sh