Skip to content

Commit

Permalink
add new developer commands for parsing game and distro details
Browse files Browse the repository at this point in the history
  • Loading branch information
MicLieg committed Mar 3, 2024
1 parent 2461403 commit 7001079
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 7 deletions.
108 changes: 108 additions & 0 deletions lgsm/modules/command_dev_parse_distro_details.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash
# LinuxGSM command_dev_parse_distro_details.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Display parsed distro details.

info_distro.sh

# Create an associative array of the server details.
declare -A server_details=(
['.NET Version']="${dotnetversion}"
['Arch']="${arch}"
['Avail Space']="${availspace}"
['Backup Count']="${backupcount}"
['Backup Dir DU']="${backupdirdu}"
['CPU Cores']="${cpucores}"
['CPU Frequency']="${cpufreqency}"
['CPU Model']="${cpumodel}"
['CPU Used MHz']="${cpuusedmhz}"
['CPU Used']="${cpuused}"
['Days']="${days}"
['Distro Codename']="${distrocodename}"
['Distro ID Like']="${distroidlike}"
['Distro ID']="${distroid}"
['Distro Info Array']="${distro_info_array}"
['Distro Name']="${distroname}"
['Distro Support']="${distrosupport}"
['Distro Version CSV']="${distroversioncsv}"
['Distro Version RH']="${distroversionrh}"
['Distro Version']="${distroversion}"
['Distros Unsupported Array']="${distrosunsupported_array}"
['Distros Unsupported']="${distrosunsupported}"
['File System']="${filesystem}"
['Game Server PID']="${gameserverpid}"
['GLIBC Version']="${glibcversion}"
['GLIBC']="${glibc}"
['HLDS Linux PID']="${hldslinuxpid}"
['Hours']="${hours}"
['Human Readable']="${humanreadable}"
['Java Version']="${javaversion}"
['Kernel']="${kernel}"
['Last Backup Date']="${lastbackupdate}"
['Last Backup Days Ago']="${lastbackupdaysago}"
['Last Backup Size']="${lastbackupsize}"
['Last Backup']="${lastbackup}"
['Load']="${load}"
['Mem Used MB']="${memusedmb}"
['Mem Used Pct']="${memusedpct}"
['Minutes']="${minutes}"
['Module Self Name']="${moduleselfname}"
['Mono Version']="${monoversion}"
['Net Int']="${netint}"
['Net Link']="${netlink}"
['Old Free']="${oldfree}"
['Phys Mem Actual Free KB']="${physmemactualfreekb}"
['Phys Mem Available']="${physmemavailable}"
['Phys Mem Buffers KB']="${physmembufferskb}"
['Phys Mem Cached KB']="${physmemcachedkb}"
['Phys Mem Cached']="${physmemcached}"
['Phys Mem Free KB']="${physmemfreekb}"
['Phys Mem Free']="${physmemfree}"
['Phys Mem Reclaimable KB']="${physmemreclaimablekb}"
['Phys Mem Total GB']="${physmemtotalgb}"
['Phys Mem Total KB']="${physmemtotalkb}"
['Phys Mem Total MB']="${physmemtotalmb}"
['Phys Mem Total']="${physmemtotal}"
['Phys Mem Used']="${physmemused}"
['Root Dir DU Ex Backup']="${rootdirduexbackup}"
['Root Dir DU']="${rootdirdu}"
['Server Files DU']="${serverfilesdu}"
['SRCDS Linux PID']="${srcdslinuxpid}"
['SS Info']="${ssinfo}"
['Swap Free']="${swapfree}"
['Swap Total']="${swaptotal}"
['Swap Used']="${swapused}"
['Tmux Version']="${tmuxversion}"
['Total Space']="${totalspace}"
['Uptime']="${uptime}"
['Used Space']="${usedspace}"
['Virtual Environment']="${virtualenvironment}"
)

# Initialize a variable to keep track of missing distro details.
missing_details=""

# Loop through the distro details and output them.
echo -e ""
echo -e "${bold}${lightgreen}Available Distro Details${default}"
fn_messages_separator
for key in "${!server_details[@]}"; do
value=${server_details[$key]}
if [ -z "$value" ]; then
missing_details+="\n${key}"
else
echo -e "$key: $value "
fi
done

# Output the missing distro details if there are any.
if [ -n "$missing_details" ]; then
echo -e ""
echo -e "${lightgreen}Missing or unsupported Dsitro Details${default}"
fn_messages_separator
echo -e "${missing_details}" | sort
fi

core_exit.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
# LinuxGSM command_dev_debug.sh module
# LinuxGSM command_dev_parse_game_details.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Dev only: Enables debugging log to be saved to dev-debug.log.
# Description: Display parsed gameserver details.

