diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh
index c77b27aee..e296c33de 100644
--- a/lgsm/functions/check_deps.sh
+++ b/lgsm/functions/check_deps.sh
@@ -149,7 +149,7 @@ if [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
# All servers except ts3 require tmux
if [ "${gamename}" != "TeamSpeak 3" ]; then
- if [ "$(command -v tmux 2>/dev/null)" ]||[ "$(which tmux 2>/dev/null)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then
+ if [ "$(command -v tmux 2>/dev/null)" ]; then
tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
else
array_deps_required+=( tmux )
@@ -246,7 +246,7 @@ elif [ -n "$(command -v yum 2>/dev/null)" ]; then
# All servers except ts3 require tmux
if [ "${gamename}" != "TeamSpeak 3" ]; then
- if [ "$(command -v tmux 2>/dev/null)" ]||[ "$(which tmux 2>/dev/null)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then
+ if [ "$(command -v tmux 2>/dev/null)" ]; then
tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
else
array_deps_required+=( tmux )
diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh
index 2690eb7c5..3a99b009b 100644
--- a/lgsm/functions/check_glibc.sh
+++ b/lgsm/functions/check_glibc.sh
@@ -17,7 +17,7 @@ elif [ "${glibcrequired}" == "UNKNOWN" ]; then
fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}"
echo -e " * glibc required: ${red}${glibcrequired}${default}"
echo -e " * glibc installed: ${glibcversion}"
-elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
+elif [ "$(printf "%s\n'${glibcrequired}'\n" "${glibcversion}" | sort -V | head -n 1)" != "${glibcrequired}" ]; then
if [ "${glibcfix}" == "yes" ]; then
if [ "${function_selfname}" != "command_install.sh" ]; then
fn_print_dots "Glibc fix"
diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh
index 35434c8cd..a58782515 100644
--- a/lgsm/functions/check_root.sh
+++ b/lgsm/functions/check_root.sh
@@ -7,7 +7,7 @@
local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-if [ $(whoami) = "root" ]; then
+if [ "$(whoami)" = "root" ]; then
fn_print_fail_nl "Do NOT run this script as root!"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "${selfname} attempted to run as root."
diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh
index 0b88b06b5..8999b2f93 100644
--- a/lgsm/functions/command_dev_detect_deps.sh
+++ b/lgsm/functions/command_dev_detect_deps.sh
@@ -20,7 +20,7 @@ elif [ "$(command -v readelf 2>/dev/null)" ]; then
else
echo "readelf/eu-readelf not installed"
fi
-files=$(find ${serverfiles} | wc -l)
+files=$(find "${serverfiles}" | wc -l)
find "${serverfiles}" -type f -print0 |
while IFS= read -r -d $'\0' line; do
if [ "${readelf}" == "eu-readelf" ]; then
@@ -34,7 +34,7 @@ done
sort "${tmpdir}/.depdetect_readelf" |uniq >"${tmpdir}/.depdetect_readelf_uniq"
-while read lib; do
+while read -r lib; do
if [ "${lib}" == "libm.so.6" ]||[ "${lib}" == "libc.so.6" ]||[ "${lib}" == "libtcmalloc_minimal.so.4" ]||[ "${lib}" == "libpthread.so.0" ]||[ "${lib}" == "libdl.so.2" ]||[ "${lib}" == "libnsl.so.1" ]||[ "${lib}" == "libgcc_s.so.1" ]||[ "${lib}" == "librt.so.1" ]||[ "${lib}" == "ld-linux.so.2" ]; then
echo "glibc.i686" >> "${tmpdir}/.depdetect_centos_list"
echo "lib32gcc1" >> "${tmpdir}/.depdetect_ubuntu_list"
diff --git a/lgsm/functions/command_dev_detect_glibc.sh b/lgsm/functions/command_dev_detect_glibc.sh
index 755a68f82..38018ef27 100644
--- a/lgsm/functions/command_dev_detect_glibc.sh
+++ b/lgsm/functions/command_dev_detect_glibc.sh
@@ -28,8 +28,8 @@ elif [ -f "${serverfiles}" ]; then
fi
echo ""
-files=$(find ${serverfiles} | wc -l)
-find ${serverfiles} -type f -print0 |
+files=$(find "${serverfiles}" | wc -l)
+find "${serverfiles}" -type f -print0 |
while IFS= read -r -d $'\0' line; do
glibcversion=$(objdump -T "${line}" 2>/dev/null|grep -oP "GLIBC[^ ]+" |grep -v GLIBCXX|sort|uniq|sort -r --version-sort| head -n 1)
if [ "${glibcversion}" ]; then
diff --git a/lgsm/functions/command_dev_detect_ldd.sh b/lgsm/functions/command_dev_detect_ldd.sh
index 4e27eb361..b4758cdb8 100644
--- a/lgsm/functions/command_dev_detect_ldd.sh
+++ b/lgsm/functions/command_dev_detect_ldd.sh
@@ -26,11 +26,11 @@ files=$(find "${serverfiles}" | wc -l)
find "${serverfiles}" -type f -print0 |
while IFS= read -r -d $'\0' line; do
#ldd -v $line 2>/dev/null|grep "=>" >>"${tmpdir}/detect_ldd.tmp"
- if [ -n "$(ldd ${line} 2>/dev/null |grep -v "not a dynamic executable")" ]; then
+ if [ -n "$(ldd "${line}" 2>/dev/null |grep -v "not a dynamic executable")" ]; then
echo "${line}" >> "${tmpdir}/detect_ldd.tmp"
ldd "${line}" 2>/dev/null |grep -v "not a dynamic executable" >> "${tmpdir}/detect_ldd.tmp"
- if [ -n "$(ldd $line 2>/dev/null |grep -v "not a dynamic executable"|grep "not found")" ]; then
+ if [ -n "$(ldd "${line}" 2>/dev/null |grep -v "not a dynamic executable"|grep "not found")" ]; then
echo "${line}" >> "${tmpdir}/detect_ldd_not_found.tmp"
ldd "${line}" 2>/dev/null |grep -v "not a dynamic executable"|grep "not found" >> "${tmpdir}/detect_ldd_not_found.tmp"
fi
diff --git a/lgsm/functions/command_mods_remove.sh b/lgsm/functions/command_mods_remove.sh
index 79b582a7e..b2700b683 100644
--- a/lgsm/functions/command_mods_remove.sh
+++ b/lgsm/functions/command_mods_remove.sh
@@ -68,7 +68,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
# If file or directory exists, then remove it
if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then
- rm -rf "${modinstalldir}/${currentfileremove}"
+ rm -rf "${modinstalldir:?}/${currentfileremove}"
((exitcode=$?))
if [ ${exitcode} -ne 0 ]; then
fn_script_log_fatal "Removing ${modinstalldir}/${currentfileremove}"
@@ -78,7 +78,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
fi
fi
tput rc; tput el
- printf "removing ${modprettyname} ${modfileline} / ${modsfilelistsize} : ${currentfileremove}..."
+ echo "removing ${modprettyname} ${modfileline} / ${modsfilelistsize} : ${currentfileremove}..."
((modfileline++))
done
if [ ${exitcode} -ne 0 ]; then
diff --git a/lgsm/functions/command_mods_update.sh b/lgsm/functions/command_mods_update.sh
index c339efb00..a2274277d 100644
--- a/lgsm/functions/command_mods_update.sh
+++ b/lgsm/functions/command_mods_update.sh
@@ -27,7 +27,7 @@ fn_remove_cfg_files(){
echo -e " * serverfiles/${filetopreserve}"
# If it matches an existing file that have been extracted delete the file
if [ -f "${extractdir}/${filetopreserve}" ]||[ -d "${extractdir}/${filetopreserve}" ]; then
- rm -r "${extractdir}/${filetopreserve}"
+ rm -r "${extractdir:?}/${filetopreserve}"
# Write the file path in a tmp file, to rebuild a full file list as it is rebuilt upon update
if [ ! -f "${modsdir}/.removedfiles.tmp" ]; then
touch "${modsdir}/.removedfiles.tmp"
@@ -72,7 +72,7 @@ sleep 1
# List all installed mods and apply update
# Reset line value
installedmodsline="1"
-while [ ${installedmodsline} -le ${installedmodscount} ]; do
+while [ "${installedmodsline}" -le "${installedmodscount}" ]; do
currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")"
if [ -n "${currentmod}" ]; then
fn_mod_get_info
diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh
index e54a6f80e..4740f2f92 100644
--- a/lgsm/functions/command_stop.sh
+++ b/lgsm/functions/command_stop.sh
@@ -118,7 +118,7 @@ fn_stop_graceful_sdtd(){
sleep 1
if [ "${telnetenabled}" == "false" ]; then
fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
- elif [ "$(command -v expect 2>/dev/null)" ]||[ "$(which expect >/dev/null 2>&1)" ]; then
+ elif [ "$(command -v expect 2>/dev/null)" ]; then
# Tries to shutdown with both localhost and server IP.
for telnetip in 127.0.0.1 ${ip}; do
fn_print_dots "Graceful: telnet: ${telnetip}"
@@ -219,14 +219,14 @@ fn_stop_ark(){
if [ "${#queryport}" -gt 0 ] ; then
for (( pidcheck=0 ; pidcheck < ${maxpiditer} ; pidcheck++ )) ; do
pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\
- grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\
+ grep ":${queryport}[[:space:]]" | rev | awk '{print $1}' |\
rev | cut -d\/ -f1)
#
# check for a valid pid
pid=${pid//[!0-9]/}
let pid+=0 # turns an empty string into a valid number, '0',
# and a valid numeric pid remains unchanged.
- if [ "${pid}" -gt 1 ]&&[ "${pid}" -le $(cat /proc/sys/kernel/pid_max) ]; then
+ if [ "${pid}" -gt 1 ]&&[ "${pid}" -le "$(cat "/proc/sys/kernel/pid_max")" ]; then
fn_print_dots "Process still bound. Awaiting graceful exit: ${pidcheck}"
sleep 1
else
diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh
index ccf619b6b..05acf0f6b 100644
--- a/lgsm/functions/command_ts3_server_pass.sh
+++ b/lgsm/functions/command_ts3_server_pass.sh
@@ -19,7 +19,7 @@ fn_serveradmin_password_prompt(){
echo Exiting; exit
fi
fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
- read -p "Enter new password : " newpassword
+ read -rp "Enter new password : " newpassword
}
fn_serveradmin_password_set(){
diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh
index 8ae6a08ae..a9cfc2721 100644
--- a/lgsm/functions/command_validate.sh
+++ b/lgsm/functions/command_validate.sh
@@ -22,7 +22,7 @@ fn_validation(){
cd "${steamcmddir}"
# Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh
- if [ $(command -v stdbuf) ]&&[ "${arch}" != "x86_64" ]; then
+ if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
unbuffer="stdbuf -i0 -o0 -e0"
fi
diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh
index bda9490cc..856bc5086 100644
--- a/lgsm/functions/compress_unreal2_maps.sh
+++ b/lgsm/functions/compress_unreal2_maps.sh
@@ -22,7 +22,7 @@ if ! fn_prompt_yn "Start compression?" Y; then
fi
mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1
rm -rfv "${serverfiles}/Maps/"*.ut2.uz2
-cd "${systemdir}"
+cd "${systemdir}" || exit
for map in "${serverfiles}/Maps/"*; do
./ucc-bin compress "${map}" --nohomedir
done
diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh
index a45ced4a3..359a4c8a6 100644
--- a/lgsm/functions/core_dl.sh
+++ b/lgsm/functions/core_dl.sh
@@ -238,15 +238,9 @@ fn_update_function(){
}
# Defines curl path
-curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
-for curlpath in "${curl_paths_array}"
-do
- if [ -x "${curlpath}" ]; then
- break
- fi
-done
+curlpath=$(command -v curl 2>/dev/null)
-if [ "$(basename ${curlpath})" != "curl" ]; then
+if [ "$(basename "${curlpath}")" != "curl" ]; then
echo "[ FAIL ] Curl is not installed"
exit 1
fi
\ No newline at end of file
diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh
index 3ce4600da..58860d857 100644
--- a/lgsm/functions/core_exit.sh
+++ b/lgsm/functions/core_exit.sh
@@ -26,12 +26,12 @@ elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then
fn_exit_dev_debug
# remove trap.
trap - INT
- exit ${exitcode}
+ exit "${exitcode}"
else
exitcode=0
fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}"
fn_exit_dev_debug
# remove trap.
trap - INT
- exit ${exitcode}
+ exit "${exitcode}"
fi
diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh
index 126cc8925..5a4907e08 100644
--- a/lgsm/functions/info_distro.sh
+++ b/lgsm/functions/info_distro.sh
@@ -124,7 +124,7 @@ if [ -d "${backupdir}" ]; then
# number of backups.
backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
# most recent backup.
- lastbackup=$(ls -t "${backupdir}"/*.tar.gz | head -1)
+ lastbackup=$(find "${backupdir}"/*.tar.gz | head -1)
# date of most recent backup.
lastbackupdate=$(date -r "${lastbackup}")
# no of days since last backup.
diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh
index 0fb611253..190afbcd3 100644
--- a/lgsm/functions/install_config.sh
+++ b/lgsm/functions/install_config.sh
@@ -61,8 +61,7 @@ fn_set_config_vars(){
echo "changing hostname."
fn_script_log_info "changing hostname."
sleep 1
-
- if [ $(grep SERVERNAME=SERVERNAME \"${lgsmdir}/config-default/config-game/${config}\" 2>/dev/null) ]; then
+ if grep -q "SERVERNAME=SERVERNAME" "${lgsmdir}/config-default/config-game/${config}" 2>/dev/null; then
sed -i "s/SERVERNAME=SERVERNAME/SERVERNAME=${servername}/g" "${servercfgfullpath}"
else
sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}"
diff --git a/lgsm/functions/install_dst_token.sh b/lgsm/functions/install_dst_token.sh
index f7bd27138..c319088d1 100644
--- a/lgsm/functions/install_dst_token.sh
+++ b/lgsm/functions/install_dst_token.sh
@@ -30,7 +30,7 @@ if [ -z "${autoinstall}" ]; then
if [ "${overwritetoken}" == "true" ]; then
echo "Once you have the cluster token, enter it below"
echo -n "Cluster Token: "
- read token
+ read -r token
mkdir -pv "${clustercfgdir}"
echo "${token}" > "${clustercfgdir}/cluster_token.txt"
if [ -f "${clustercfgdir}/cluster_token.txt" ]; then
diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh
index bebb3c3ed..9ff176521 100644
--- a/lgsm/functions/install_gslt.sh
+++ b/lgsm/functions/install_gslt.sh
@@ -29,7 +29,7 @@ if [ -z "${autoinstall}" ]; then
if [ "${gamename}" != "Tower Unite" ]; then
echo "Enter token below (Can be blank)."
echo -n "GSLT TOKEN: "
- read token
+ read -r token
if ! grep -q "^gslt=" "${configdirserver}/${servicename}.cfg" > /dev/null 2>&1; then
echo -e "\ngslt=\"${token}\"" >> "${configdirserver}/${servicename}.cfg"
else
diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh
index 1509c8f62..7cfc3205f 100644
--- a/lgsm/functions/install_ts3db.sh
+++ b/lgsm/functions/install_ts3db.sh
@@ -14,7 +14,7 @@ fn_install_ts3db_mariadb(){
echo "checking if libmariadb2 is installed"
echo "================================="
sleep 1
- ldd ${serverfiles}/libts3db_mariadb.so | grep "libmariadb.so.2 => not found"
+ ldd "${serverfiles}/libts3db_mariadb.so" | grep "libmariadb.so.2 => not found"
if [ $? -eq 0 ]; then
echo "libmariadb2 not installed. Please install it first."
echo "exiting..."
@@ -26,19 +26,21 @@ fn_install_ts3db_mariadb(){
echo "Configuring ${gamename} Server for MariaDB/MySQL"
echo "================================="
sleep 1
- read -p "Enter MariaDB hostname: " mariahostname
- read -p "Enter MariaDB port: " mariaport
- read -p "Enter MariaDB username: " mariausername
- read -p "Enter MariaDB password: " mariapassword
- read -p "Enter MariaDB database name: " mariadbname
+ read -rp "Enter MariaDB hostname: " mariahostname
+ read -rp "Enter MariaDB port: " mariaport
+ read -rp "Enter MariaDB username: " mariausername
+ read -rp "Enter MariaDB password: " mariapassword
+ read -rp "Enter MariaDB database name: " mariadbname
+ {
echo "updating config."
- echo "[config]" >> ${servercfgdir}/ts3db_mariadb.ini
- echo "host='${mariahostname}'" >> ${servercfgdir}/ts3db_mariadb.ini
- echo "port='${mariaport}'" >> ${servercfgdir}/ts3db_mariadb.ini
- echo "username='${mariausername}'" >> ${servercfgdir}/ts3db_mariadb.ini
- echo "password='${mariapassword}'" >> ${servercfgdir}/ts3db_mariadb.ini
- echo "database='${mariadbname}'" >> ${servercfgdir}/ts3db_mariadb.ini
- echo "socket=" >> ${servercfgdir}/ts3db_mariadb.ini
+ echo "[config]"
+ echo "host='${mariahostname}'"
+ echo "port='${mariaport}'"
+ echo "username='${mariausername}'"
+ echo "password='${mariapassword}'"
+ echo "database='${mariadbname}'"
+ echo "socket="
+ } >> "${servercfgdir}/ts3db_mariadb.ini"
sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}"
sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}"
sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}"
@@ -69,7 +71,7 @@ echo "================================="
sleep 1
echo "IMPORANT! Save these details for later."
sleep 1
-cd "${executabledir}"
+cd "${executabledir}" || exit
./ts3server_startscript.sh start inifile=ts3-server.ini
sleep 5
./ts3server_startscript.sh stop
diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh
index 106f64825..7abe2ea2b 100644
--- a/lgsm/functions/logs.sh
+++ b/lgsm/functions/logs.sh
@@ -42,8 +42,8 @@ if [ $(find "${lgsmlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; then
scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0"
sleep 1
fn_print_ok_nl "Starting"
- fn_print_info_nl "Removing logs older than "${logdays}" days"
- fn_script_log_info "Removing logs older than "${logdays}" days"
+ fn_print_info_nl "Removing logs older than ${logdays} days"
+ fn_script_log_info "Removing logs older than ${logdays} days"
# Logging logfiles to be removed according to "${logdays}", counting and removing them
# Script logfiles
find "${lgsmlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${lgsmlog}"
diff --git a/lgsm/functions/mods_core.sh b/lgsm/functions/mods_core.sh
index e6b0ad43c..c53ad7c96 100644
--- a/lgsm/functions/mods_core.sh
+++ b/lgsm/functions/mods_core.sh
@@ -43,7 +43,7 @@ fn_mod_lowercase(){
fileswc=$(find "${extractdir}" -depth | wc -l)
echo -en "\r"
while read -r src; do
- dst=`dirname "${src}"`/`basename "${src}" | tr '[A-Z]' '[a-z]'`
+ dst=$(dirname "${src}"`/`basename "${src}" | tr '[A-Z]' '[a-z]')
if [ "${src}" != "${dst}" ]
then
[ ! -e "${dst}" ] && mv -T "${src}" "${dst}" || echo "${src} was not renamed"
@@ -219,7 +219,7 @@ fn_mods_installed_list(){
moddescriptionmaxlength="0"
modcommandmaxlength="0"
# Loop through every line of the installed mods list ${modsinstalledlistfullpath}
- while [ ${installedmodsline} -le ${installedmodscount} ]; do
+ while [ "${installedmodsline}" -le "${installedmodscount}" ]; do
currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")"
# Get mod info to make sure mod exists
fn_mod_get_info
diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh
index cb23e5264..bbb5163e8 100644
--- a/lgsm/functions/update_minecraft.sh
+++ b/lgsm/functions/update_minecraft.sh
@@ -47,7 +47,7 @@ fn_update_currentbuild(){
fi
# Get current build from logs
- currentbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
+ currentbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: mojang.com: Current build version not found"
fn_script_log_error "Checking for update: mojang.com: Current build version not found"
@@ -58,7 +58,7 @@ fn_update_currentbuild(){
command_stop.sh
exitbypass=1
command_start.sh
- currentbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
+ currentbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: mojang.com: Current build version still not found"
fn_script_log_fatal "Checking for update: mojang.com: Current build version still not found"
diff --git a/lgsm/functions/update_mumble.sh b/lgsm/functions/update_mumble.sh
index 8ae59a52b..f104451b3 100644
--- a/lgsm/functions/update_mumble.sh
+++ b/lgsm/functions/update_mumble.sh
@@ -49,7 +49,7 @@ fn_update_mumble_currentbuild(){
fi
# Get current build from logs
- currentbuild=$(cat "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null | sort | egrep 'Murmur ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | awk '{print $4}')
+ currentbuild=$(cat "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null | sort | grep -E 'Murmur ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | awk '{print $4}')
if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: GitHub: Current build version not found"
fn_script_log_error "Checking for update: GitHub: Current build version not found"
@@ -60,7 +60,7 @@ fn_update_mumble_currentbuild(){
command_stop.sh
exitbypass=1
command_start.sh
- currentbuild=$(cat "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null | sort | egrep 'Murmur ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | awk '{print $4}')
+ currentbuild=$(cat "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null | sort | grep -E 'Murmur ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | awk '{print $4}')
if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: GitHub: Current build version still not found"
fn_script_log_fatal "Checking for update: GitHub: Current build version still not found"
diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh
index 8bc3fa144..1b0663df0 100644
--- a/lgsm/functions/update_steamcmd.sh
+++ b/lgsm/functions/update_steamcmd.sh
@@ -17,7 +17,7 @@ fn_update_steamcmd_dl(){
fn_print_ok_nl "SteamCMD"
fn_script_log_info "Starting SteamCMD"
- cd "${steamcmddir}"
+ cd "${steamcmddir}" || exit
# Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh
@@ -157,7 +157,7 @@ fn_update_steamcmd_check(){
fi
# Set branch for updateinfo
- IFS=' ' read -a branchsplits <<< "${branch}"
+ IFS=' ' read -ra branchsplits <<< "${branch}"
if [ "${#branchsplits[@]}" -gt 1 ]; then
branchname="${branchsplits[1]}"
else
@@ -165,7 +165,7 @@ fn_update_steamcmd_check(){
fi
# Gets availablebuild info
- cd "${steamcmddir}"
+ cd "${steamcmddir}" || exit
availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | sed -n '/branch/,$p' | grep -m 1 buildid | tr -cd '[:digit:]')
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: SteamCMD"
diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh
index 8b4cf7be0..dc41c5053 100644
--- a/lgsm/functions/update_ts3.sh
+++ b/lgsm/functions/update_ts3.sh
@@ -48,7 +48,7 @@ fn_update_ts3_currentbuild(){
fi
# Get current build from logs
- currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | sort -V | tail -1)
+ currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | grep -Ev '${rootdir}/.ts3version' | tail -1) | grep -Eo 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | sort -V | tail -1)
if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: teamspeak.com: Current build version not found"
fn_script_log_error "Checking for update: teamspeak.com: Current build version not found"
@@ -59,7 +59,7 @@ fn_update_ts3_currentbuild(){
command_stop.sh
exitbypass=1
command_start.sh
- currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
+ currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | grep -Ev '${rootdir}/.ts3version' | tail -1) | grep -Eo 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: teamspeak.com: Current build version still not found"
fn_script_log_fatal "Checking for update: teamspeak.com: Current build version still not found"
@@ -112,13 +112,13 @@ fn_update_ts3_availablebuild_legacy(){
# Gets latest build info.
# Grabs all version numbers but not in correct order.
- wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${tmpdir}/.ts3_version_numbers_unsorted.tmp"
+ wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | grep -Eo '.*\/<\/a>' | grep -Eo '[0-9\.?]+'|uniq > "${tmpdir}/.ts3_version_numbers_unsorted.tmp"
# Sort version numbers
cat "${tmpdir}/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${tmpdir}/.ts3_version_numbers_sorted.tmp"
# Finds directory with most recent server version.
- while read ts3_version_number; do
+ while read -r ts3_version_number; do
wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
if [ $? -eq 0 ]; then
availablebuild="${ts3_version_number}"
@@ -206,7 +206,7 @@ fn_update_ts3_compare(){
fn_update_ts3_arch
if [ "${installer}" == "1" ]; then
# if jq available uses json update checker
- if [ "$(command -v jq)" ]||[ "$(which jq >/dev/null 2>&1)" ]; then
+ if [ "$(command -v jq >/dev/null 2>&1)" ]; then
fn_update_ts3_availablebuild
else
fn_update_ts3_availablebuild_legacy
diff --git a/linuxgsm.sh b/linuxgsm.sh
index 95d38c8b8..17b8cf74e 100755
--- a/linuxgsm.sh
+++ b/linuxgsm.sh
@@ -70,13 +70,8 @@ fn_bootstrap_fetch_file(){
mkdir -p "${local_filedir}"
fi
# Defines curl path
- curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
- for curlpath in "${curl_paths_array}"
- do
- if [ -x "${curlpath}" ]; then
- break
- fi
- done
+ curlpath=$(command -v curl 2>/dev/null)
+
# If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then
# trap to remove part downloaded files
@@ -198,8 +193,8 @@ fn_install_menu() {
options=$4
# Get menu command
for menucmd in whiptail dialog bash; do
- if [ -x $(which ${menucmd}) ]; then
- menucmd=$(which ${menucmd})
+ if [ -x $(command -v ${menucmd}) ]; then
+ menucmd=$(command -v ${menucmd})
break
fi
done
diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh
index fe4f8e06d..9517cc9ac 100644
--- a/tests/tests_jc2server.sh
+++ b/tests/tests_jc2server.sh
@@ -65,13 +65,8 @@ fn_bootstrap_fetch_file(){
mkdir -p "${local_filedir}"
fi
# Defines curl path
- curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
- for curlpath in "${curl_paths_array}"
- do
- if [ -x "${curlpath}" ]; then
- break
- fi
- done
+ curlpath=$(command -v curl 2>/dev/null)
+
# If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then
# trap to remove part downloaded files
@@ -193,8 +188,8 @@ fn_install_menu() {
options=$4
# Get menu command
for menucmd in whiptail dialog bash; do
- if [ -x $(which ${menucmd}) ]; then
- menucmd=$(which ${menucmd})
+ if [ -x $(command -v ${menucmd}) ]; then
+ menucmd=$(command -v ${menucmd})
break
fi
done
diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh
index b8f9bd7ce..2c93c27c4 100644
--- a/tests/tests_ts3server.sh
+++ b/tests/tests_ts3server.sh
@@ -65,13 +65,8 @@ fn_bootstrap_fetch_file(){
mkdir -p "${local_filedir}"
fi
# Defines curl path
- curl_paths_array=($(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)
- for curlpath in "${curl_paths_array}"
- do
- if [ -x "${curlpath}" ]; then
- break
- fi
- done
+ curlpath=$(command -v curl 2>/dev/null)
+
# If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then
# trap to remove part downloaded files
@@ -193,8 +188,8 @@ fn_install_menu() {
options=$4
# Get menu command
for menucmd in whiptail dialog bash; do
- if [ -x $(which ${menucmd}) ]; then
- menucmd=$(which ${menucmd})
+ if [ -x $(command -v ${menucmd}) ]; then
+ menucmd=$(command -v ${menucmd})
break
fi
done