Browse Source

standardise for loop do

pull/3015/head
Daniel Gibbs 5 years ago
parent
commit
e02b878da5
  1. 27
      lgsm/functions/check.sh
  2. 3
      lgsm/functions/check_deps.sh
  3. 4
      lgsm/functions/check_ip.sh
  4. 9
      lgsm/functions/command_backup.sh
  5. 3
      lgsm/functions/command_details.sh
  6. 9
      lgsm/functions/command_dev_detect_deps.sh
  7. 3
      lgsm/functions/command_dev_detect_glibc.sh
  8. 15
      lgsm/functions/command_dev_query_raw.sh
  9. 9
      lgsm/functions/command_fastdl.sh
  10. 7
      lgsm/functions/command_monitor.sh
  11. 3
      lgsm/functions/command_update_linuxgsm.sh
  12. 3
      lgsm/functions/core_dl.sh
  13. 3
      lgsm/functions/core_legacy.sh
  14. 3
      lgsm/functions/info_distro.sh
  15. 26
      lgsm/functions/info_messages.sh
  16. 3
      linuxgsm.sh
  17. 3
      tests/tests_fctrserver.sh
  18. 3
      tests/tests_jc2server.sh
  19. 3
      tests/tests_mcserver.sh
  20. 3
      tests/tests_ts3server.sh

27
lgsm/functions/check.sh

@ -31,8 +31,7 @@ if [ "${commandname}" != "INSTALL" ]&&[ "${commandname}" != "UPDATE-LGSM" ]&&[ "
fi
allowed_commands_array=( START DEBUG )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_executable.sh
fi
@ -40,8 +39,7 @@ done
if [ "$(whoami)" != "root" ]; then
allowed_commands_array=( DEBUG START INSTALL )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_glibc.sh
fi
@ -49,32 +47,28 @@ if [ "$(whoami)" != "root" ]; then
fi
allowed_commands_array=( BACKUP CONSOLE DEBUG DETAILS MAP-COMPRESSOR FASTDL MODS-INSTALL MODS-REMOVE MODS-UPDATE MONITOR POST-DETAILS RESTART START STOP TEST-ALERT CHANGE-PASSWORD UPDATE UPDATE-LGSM VALIDATE WIPE )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_logs.sh
fi
done
allowed_commands_array=( DEBUG START STOP )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_deps.sh
fi
done
allowed_commands_array=( CONSOLE DEBUG MONITOR START STOP )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_config.sh
fi
done
allowed_commands_array=( DEBUG DETAILS POST_DETAILS MONITOR START STOP DEV-QUERY-RAW )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
if [ -z "${installflag}" ]; then
check_ip.sh
@ -83,8 +77,7 @@ do
done
allowed_commands_array=( DEBUG START UPDATE VALIDATE )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
if [ "${appid}" ]; then
check_steamcmd.sh
@ -93,16 +86,14 @@ do
done
allowed_commands_array=( DETAILS MONITOR START STOP CHANGE-PASSWORD UPDATE VALIDATE )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_status.sh
fi
done
allowed_commands_array=( DEBUG START INSTALL )
for allowed_command in "${allowed_commands_array[@]}"
do
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_system_requirements.sh
fi

3
lgsm/functions/check_deps.sh

@ -329,8 +329,7 @@ fn_found_missing_deps(){
fn_check_loop(){
# Loop though required depenencies.
for deptocheck in ${array_deps_required[*]}
do
for deptocheck in ${array_deps_required[*]}; do
fn_deps_detector
done

4
lgsm/functions/check_ip.sh

@ -15,8 +15,8 @@ if [ ! -f "/bin/ip" ]; then
else
ipcommand="ip"
fi
getip=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|sort -u|grep -v 127.0.0)
getipwc=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|sort -u|grep -vc 127.0.0)
getip=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0)
getipwc=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -vc 127.0.0)
# Check if server has multiple IP addresses

9
lgsm/functions/command_backup.sh

