Browse Source

Merge branch 'feature/codetidy' into develop

pull/1863/head
Daniel Gibbs 7 years ago
parent
commit
469733216b
  1. 4
      lgsm/functions/check_deps.sh
  2. 2
      lgsm/functions/check_glibc.sh
  3. 2
      lgsm/functions/check_root.sh
  4. 4
      lgsm/functions/command_dev_detect_deps.sh
  5. 4
      lgsm/functions/command_dev_detect_glibc.sh
  6. 4
      lgsm/functions/command_dev_detect_ldd.sh
  7. 4
      lgsm/functions/command_mods_remove.sh
  8. 4
      lgsm/functions/command_mods_update.sh
  9. 6
      lgsm/functions/command_stop.sh
  10. 2
      lgsm/functions/command_ts3_server_pass.sh
  11. 2
      lgsm/functions/command_validate.sh
  12. 2
      lgsm/functions/compress_unreal2_maps.sh
  13. 10
      lgsm/functions/core_dl.sh
  14. 4
      lgsm/functions/core_exit.sh
  15. 2
      lgsm/functions/info_distro.sh
  16. 3
      lgsm/functions/install_config.sh
  17. 2
      lgsm/functions/install_dst_token.sh
  18. 2
      lgsm/functions/install_gslt.sh
  19. 30
      lgsm/functions/install_ts3db.sh
  20. 4
      lgsm/functions/logs.sh
  21. 4
      lgsm/functions/mods_core.sh
  22. 4
      lgsm/functions/update_minecraft.sh
  23. 4
      lgsm/functions/update_mumble.sh
  24. 6
      lgsm/functions/update_steamcmd.sh
  25. 10
      lgsm/functions/update_ts3.sh
  26. 13
      linuxgsm.sh
  27. 13
      tests/tests_jc2server.sh
  28. 13
      tests/tests_ts3server.sh

4
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 # All servers except ts3 require tmux
if [ "${gamename}" != "TeamSpeak 3" ]; then 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. tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
else else
array_deps_required+=( tmux ) array_deps_required+=( tmux )
@ -246,7 +246,7 @@ elif [ -n "$(command -v yum 2>/dev/null)" ]; then
# All servers except ts3 require tmux # All servers except ts3 require tmux
if [ "${gamename}" != "TeamSpeak 3" ]; then 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. tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
else else
array_deps_required+=( tmux ) array_deps_required+=( tmux )

2
lgsm/functions/check_glibc.sh

@ -17,7 +17,7 @@ elif [ "${glibcrequired}" == "UNKNOWN" ]; then
fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}" fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}"
echo -e " * glibc required: ${red}${glibcrequired}${default}" echo -e " * glibc required: ${red}${glibcrequired}${default}"
echo -e " * glibc installed: ${glibcversion}" 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 [ "${glibcfix}" == "yes" ]; then
if [ "${function_selfname}" != "command_install.sh" ]; then if [ "${function_selfname}" != "command_install.sh" ]; then
fn_print_dots "Glibc fix" fn_print_dots "Glibc fix"

2
lgsm/functions/check_root.sh

@ -7,7 +7,7 @@
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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!" fn_print_fail_nl "Do NOT run this script as root!"
if [ -d "${lgsmlogdir}" ]; then if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "${selfname} attempted to run as root." fn_script_log_fatal "${selfname} attempted to run as root."

4
lgsm/functions/command_dev_detect_deps.sh

@ -20,7 +20,7 @@ elif [ "$(command -v readelf 2>/dev/null)" ]; then
else else
echo "readelf/eu-readelf not installed" echo "readelf/eu-readelf not installed"
fi fi
files=$(find ${serverfiles} | wc -l) files=$(find "${serverfiles}" | wc -l)
find "${serverfiles}" -type f -print0 | find "${serverfiles}" -type f -print0 |
while IFS= read -r -d $'\0' line; do while IFS= read -r -d $'\0' line; do
if [ "${readelf}" == "eu-readelf" ]; then if [ "${readelf}" == "eu-readelf" ]; then
@ -34,7 +34,7 @@ done
sort "${tmpdir}/.depdetect_readelf" |uniq >"${tmpdir}/.depdetect_readelf_uniq" 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 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 "glibc.i686" >> "${tmpdir}/.depdetect_centos_list"
echo "lib32gcc1" >> "${tmpdir}/.depdetect_ubuntu_list" echo "lib32gcc1" >> "${tmpdir}/.depdetect_ubuntu_list"