if [ -f "config" ]; then
servercfgfullpath="config"
Expand Down Expand Up @@ -32,42 +32,100 @@ echo -e "Carriage Return: ${carriagereturn}"
# Create an associative array of the server details.
declare -A server_details=(
['Admin Password']="${adminpassword}"
['Alert IP']="${alertip}"
['API Port']="${apiport}"
['App Port']="${appport}"
['ASE']="${ase}"
['Auth Token']="${authtoken}"
['BattleEye Port']="${battleeyeport}"
['Beacon Port']="${beaconport}"
['Cave']="${cave}"
['Client Port']="${clientport}"
['Cluster']="${cluster}"
['Config IP']="${configip}"
['Creative Mode']="${creativemode}"
['Custom Level URL']="${customlevelurl}"
['DB Plugin']="${dbplugin}"
['Default Map']="${defaultmap}"
['Default Scenario']="${defaultscenario}"
['Display Master Server']="${displaymasterserver}"
['Epic Settings']="${epicsettings}"
['File Port']="${fileport}"
['Files Port']="${filesport}"
['Game Mode']="${gamemode}"
['Game Type']="${gametype}"
['Home Kingdom']="${homekingdom}"
['Home Server']="${homeserver}"
['HTTP Enabled']="${httpenabled}"
['HTTP IP']="${httpip}"
['HTTP Password']="${httppassword}"
['HTTP Port']="${httpport}"
['HTTP User']="${httpuser}"
['Internet IP']="${publicip}"
['LAN Port']="${lanport}"
['Login Server']="${loginserver}"
['Master Port']="${masterport}"
['Master Server']="${masterserver}"
['Master']="${master}"
['Max Players']="${maxplayers}"
['Maxplayers']="${maxplayers}"
['Mod Server Port']="${modserverport}"
['OldQueryPortNumber']="${oldqueryportnumber}"
['Password']="${password}"
['Port 401']="${port401}"
['Port IPv6']="${portipv6}"
['Port']="${port}"
['Query Enabled']="${queryenabled}"
['Query HTTP Port']="${queryhttpport}"
['Query HTTPS Port']="${queryhttpsport}"
['Query Mode']="${querymode}"
['Query Port GS']="${queryportgs}"
['Query Port']="${queryport}"
['Query SSH Port']="${querysshport}"
['Queue Enabled']="${queueenabled}"
['Queue Port']="${queueport}"
['Random Map']="${randommap}"
['Raw Port']="${rawport}"
['RC Password']="${rcpassword}"
['RCON Enabled']="${rconenabled}"
['RCON Password']="${rconpassword}"
['RCON Port']="${rconport}"
['RCON Web']="${rconweb}"
['Reserved Slots']="${reservedslots}"
['RMI Port']="${rmiport}"
['RMI Reg Port']="${rmiregport}"
['Salt']="${salt}"
['Save Game Interval']="${savegameinterval}"
['Save Interval']="${saveinterval}"
['Secondary Port']="${port3}"
['Seed']="${seed}"
['Server Description']="${serverdescription}"
['Server IP']="${ip}"
['Server Level']="${serverlevel}"
['Server Name']="${servername}"
['Server Password Enabled']="${serverpasswordenabled}"
['Server Password']="${serverpassword}"
['Server Version']="${serverversion}"
['Servername']="${servername}"
['Shard']="${shard}"
['Sharding']="${sharding}"
['Shutdown Port']="${shutdownport}"
['Stats Port']="${statsport}"
['Steam Auth Port']="${steamauthport}"
['Steam Port']="${steamport}"
['Steamworks Port']="${steamworksport}"
['Telnet Enabled']="${telnetenabled}"
['Telnet IP']="${telnetip}"
['Telnet Password']="${telnetpass}"
['Telnet Password']="${telnetpassword}"
['Telnet Port']="${telnetport}"
['Tickrate']="${tickrate}"
['Unknown Port']="${unknownport}"
['Version Count']="${versioncount}"
['Voice Port']="${voiceport}"
['Voice Unused Port']="${voiceunusedport}"
['World Name']="${worldname}"
['World Size']="${worldsize}"
['World Type']="${worldtype}"
)

Expand All @@ -90,9 +148,10 @@ done
# Output the missing server details if there are any.
if [ -n "$missing_details" ]; then
echo -e ""
echo -e "${lightgreen}Missing Server Details${default}"
echo -e "${lightgreen}Missing Server Details"
echo -e "(or not supported by ${gamename})${default}"
fn_messages_separator
echo -e "${missing_details}"
echo -e "${missing_details}" | sort
fi

core_exit.sh
5 changes: 3 additions & 2 deletions lgsm/modules/core_getopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ cmd_install_squad_license=("li;license" "install_squad_license.sh" "Add your Squ
cmd_fastdl=("fd;fastdl" "command_fastdl.sh" "Build a FastDL directory.")
# Dev commands.
cmd_dev_debug=("dev;developer" "command_dev_debug.sh" "Enable developer Mode.")
cmd_dev_details=("ddt;detect-details" "command_dev_details.sh" "Display parsed details.")
cmd_dev_parse_game_details=("pgd;parse-game-details" "command_dev_parse_game_details.sh" "Display parsed gameserver details.")
cmd_dev_parse_distro_details=("pdd;parse-distro-details" "command_dev_parse_distro_details.sh" "Display parsed distro details.")
cmd_dev_detect_deps=("dd;detect-deps" "command_dev_detect_deps.sh" "Detect required dependencies.")
cmd_dev_detect_glibc=("dg;detect-glibc" "command_dev_detect_glibc.sh" "Detect required glibc.")
cmd_dev_detect_ldd=("dl;detect-ldd" "command_dev_detect_ldd.sh" "Detect required dynamic dependencies.")
Expand Down Expand Up @@ -146,7 +147,7 @@ currentopt+=("${cmd_install[@]}" "${cmd_auto_install[@]}")
## Developer commands.
currentopt+=("${cmd_dev_debug[@]}")
if [ -f ".dev-debug" ]; then
currentopt+=("${cmd_dev_details[@]}" "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" "${cmd_dev_query_raw[@]}" "${cmd_dev_clear_modules[@]}")
currentopt+=("${cmd_dev_parse_game_details[@]}" "${cmd_dev_parse_distro_details[@]}" "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" "${cmd_dev_query_raw[@]}" "${cmd_dev_clear_modules[@]}")
fi

## Sponsor.
Expand Down
7 changes: 6 additions & 1 deletion lgsm/modules/core_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,12 @@ command_dev_debug.sh() {
fn_fetch_module
}

command_dev_details.sh() {
command_dev_parse_game_details.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}

command_dev_parse_distro_details.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
Expand Down

0 comments on commit 7001079

Please sign in to comment.