@ -218,20 +218,17 @@ fn_backup_relpath() {
# Compare the leading entries of each array. These common elements will be clipped off.
# for the relative path output.
for ((base=0; base<${#rdirtoks[@]}; base++))
do
for ((base=0; base<${#rdirtoks[@]}; base++)); do
[[ "${rdirtoks[$base]}" != "${bdirtoks[$base]}" ]] && break
done
# Next, climb out of the remaining rootdir location with updir references.
for ((x=base;x<${#rdirtoks[@]};x++))
do
for ((x=base;x<${#rdirtoks[@]};x++)); do
echo -n "../"
done
# Climb down the remaining components of the backupdir location.
for ((x=base;x<$(( ${#bdirtoks[@]} - 1 ));x++))
do
for ((x=base;x<$(( ${#bdirtoks[@]} - 1 ));x++)); do
echo -n "${bdirtoks[$x]}/"
done

3
lgsm/functions/command_details.sh

@ -17,8 +17,7 @@ info_parms.sh
info_distro.sh
info_messages.sh
if [ "${querymode}" == "2" ]||[ "${querymode}" == "3" ]; then
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
query_gamedig.sh
if [ "${querystatus}" == "0" ]; then
break

9
lgsm/functions/command_dev_detect_deps.sh

@ -42,8 +42,7 @@ touch "${tmpdir}/.depdetect_debian_list"
while read -r lib; do
echo -e "${lib}"
libs_array=( libm.so.6 libc.so.6 libtcmalloc_minimal.so.4 libpthread.so.0 libdl.so.2 libnsl.so.1 libgcc_s.so.1 librt.so.1 ld-linux.so.2 libdbus-glib-1.so.2 libgio-2.0.so.0 libglib-2.0.so.0 libGL.so.1 libgobject-2.0.so.0 libnm-glib.so.4 libnm-util.so.2 )
for lib_file in "${libs_array[@]}"
do
for lib_file in "${libs_array[@]}"; do
if [ "${lib}" == "${lib_file}" ]; then
echo -e "glibc.i686" >> "${tmpdir}/.depdetect_centos_list"
echo -e "lib32gcc1" >> "${tmpdir}/.depdetect_ubuntu_list"
@ -53,8 +52,7 @@ while read -r lib; do
done
libs_array=( libawt.so libjava.so libjli.so libjvm.so libnet.so libnio.so libverify.so )
for lib_file in "${libs_array[@]}"
do
for lib_file in "${libs_array[@]}"; do
if [ "${lib}" == "${lib_file}" ]; then
echo -e "java-1.8.0-openjdk" >> "${tmpdir}/.depdetect_centos_list"
echo -e "default-jre" >> "${tmpdir}/.depdetect_ubuntu_list"
@ -64,8 +62,7 @@ while read -r lib; do
done
libs_array=( libtier0.so libtier0_srv.so libvstdlib_srv.so Core.so libvstdlib.so libtier0_s.so Editor.so Engine.so liblua.so libsteam_api.so ld-linux-x86-64.so.2 libPhysX3_x86.so libPhysX3Common_x86.so libPhysX3Cooking_x86.so)
for lib_file in "${libs_array[@]}"
do
for lib_file in "${libs_array[@]}"; do
# Known shared libs what dont requires dependencies.
if [ "${lib}" == "${lib_file}" ]; then
libdetected=1

3
lgsm/functions/command_dev_detect_glibc.sh

@ -35,8 +35,7 @@ echo -e ""
glibc_check_dir_array=( steamcmddir serverfiles )
for glibc_check_var in "${glibc_check_dir_array[@]}"
do
for glibc_check_var in "${glibc_check_dir_array[@]}"; do
if [ "${glibc_check_var}" == "serverfiles" ]; then
glibc_check_dir="${serverfiles}"
glibc_check_name="${gamename}"

15
lgsm/functions/command_dev_query_raw.sh

@ -18,8 +18,7 @@ echo -e "Query Port - Raw Output"
echo -e "=================================================================="
echo -e ""
echo -e "QUERY IP"
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
echo -e "${queryip}"
done
echo -e "================================="
@ -38,8 +37,7 @@ fi
if [ ! "$(command -v jq 2>/dev/null)" ]; then
fn_print_failure_nl "jq not installed"
fi
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
query_gamedig.sh
echo -e "${gamedigcmd}"
echo""
@ -49,8 +47,7 @@ echo -e ""
echo -e "gsquery Raw Output"
echo -e "================================="
echo -e ""
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
echo -e "./query_gsquery.py -a \"${queryip}\" -p \"${queryport}\" -e \"${querytype}\""
echo -e ""
if [ ! -f "${functionsdir}/query_gsquery.py" ]; then
@ -62,8 +59,7 @@ echo -e ""
echo -e "TCP Raw Output"
echo -e "================================="
echo -e ""
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
echo -e "bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}''"
echo -e ""
timeout 3 bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}''
@ -82,8 +78,7 @@ echo -e ""
echo -e "TCP Raw Output"
echo -e "================================="
echo -e ""
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
echo -e "bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}''"
echo -e ""
timeout 3 bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}''

9
lgsm/functions/command_fastdl.sh

@ -236,8 +236,7 @@ fn_fastdl_preview(){
# Builds Garry's Mod fastdl directory content.
fn_fastdl_gmod(){
cd "${systemdir}" || exit
for allowed_extention in "${allowed_extentions_array[@]}"
do
for allowed_extention in "${allowed_extentions_array[@]}"; do
fileswc=0
tput sc
while read -r fastdlfile; do
@ -311,8 +310,7 @@ fn_fastdl_gmod(){
}
fn_fastdl_source(){
for directory in "${fastdl_directories_array[@]}"
do
for directory in "${fastdl_directories_array[@]}"; do
if [ -d "${systemdir}/${directory}" ]; then
if [ "${directory}" == "maps" ]; then
local allowed_extentions_array=( "*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt" )
@ -325,8 +323,7 @@ fn_fastdl_source(){
elif [ "${directory}" == "sound" ]; then
local allowed_extentions_array=( "*.wav" "*.mp3" "*.ogg" )
fi
for allowed_extention in "${allowed_extentions_array[@]}"
do
for allowed_extention in "${allowed_extentions_array[@]}"; do
fileswc=0
tput sc
while read -r fastdlfile; do

7
lgsm/functions/command_monitor.sh

@ -101,8 +101,7 @@ fn_monitor_query(){
# Query will wait up to 60 seconds to confirm server is down as server can become non-responsive during map changes.
totalseconds=0
for queryattempt in {1..5}; do
for queryip in "${queryips[@]}"
do
for queryip in "${queryips[@]}"; do
fn_print_dots "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: "
fn_print_querying_eol
fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : QUERYING"
@ -188,7 +187,6 @@ for queryattempt in {1..5}; do
break
fi
done
done
}
@ -204,8 +202,7 @@ fn_monitor_loop(){
elif [ "${querymode}" == "5" ]; then
local query_methods_array=( tcp )
fi
for querymethod in "${query_methods_array[@]}"
do
for querymethod in "${query_methods_array[@]}"; do
# Will check if gamedig is installed and bypass if not.
if [ "${querymethod}" == "gamedig" ]; then
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then

3
lgsm/functions/command_update_linuxgsm.sh

@ -149,8 +149,7 @@ fi
if [ -n "${functionsdir}" ]; then
if [ -d "${functionsdir}" ]; then
cd "${functionsdir}" || exit
for functionfile in *
do
for functionfile in *; do
# check if module exists in the repo and remove if missing.
# commonly used if module names change.
echo -en "checking ${remotereponame} module ${functionfile}...\c"

3
lgsm/functions/core_dl.sh

@ -248,8 +248,7 @@ fn_fetch_file(){
counter=1
remote_fileurls_array=( remote_fileurl )
fi
for remote_fileurl_array in "${remote_fileurls_array[@]}"
do
for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
fileurl="${remote_fileurl}"
fileurl_name="${remote_fileurl_name}"

3
lgsm/functions/core_legacy.sh

@ -8,8 +8,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# This is to help the transition to v20.3.0 and above
legacy_versions_array=( v20.2.1 v20.2.0 v20.1.5 v20.1.4 v20.1.3 v20.1.2 v20.1.1 v20.1.0 v19.12.5 v19.12.4 v19.12.3 v19.12.2 v19.12.1 v19.12.0 )
for legacy_version in "${legacy_versions_array[@]}"
do
for legacy_version in "${legacy_versions_array[@]}"; do
if [ "${version}" == "${legacy_version}" ]; then
legacymode=1
fi

3
lgsm/functions/info_distro.sh

@ -25,8 +25,7 @@ kernel=$(uname -r)
# Gathers distro info from various sources filling in missing gaps.
distro_info_array=( os-release lsb_release hostnamectl debian_version redhat-release )
for distro_info in "${distro_info_array[@]}"
do
for distro_info in "${distro_info_array[@]}"; do
if [ -f "/etc/os-release" ]&&[ "${distro_info}" == "os-release" ]; then
distroname=$(grep PRETTY_NAME /etc/os-release | sed 's/PRETTY_NAME=//g' | tr -d '="' | sed 's/\"//g')
distroversion=$(grep VERSION_ID /etc/os-release | sed 's/VERSION_ID=//g' | sed 's/\"//g')

26
lgsm/functions/info_messages.sh

@ -25,8 +25,12 @@ fn_info_message_head(){
echo -e "Hostname"
echo -e "${HOSTNAME}"
echo -e ""
echo -e "Game Server IP"
echo -e "Server IP"
if [ "${multiple_ip}" == "1" ]; then
echo -e "NOT SET"
else
echo -e "${ip}:${port}"
fi
}
fn_info_message_distro(){
@ -109,7 +113,7 @@ fn_info_message_server_resource(){
if [ -n "${netlink}" ]; then
echo -e "${lightblue}Link Speed:\t${default}${netlink}"
fi
echo -e "${lightblue}Server IP:\t${default}${getip}"
echo -e "${lightblue}IP:\t${default}${ip}"
if [ "${ip}" != "${extip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${extip}"
fi
@ -154,7 +158,7 @@ fn_info_message_gameserver(){
# Counter-Strike: Global Offensive Server Details
# ==========================================================================================================================================================================================================================================
# Server name: LinuxGSM
# Game Server IP: 80.70.189.230:27015
# Server IP: 80.70.189.230:27015
# Server password: NOT SET
# RCON password: adminF54CC0VR
# Players: 0/16
@ -198,8 +202,12 @@ fn_info_message_gameserver(){
echo -e "${lightblue}Beta Password:\t${default}${betapassword}"
fi
# Game Server IP
echo -e "${lightblue}Game Server IP:\t${default}${ip}:${port}"
# Server ip
if [ "${multiple_ip}" == "1" ]; then
echo -e "${lightblue}Server IP:\t${default}NOT SET"
else
echo -e "${lightblue}Server IP:\t${default}${ip}:${port}"
fi
# Internet ip
if [ -n "${extip}" ]; then
@ -547,8 +555,7 @@ fn_info_message_ports(){
parmslocation="${red}UNKNOWN${default}"
# engines/games that require editing in the config file.
local ports_edit_array=( "avalanche2.0" "avalanche3.0" "Ballistic Overkill" "dontstarve" "Eco" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "Minecraft Bedrock" "Project Cars" "projectzomboid" "quake" "refractor" "realvirtuality" "renderware" "seriousengine35" "Stationeers" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" "wurm")
for port_edit in "${ports_edit_array[@]}"
do
for port_edit in "${ports_edit_array[@]}"; do
if [ "${shortname}" == "ut3" ]; then
parmslocation="${servercfgdir}/UTWeb.ini"
elif [ "${shortname}" == "kf2" ]; then
@ -559,8 +566,7 @@ fn_info_message_ports(){
done
# engines/games that require editing the parms.
local ports_edit_array=( "Avorion" "goldsrc" "Factorio" "Hurtworld" "iw3.0" "ioquake3" "qfusion" "Rust" "Soldat" "spark" "source" "starbound" "unreal4" "realvirtuality" "Unturned" )
for port_edit in "${ports_edit_array[@]}"
do
for port_edit in "${ports_edit_array[@]}"; do
if [ "${engine}" == "${port_edit}" ]||[ "${gamename}" == "${port_edit}" ]||[ "${shortname}" == "${port_edit}" ]; then
parmslocation="${configdirserver}"
fi
@ -757,7 +763,7 @@ fn_info_message_dst(){
}
fn_info_message_eco(){
echo -e "netstat -atunp | grep mono"
echo -e "netstat -atunp | grep EcoServer"
echo -e ""
{
echo -e "${lightblue}DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL${default}"

3
linuxgsm.sh

@ -82,8 +82,7 @@ fn_bootstrap_fetch_file(){
remote_fileurls_array=( remote_fileurl )
fi
for remote_fileurl_array in "${remote_fileurls_array[@]}"
do
for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
fileurl="${remote_fileurl}"
fileurl_name="${remote_fileurl_name}"

3
tests/tests_fctrserver.sh

@ -89,8 +89,7 @@ fn_bootstrap_fetch_file(){
remote_fileurls_array=( remote_fileurl )
fi
for remote_fileurl_array in "${remote_fileurls_array[@]}"
do
for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
fileurl="${remote_fileurl}"
fileurl_name="${remote_fileurl_name}"

3
tests/tests_jc2server.sh

@ -90,8 +90,7 @@ fn_bootstrap_fetch_file(){
remote_fileurls_array=( remote_fileurl )
fi
for remote_fileurl_array in "${remote_fileurls_array[@]}"
do
for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
fileurl="${remote_fileurl}"
fileurl_name="${remote_fileurl_name}"

3
tests/tests_mcserver.sh

@ -90,8 +90,7 @@ fn_bootstrap_fetch_file(){
remote_fileurls_array=( remote_fileurl )
fi
for remote_fileurl_array in "${remote_fileurls_array[@]}"
do
for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
fileurl="${remote_fileurl}"
fileurl_name="${remote_fileurl_name}"

3
tests/tests_ts3server.sh

@ -90,8 +90,7 @@ fn_bootstrap_fetch_file(){
remote_fileurls_array=( remote_fileurl )
fi
for remote_fileurl_array in "${remote_fileurls_array[@]}"
do
for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
fileurl="${remote_fileurl}"
fileurl_name="${remote_fileurl_name}"

Loading…
Cancel
Save