4
lgsm/functions/command_dev_detect_glibc.sh

@ -28,8 +28,8 @@ elif [ -f "${serverfiles}" ]; then
fi fi
echo "" echo ""
files=$(find ${serverfiles} | wc -l) files=$(find "${serverfiles}" | wc -l)
find ${serverfiles} -type f -print0 | find "${serverfiles}" -type f -print0 |
while IFS= read -r -d $'\0' line; do 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) 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 if [ "${glibcversion}" ]; then

4
lgsm/functions/command_dev_detect_ldd.sh

@ -26,11 +26,11 @@ files=$(find "${serverfiles}" | wc -l)
find "${serverfiles}" -type f -print0 | find "${serverfiles}" -type f -print0 |
while IFS= read -r -d $'\0' line; do while IFS= read -r -d $'\0' line; do
#ldd -v $line 2>/dev/null|grep "=>" >>"${tmpdir}/detect_ldd.tmp" #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" echo "${line}" >> "${tmpdir}/detect_ldd.tmp"
ldd "${line}" 2>/dev/null |grep -v "not a dynamic executable" >> "${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" 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" ldd "${line}" 2>/dev/null |grep -v "not a dynamic executable"|grep "not found" >> "${tmpdir}/detect_ldd_not_found.tmp"
fi fi

4
lgsm/functions/command_mods_remove.sh

@ -68,7 +68,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
# If file or directory exists, then remove it # If file or directory exists, then remove it
if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then
rm -rf "${modinstalldir}/${currentfileremove}" rm -rf "${modinstalldir:?}/${currentfileremove}"
((exitcode=$?)) ((exitcode=$?))
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
fn_script_log_fatal "Removing ${modinstalldir}/${currentfileremove}" fn_script_log_fatal "Removing ${modinstalldir}/${currentfileremove}"
@ -78,7 +78,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
fi fi
fi fi
tput rc; tput el tput rc; tput el
printf "removing ${modprettyname} ${modfileline} / ${modsfilelistsize} : ${currentfileremove}..." echo "removing ${modprettyname} ${modfileline} / ${modsfilelistsize} : ${currentfileremove}..."
((modfileline++)) ((modfileline++))
done done
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then

4
lgsm/functions/command_mods_update.sh

@ -27,7 +27,7 @@ fn_remove_cfg_files(){
echo -e " * serverfiles/${filetopreserve}" echo -e " * serverfiles/${filetopreserve}"
# If it matches an existing file that have been extracted delete the file # If it matches an existing file that have been extracted delete the file
if [ -f "${extractdir}/${filetopreserve}" ]||[ -d "${extractdir}/${filetopreserve}" ]; then 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 # 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 if [ ! -f "${modsdir}/.removedfiles.tmp" ]; then
touch "${modsdir}/.removedfiles.tmp" touch "${modsdir}/.removedfiles.tmp"
@ -72,7 +72,7 @@ sleep 1
# List all installed mods and apply update # List all installed mods and apply update
# Reset line value # Reset line value
installedmodsline="1" installedmodsline="1"
while [ ${installedmodsline} -le ${installedmodscount} ]; do while [ "${installedmodsline}" -le "${installedmodscount}" ]; do
currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")" currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")"
if [ -n "${currentmod}" ]; then if [ -n "${currentmod}" ]; then
fn_mod_get_info fn_mod_get_info

6
lgsm/functions/command_stop.sh

@ -118,7 +118,7 @@ fn_stop_graceful_sdtd(){
sleep 1 sleep 1
if [ "${telnetenabled}" == "false" ]; then if [ "${telnetenabled}" == "false" ]; then
fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}" 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. # Tries to shutdown with both localhost and server IP.
for telnetip in 127.0.0.1 ${ip}; do for telnetip in 127.0.0.1 ${ip}; do
fn_print_dots "Graceful: telnet: ${telnetip}" fn_print_dots "Graceful: telnet: ${telnetip}"
@ -219,14 +219,14 @@ fn_stop_ark(){
if [ "${#queryport}" -gt 0 ] ; then if [ "${#queryport}" -gt 0 ] ; then
for (( pidcheck=0 ; pidcheck < ${maxpiditer} ; pidcheck++ )) ; do for (( pidcheck=0 ; pidcheck < ${maxpiditer} ; pidcheck++ )) ; do
pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\ 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) rev | cut -d\/ -f1)
# #
# check for a valid pid # check for a valid pid
pid=${pid//[!0-9]/} pid=${pid//[!0-9]/}
let pid+=0 # turns an empty string into a valid number, '0', let pid+=0 # turns an empty string into a valid number, '0',
# and a valid numeric pid remains unchanged. # 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}" fn_print_dots "Process still bound. Awaiting graceful exit: ${pidcheck}"
sleep 1 sleep 1
else else

2
lgsm/functions/command_ts3_server_pass.sh

@ -19,7 +19,7 @@ fn_serveradmin_password_prompt(){
echo Exiting; exit echo Exiting; exit
fi fi
fn_script_log_info "Initiating ${gamename} ServerAdmin password change" 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(){ fn_serveradmin_password_set(){

2
lgsm/functions/command_validate.sh

@ -22,7 +22,7 @@ fn_validation(){
cd "${steamcmddir}" cd "${steamcmddir}"
# Detects if unbuffer command is available for 32 bit distributions only. # Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh info_distro.sh
if [ $(command -v stdbuf) ]&&[ "${arch}" != "x86_64" ]; then if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
unbuffer="stdbuf -i0 -o0 -e0" unbuffer="stdbuf -i0 -o0 -e0"
fi fi

2
lgsm/functions/compress_unreal2_maps.sh

@ -22,7 +22,7 @@ if ! fn_prompt_yn "Start compression?" Y; then
fi fi
mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1
rm -rfv "${serverfiles}/Maps/"*.ut2.uz2 rm -rfv "${serverfiles}/Maps/"*.ut2.uz2
cd "${systemdir}" cd "${systemdir}" || exit
for map in "${serverfiles}/Maps/"*; do for map in "${serverfiles}/Maps/"*; do
./ucc-bin compress "${map}" --nohomedir ./ucc-bin compress "${map}" --nohomedir
done done

10
lgsm/functions/core_dl.sh

@ -238,15 +238,9 @@ fn_update_function(){
} }
# Defines curl path # 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) curlpath=$(command -v curl 2>/dev/null)
for curlpath in "${curl_paths_array}"
do
if [ -x "${curlpath}" ]; then
break
fi
done
if [ "$(basename ${curlpath})" != "curl" ]; then if [ "$(basename "${curlpath}")" != "curl" ]; then
echo "[ FAIL ] Curl is not installed" echo "[ FAIL ] Curl is not installed"
exit 1 exit 1
fi fi

4
lgsm/functions/core_exit.sh

@ -26,12 +26,12 @@ elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then
fn_exit_dev_debug fn_exit_dev_debug
# remove trap. # remove trap.
trap - INT trap - INT
exit ${exitcode} exit "${exitcode}"
else else
exitcode=0 exitcode=0
fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}"
fn_exit_dev_debug fn_exit_dev_debug
# remove trap. # remove trap.
trap - INT trap - INT
exit ${exitcode} exit "${exitcode}"
fi fi

2
lgsm/functions/info_distro.sh

@ -124,7 +124,7 @@ if [ -d "${backupdir}" ]; then
# number of backups. # number of backups.
backupcount=$(find "${backupdir}"/*.tar.gz | wc -l) backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
# most recent backup. # most recent backup.
lastbackup=$(ls -t "${backupdir}"/*.tar.gz | head -1) lastbackup=$(find "${backupdir}"/*.tar.gz | head -1)
# date of most recent backup. # date of most recent backup.
lastbackupdate=$(date -r "${lastbackup}") lastbackupdate=$(date -r "${lastbackup}")
# no of days since last backup. # no of days since last backup.

3
lgsm/functions/install_config.sh

@ -61,8 +61,7 @@ fn_set_config_vars(){
echo "changing hostname." echo "changing hostname."
fn_script_log_info "changing hostname." fn_script_log_info "changing hostname."
sleep 1 sleep 1
if grep -q "SERVERNAME=SERVERNAME" "${lgsmdir}/config-default/config-game/${config}" 2>/dev/null; then
if [ $(grep SERVERNAME=SERVERNAME \"${lgsmdir}/config-default/config-game/${config}\" 2>/dev/null) ]; then
sed -i "s/SERVERNAME=SERVERNAME/SERVERNAME=${servername}/g" "${servercfgfullpath}" sed -i "s/SERVERNAME=SERVERNAME/SERVERNAME=${servername}/g" "${servercfgfullpath}"
else else
sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}" sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}"

2
lgsm/functions/install_dst_token.sh

@ -30,7 +30,7 @@ if [ -z "${autoinstall}" ]; then
if [ "${overwritetoken}" == "true" ]; then if [ "${overwritetoken}" == "true" ]; then
echo "Once you have the cluster token, enter it below" echo "Once you have the cluster token, enter it below"
echo -n "Cluster Token: " echo -n "Cluster Token: "
read token read -r token
mkdir -pv "${clustercfgdir}" mkdir -pv "${clustercfgdir}"
echo "${token}" > "${clustercfgdir}/cluster_token.txt" echo "${token}" > "${clustercfgdir}/cluster_token.txt"
if [ -f "${clustercfgdir}/cluster_token.txt" ]; then if [ -f "${clustercfgdir}/cluster_token.txt" ]; then

2
lgsm/functions/install_gslt.sh

@ -29,7 +29,7 @@ if [ -z "${autoinstall}" ]; then
if [ "${gamename}" != "Tower Unite" ]; then if [ "${gamename}" != "Tower Unite" ]; then
echo "Enter token below (Can be blank)." echo "Enter token below (Can be blank)."
echo -n "GSLT TOKEN: " echo -n "GSLT TOKEN: "
read token read -r token
if ! grep -q "^gslt=" "${configdirserver}/${servicename}.cfg" > /dev/null 2>&1; then if ! grep -q "^gslt=" "${configdirserver}/${servicename}.cfg" > /dev/null 2>&1; then
echo -e "\ngslt=\"${token}\"" >> "${configdirserver}/${servicename}.cfg" echo -e "\ngslt=\"${token}\"" >> "${configdirserver}/${servicename}.cfg"
else else

30
lgsm/functions/install_ts3db.sh

@ -14,7 +14,7 @@ fn_install_ts3db_mariadb(){
echo "checking if libmariadb2 is installed" echo "checking if libmariadb2 is installed"
echo "=================================" echo "================================="
sleep 1 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 if [ $? -eq 0 ]; then
echo "libmariadb2 not installed. Please install it first." echo "libmariadb2 not installed. Please install it first."
echo "exiting..." echo "exiting..."
@ -26,19 +26,21 @@ fn_install_ts3db_mariadb(){
echo "Configuring ${gamename} Server for MariaDB/MySQL" echo "Configuring ${gamename} Server for MariaDB/MySQL"
echo "=================================" echo "================================="
sleep 1 sleep 1
read -p "Enter MariaDB hostname: " mariahostname read -rp "Enter MariaDB hostname: " mariahostname
read -p "Enter MariaDB port: " mariaport read -rp "Enter MariaDB port: " mariaport
read -p "Enter MariaDB username: " mariausername read -rp "Enter MariaDB username: " mariausername
read -p "Enter MariaDB password: " mariapassword read -rp "Enter MariaDB password: " mariapassword
read -p "Enter MariaDB database name: " mariadbname read -rp "Enter MariaDB database name: " mariadbname
{
echo "updating config." echo "updating config."
echo "[config]" >> ${servercfgdir}/ts3db_mariadb.ini echo "[config]"
echo "host='${mariahostname}'" >> ${servercfgdir}/ts3db_mariadb.ini echo "host='${mariahostname}'"
echo "port='${mariaport}'" >> ${servercfgdir}/ts3db_mariadb.ini echo "port='${mariaport}'"
echo "username='${mariausername}'" >> ${servercfgdir}/ts3db_mariadb.ini echo "username='${mariausername}'"
echo "password='${mariapassword}'" >> ${servercfgdir}/ts3db_mariadb.ini echo "password='${mariapassword}'"
echo "database='${mariadbname}'" >> ${servercfgdir}/ts3db_mariadb.ini echo "database='${mariadbname}'"
echo "socket=" >> ${servercfgdir}/ts3db_mariadb.ini echo "socket="
} >> "${servercfgdir}/ts3db_mariadb.ini"
sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}" sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}"
sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}" sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}"
sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}" sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}"
@ -69,7 +71,7 @@ echo "================================="
sleep 1 sleep 1
echo "IMPORANT! Save these details for later." echo "IMPORANT! Save these details for later."
sleep 1 sleep 1
cd "${executabledir}" cd "${executabledir}" || exit
./ts3server_startscript.sh start inifile=ts3-server.ini ./ts3server_startscript.sh start inifile=ts3-server.ini
sleep 5 sleep 5
./ts3server_startscript.sh stop ./ts3server_startscript.sh stop

4
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" scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0"
sleep 1 sleep 1
fn_print_ok_nl "Starting" fn_print_ok_nl "Starting"
fn_print_info_nl "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" fn_script_log_info "Removing logs older than ${logdays} days"
# Logging logfiles to be removed according to "${logdays}", counting and removing them # Logging logfiles to be removed according to "${logdays}", counting and removing them
# Script logfiles # Script logfiles
find "${lgsmlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${lgsmlog}" find "${lgsmlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${lgsmlog}"

4
lgsm/functions/mods_core.sh

@ -43,7 +43,7 @@ fn_mod_lowercase(){
fileswc=$(find "${extractdir}" -depth | wc -l) fileswc=$(find "${extractdir}" -depth | wc -l)
echo -en "\r" echo -en "\r"
while read -r src; do 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}" ] if [ "${src}" != "${dst}" ]
then then
[ ! -e "${dst}" ] && mv -T "${src}" "${dst}" || echo "${src} was not renamed" [ ! -e "${dst}" ] && mv -T "${src}" "${dst}" || echo "${src} was not renamed"
@ -219,7 +219,7 @@ fn_mods_installed_list(){
moddescriptionmaxlength="0" moddescriptionmaxlength="0"
modcommandmaxlength="0" modcommandmaxlength="0"
# Loop through every line of the installed mods list ${modsinstalledlistfullpath} # 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}")" currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")"
# Get mod info to make sure mod exists # Get mod info to make sure mod exists
fn_mod_get_info fn_mod_get_info

4
lgsm/functions/update_minecraft.sh

@ -47,7 +47,7 @@ fn_update_currentbuild(){
fi fi
# Get current build from logs # 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 if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: mojang.com: Current build version not found" 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" fn_script_log_error "Checking for update: mojang.com: Current build version not found"
@ -58,7 +58,7 @@ fn_update_currentbuild(){
command_stop.sh command_stop.sh
exitbypass=1 exitbypass=1
command_start.sh 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 if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: mojang.com: Current build version still not found" 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" fn_script_log_fatal "Checking for update: mojang.com: Current build version still not found"

4
lgsm/functions/update_mumble.sh

@ -49,7 +49,7 @@ fn_update_mumble_currentbuild(){
fi fi
# Get current build from logs # 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 if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: GitHub: Current build version not found" 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" fn_script_log_error "Checking for update: GitHub: Current build version not found"
@ -60,7 +60,7 @@ fn_update_mumble_currentbuild(){
command_stop.sh command_stop.sh
exitbypass=1 exitbypass=1
command_start.sh 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 if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: GitHub: Current build version still not found" 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" fn_script_log_fatal "Checking for update: GitHub: Current build version still not found"

6
lgsm/functions/update_steamcmd.sh

@ -17,7 +17,7 @@ fn_update_steamcmd_dl(){
fn_print_ok_nl "SteamCMD" fn_print_ok_nl "SteamCMD"
fn_script_log_info "Starting SteamCMD" fn_script_log_info "Starting SteamCMD"
cd "${steamcmddir}" cd "${steamcmddir}" || exit
# Detects if unbuffer command is available for 32 bit distributions only. # Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh info_distro.sh
@ -157,7 +157,7 @@ fn_update_steamcmd_check(){
fi fi
# Set branch for updateinfo # Set branch for updateinfo
IFS=' ' read -a branchsplits <<< "${branch}" IFS=' ' read -ra branchsplits <<< "${branch}"
if [ "${#branchsplits[@]}" -gt 1 ]; then if [ "${#branchsplits[@]}" -gt 1 ]; then
branchname="${branchsplits[1]}" branchname="${branchsplits[1]}"
else else
@ -165,7 +165,7 @@ fn_update_steamcmd_check(){
fi fi
# Gets availablebuild info # 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:]') 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 if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: SteamCMD" fn_print_fail "Checking for update: SteamCMD"

10
lgsm/functions/update_ts3.sh

@ -48,7 +48,7 @@ fn_update_ts3_currentbuild(){
fi fi
# Get current build from logs # 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 if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: teamspeak.com: Current build version not found" 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" 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 command_stop.sh
exitbypass=1 exitbypass=1
command_start.sh 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 if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: teamspeak.com: Current build version still not found" 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" 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. # Gets latest build info.
# Grabs all version numbers but not in correct order. # 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 href=\".*\/\">.*\/<\/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 href=\".*\/\">.*\/<\/a>' | grep -Eo '[0-9\.?]+'|uniq > "${tmpdir}/.ts3_version_numbers_unsorted.tmp"
# Sort version numbers # Sort version numbers
cat "${tmpdir}/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${tmpdir}/.ts3_version_numbers_sorted.tmp" 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. # 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" 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 if [ $? -eq 0 ]; then
availablebuild="${ts3_version_number}" availablebuild="${ts3_version_number}"
@ -206,7 +206,7 @@ fn_update_ts3_compare(){
fn_update_ts3_arch fn_update_ts3_arch
if [ "${installer}" == "1" ]; then if [ "${installer}" == "1" ]; then
# if jq available uses json update checker # 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 fn_update_ts3_availablebuild
else else
fn_update_ts3_availablebuild_legacy fn_update_ts3_availablebuild_legacy

13
linuxgsm.sh

@ -70,13 +70,8 @@ fn_bootstrap_fetch_file(){
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path # 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) curlpath=$(command -v curl 2>/dev/null)
for curlpath in "${curl_paths_array}"
do
if [ -x "${curlpath}" ]; then
break
fi
done
# If curl exists download file # If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then if [ "$(basename ${curlpath})" == "curl" ]; then
# trap to remove part downloaded files # trap to remove part downloaded files
@ -198,8 +193,8 @@ fn_install_menu() {
options=$4 options=$4
# Get menu command # Get menu command
for menucmd in whiptail dialog bash; do for menucmd in whiptail dialog bash; do
if [ -x $(which ${menucmd}) ]; then if [ -x $(command -v ${menucmd}) ]; then
menucmd=$(which ${menucmd}) menucmd=$(command -v ${menucmd})
break break
fi fi
done done

13
tests/tests_jc2server.sh

@ -65,13 +65,8 @@ fn_bootstrap_fetch_file(){
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path # 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) curlpath=$(command -v curl 2>/dev/null)
for curlpath in "${curl_paths_array}"
do
if [ -x "${curlpath}" ]; then
break
fi
done
# If curl exists download file # If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then if [ "$(basename ${curlpath})" == "curl" ]; then
# trap to remove part downloaded files # trap to remove part downloaded files
@ -193,8 +188,8 @@ fn_install_menu() {
options=$4 options=$4
# Get menu command # Get menu command
for menucmd in whiptail dialog bash; do for menucmd in whiptail dialog bash; do
if [ -x $(which ${menucmd}) ]; then if [ -x $(command -v ${menucmd}) ]; then
menucmd=$(which ${menucmd}) menucmd=$(command -v ${menucmd})
break break
fi fi
done done

13
tests/tests_ts3server.sh

@ -65,13 +65,8 @@ fn_bootstrap_fetch_file(){
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path # 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) curlpath=$(command -v curl 2>/dev/null)
for curlpath in "${curl_paths_array}"
do
if [ -x "${curlpath}" ]; then
break
fi
done
# If curl exists download file # If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then if [ "$(basename ${curlpath})" == "curl" ]; then
# trap to remove part downloaded files # trap to remove part downloaded files
@ -193,8 +188,8 @@ fn_install_menu() {
options=$4 options=$4
# Get menu command # Get menu command
for menucmd in whiptail dialog bash; do for menucmd in whiptail dialog bash; do
if [ -x $(which ${menucmd}) ]; then if [ -x $(command -v ${menucmd}) ]; then
menucmd=$(which ${menucmd}) menucmd=$(command -v ${menucmd})
break break
fi fi
done done

Loading…
Cancel
Save