mirror of
https://github.com/GameServerManagers/LinuxGSM.git
synced 2025-01-08 12:07:37 +08:00
standardise command if
This commit is contained in:
parent
ce2005ab6a
commit
736e55717f
@ -160,7 +160,7 @@ fn_deps_detector(){
|
||||
depstatus=1
|
||||
jquniversemissing=1
|
||||
elif [ "${deptocheck}" == "mono-complete" ]; then
|
||||
if [ -n "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then
|
||||
if [ "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then
|
||||
# Mono >= 5.0.0 already installed.
|
||||
depstatus=0
|
||||
else
|
||||
@ -168,10 +168,10 @@ fn_deps_detector(){
|
||||
depstatus=1
|
||||
monostatus=1
|
||||
fi
|
||||
elif [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
dpkg-query -W -f='${Status}' "${deptocheck}" 2>/dev/null | grep -q -P '^install ok installed'
|
||||
depstatus=$?
|
||||
elif [ -n "$(command -v rpm 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v rpm 2>/dev/null)" ]; then
|
||||
rpm -q "${deptocheck}" > /dev/null 2>&1
|
||||
depstatus=$?
|
||||
fi
|
||||
@ -212,15 +212,15 @@ fn_deps_email(){
|
||||
array_deps_required+=( exim4 )
|
||||
elif [ -d /etc/sendmail ]; then
|
||||
array_deps_required+=( sendmail )
|
||||
elif [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
array_deps_required+=( mailutils postfix )
|
||||
elif [ -n "$(command -v rpm 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v rpm 2>/dev/null)" ]; then
|
||||
array_deps_required+=( mailx postfix )
|
||||
fi
|
||||
else
|
||||
if [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
array_deps_required+=( mailutils postfix )
|
||||
elif [ -n "$(command -v rpm 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v rpm 2>/dev/null)" ]; then
|
||||
array_deps_required+=( mailx postfix )
|
||||
fi
|
||||
fi
|
||||
@ -255,13 +255,13 @@ fn_found_missing_deps(){
|
||||
echo -en "...\r"
|
||||
sleep 1
|
||||
echo -en " \r"
|
||||
if [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
cmd="sudo dpkg --add-architecture i386; sudo apt update; sudo apt -y install ${array_deps_missing[@]}"
|
||||
eval "${cmd}"
|
||||
elif [ -n "$(command -v dnf 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v dnf 2>/dev/null)" ]; then
|
||||
cmd="sudo dnf -y install ${array_deps_missing[@]}"
|
||||
eval "${cmd}"
|
||||
elif [ -n "$(command -v yum 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v yum 2>/dev/null)" ]; then
|
||||
cmd="sudo yum -y install ${array_deps_missing[@]}"
|
||||
eval "${cmd}"
|
||||
fi
|
||||
@ -271,11 +271,11 @@ fn_found_missing_deps(){
|
||||
echo -e ""
|
||||
fn_print_warning_nl "Manually install dependencies."
|
||||
fn_script_log_warn "Manually install dependencies."
|
||||
if [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
echo -e " sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[@]}"
|
||||
elif [ -n "$(command -v dnf 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v dnf 2>/dev/null)" ]; then
|
||||
echo -e " sudo dnf install ${array_deps_missing[@]}"
|
||||
elif [ -n "$(command -v yum 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v yum 2>/dev/null)" ]; then
|
||||
echo -e " sudo yum install ${array_deps_missing[@]}"
|
||||
fi
|
||||
if [ "${steamcmdfail}" ]; then
|
||||
@ -292,11 +292,11 @@ fn_found_missing_deps(){
|
||||
echo -e ""
|
||||
fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies."
|
||||
fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies."
|
||||
if [ -n "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
|
||||
echo -e " sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[@]}"
|
||||
elif [ -n "$(command -v dnf 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v dnf 2>/dev/null)" ]; then
|
||||
echo -e " sudo dnf install ${array_deps_missing[@]}"
|
||||
elif [ -n "$(command -v yum 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v yum 2>/dev/null)" ]; then
|
||||
echo -e " sudo yum install ${array_deps_missing[@]}"
|
||||
fi
|
||||
if [ "${steamcmdfail}" ]; then
|
||||
@ -337,7 +337,7 @@ fn_deps_build_debian(){
|
||||
# LinuxGSM requirements.
|
||||
array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python3 tar bzip2 gzip unzip binutils bc jq )
|
||||
|
||||
if [ -n "$(command -v tmux 2>/dev/null)" ]; 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 )
|
||||
@ -461,7 +461,7 @@ fn_deps_build_redhat(){
|
||||
fi
|
||||
|
||||
# All servers except ts3 require tmux.
|
||||
if [ -n "$(command -v tmux 2>/dev/null)" ]; then
|
||||
if [ "$(command -v tmux 2>/dev/null)" ]; then
|
||||
# Added for users compiling tmux from source to bypass check.
|
||||
tmuxcheck=1
|
||||
else
|
||||
|
@ -13,9 +13,9 @@ echo -e "Dependencies Checker"
|
||||
echo -e "================================="
|
||||
echo -e "Checking directory: "
|
||||
echo -e "${serverfiles}"
|
||||
if [ -n "$(command -v eu-readelf 2>/dev/null)" ]; then
|
||||
if [ "$(command -v eu-readelf 2>/dev/null)" ]; then
|
||||
readelf=eu-readelf
|
||||
elif [ -n "$(command -v readelf 2>/dev/null)" ]; then
|
||||
elif [ "$(command -v readelf 2>/dev/null)" ]; then
|
||||
readelf=readelf
|
||||
else
|
||||
echo -e "readelf/eu-readelf not installed"
|
||||
|
@ -13,7 +13,7 @@ echo -e "================================="
|
||||
echo -e "glibc Requirements Checker"
|
||||
echo -e "================================="
|
||||
|
||||
if [ -z "$(command -v objdump)" ]; then
|
||||
if [ ! "$(command -v objdump)" ]; then
|
||||
fn_print_failure_nl "objdump is missing"
|
||||
fn_script_log_fatal "objdump is missing"
|
||||
core_exit.sh
|
||||
|
@ -23,7 +23,7 @@ luafastdlfile="lgsm_cl_force_fastdl.lua"
|
||||
luafastdlfullpath="${luasvautorundir}/${luafastdlfile}"
|
||||
|
||||
# Check if bzip2 is installed.
|
||||
if [ -z "$(command -v bzip2 2>/dev/null)" ]; then
|
||||
if [ ! "$(command -v bzip2 2>/dev/null)" ]; then
|
||||
fn_print_fail "bzip2 is not installed"
|
||||
fn_script_log_fatal "bzip2 is not installed"
|
||||
core_exit.sh
|
||||
|
@ -211,7 +211,7 @@ fn_monitor_loop(){
|
||||
do
|
||||
# Will check if gamedig is installed and bypass if not.
|
||||
if [ "${querymethod}" == "gamedig" ]; then
|
||||
if [ -n "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
|
||||
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
|
||||
if [ -z "${monitorpass}" ]; then
|
||||
fn_monitor_query
|
||||
fi
|
||||
|
@ -126,7 +126,7 @@ fn_stop_graceful_sdtd(){
|
||||
fn_script_log_info "Graceful: telnet"
|
||||
if [ "${telnetenabled}" == "false" ]; then
|
||||
fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
|
||||
elif [ -n "$(command -v expect 2>/dev/null)" ]; 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}:${telnetport}"
|
||||
|
@ -18,7 +18,7 @@ fn_validation(){
|
||||
cd "${steamcmddir}" || exit
|
||||
# Detects if unbuffer command is available for 32 bit distributions only.
|
||||
info_distro.sh
|
||||
if [ -n "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
|
||||
if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
|
||||
unbuffer="stdbuf -i0 -o0 -e0"
|
||||
fi
|
||||
|
||||
|
@ -256,7 +256,7 @@ fn_update_function(){
|
||||
}
|
||||
|
||||
# Check that curl is installed
|
||||
if [ -z "$(command -v curl 2>/dev/null)" ]; then
|
||||
if [ ! "$(command -v curl 2>/dev/null)" ]; then
|
||||
echo -e "[ FAIL ] Curl is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -32,7 +32,7 @@ do
|
||||
distroversion=$(grep VERSION_ID /etc/os-release | sed 's/VERSION_ID=//g' | sed 's/\"//g')
|
||||
distroid=$(grep ID /etc/os-release | grep -v _ID | grep -v ID_ | sed 's/ID=//g' | sed 's/\"//g')
|
||||
distrocodename=$(grep VERSION_CODENAME /etc/os-release | sed 's/VERSION_CODENAME=//g' | sed 's/\"//g')
|
||||
elif [ -n "$(command -v lsb_release 2>/dev/null)" ]&&[ "${distro_info}" == "lsb_release" ]; then
|
||||
elif [ "$(command -v lsb_release 2>/dev/null)" ]&&[ "${distro_info}" == "lsb_release" ]; then
|
||||
if [ -z "${distroname}" ];then
|
||||
distroname=$(lsb_release -sd)
|
||||
elif [ -z "${distroversion}" ];then
|
||||
@ -42,7 +42,7 @@ do
|
||||
elif [ -z "${distrocodename}" ];then
|
||||
distrocodename=$(lsb_release -sc)
|
||||
fi
|
||||
elif [ -n "$(command -v hostnamectl 2>/dev/null)" ]&&[ "${distro_info}" == "hostnamectl" ]; then
|
||||
elif [ "$(command -v hostnamectl 2>/dev/null)" ]&&[ "${distro_info}" == "hostnamectl" ]; then
|
||||
if [ -z "${distroname}" ];then
|
||||
distroname=$(hostnamectl | grep "Operating System" | sed 's/Operating System: //g')
|
||||
fi
|
||||
@ -71,7 +71,7 @@ glibcversion=$(ldd --version | sed -n '1s/.* //p')
|
||||
|
||||
## tmux version
|
||||
# e.g: tmux 1.6
|
||||
if [ -z "$(command -V tmux 2>/dev/null)" ]; then
|
||||
if [ ! "$(command -V tmux 2>/dev/null)" ]; then
|
||||
tmuxv="${red}NOT INSTALLED!${default}"
|
||||
else
|
||||
if [ "$(tmux -V | sed "s/tmux //" | sed -n '1 p' | tr -cd '[:digit:]')" -lt "16" ]; then
|
||||
@ -107,7 +107,7 @@ fi
|
||||
# Available RAM and swap.
|
||||
|
||||
# Newer distros can use numfmt to give more accurate results.
|
||||
if [ -n "$(command -v numfmt 2>/dev/null)" ]; then
|
||||
if [ "$(command -v numfmt 2>/dev/null)" ]; then
|
||||
# Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated.
|
||||
|
||||
# get the raw KB values of these fields.
|
||||
@ -252,7 +252,7 @@ else
|
||||
fi
|
||||
|
||||
# Steam Master Server - checks if detected by master server.
|
||||
if [ -n "$(command -v jq 2>/dev/null)" ]; then
|
||||
if [ "$(command -v jq 2>/dev/null)" ]; then
|
||||
if [ "${ip}" ]&&[ "${port}" ]; then
|
||||
if [ "${steammaster}" == "true" ]; then
|
||||
masterserver=$(curl -m 3 -s 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr='${ip}':'${port}'&format=json' | jq '.response.servers[]|.addr' | wc -l)
|
||||
|
@ -10,7 +10,7 @@ info_distro.sh
|
||||
if [ ! -f "${datadir}/uuid.txt" ];then
|
||||
mkdir -p "${datadir}"
|
||||
touch "${datadir}/uuid.txt"
|
||||
if [ -n "$(command -v uuidgen 2>/dev/null)" ]; then
|
||||
if [ "$(command -v uuidgen 2>/dev/null)" ]; then
|
||||
uuidgen > "${datadir}/uuid.txt"
|
||||
else
|
||||
cat /proc/sys/kernel/random/uuid > "${datadir}/uuid.txt"
|
||||
|
@ -98,7 +98,7 @@ fn_install_server_files_steamcmd(){
|
||||
|
||||
# Detects if unbuffer command is available for 32 bit distributions only.
|
||||
info_distro.sh
|
||||
if [ -n "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then
|
||||
if [ "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then
|
||||
unbuffer="stdbuf -i0 -o0 -e0"
|
||||
fi
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# https://github.com/sonicsnes/node-gamedig
|
||||
|
||||
# Check if gamedig and jq are installed.
|
||||
if [ -n "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
|
||||
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
|
||||
|
||||
# will bypass query if server offline.
|
||||
check_status.sh
|
||||
|
@ -13,7 +13,7 @@ fn_update_steamcmd_dl(){
|
||||
|
||||
# Detects if unbuffer command is available for 32 bit distributions only.
|
||||
info_distro.sh
|
||||
if [ -n "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
|
||||
if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
|
||||
unbuffer="stdbuf -i0 -o0 -e0"
|
||||
fi
|
||||
|
||||
|
@ -72,7 +72,7 @@ fn_bootstrap_fetch_file(){
|
||||
fi
|
||||
|
||||
# If curl exists download file.
|
||||
if [ -n "$(command -v curl 2>/dev/null)" ]; then
|
||||
if [ "$(command -v curl 2>/dev/null)" ]; then
|
||||
# Trap to remove part downloaded files.
|
||||
echo -en " fetching ${local_filename}...\c"
|
||||
curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
|
||||
@ -192,7 +192,7 @@ fn_install_menu() {
|
||||
options=$4
|
||||
# Get menu command.
|
||||
for menucmd in whiptail dialog bash; do
|
||||
if [ -x "$(command -v "${menucmd}")" ]; then
|
||||
if [ "$(command -v "${menucmd}")" ]; then
|
||||
menucmd=$(command -v "${menucmd}")
|
||||
break
|
||||
fi
|
||||
|
@ -81,7 +81,7 @@ fn_bootstrap_fetch_file(){
|
||||
fi
|
||||
|
||||
# If curl exists download file.
|
||||
if [ -n "$(command -v curl 2>/dev/null)" ]; then
|
||||
if [ "$(command -v curl 2>/dev/null)" ]; then
|
||||
# Trap to remove part downloaded files.
|
||||
echo -en " fetching ${local_filename}...\c"
|
||||
curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
|
||||
@ -201,7 +201,7 @@ fn_install_menu() {
|
||||
options=$4
|
||||
# Get menu command.
|
||||
for menucmd in whiptail dialog bash; do
|
||||
if [ -x "$(command -v "${menucmd}")" ]; then
|
||||
if [ "$(command -v "${menucmd}")" ]; then
|
||||
menucmd=$(command -v "${menucmd}")
|
||||
break
|
||||
fi
|
||||
|
@ -201,7 +201,7 @@ fn_install_menu() {
|
||||
options=$4
|
||||
# Get menu command.
|
||||
for menucmd in whiptail dialog bash; do
|
||||
if [ -x "$(command -v "${menucmd}")" ]; then
|
||||
if [ "$(command -v "${menucmd}")" ]; then
|
||||
menucmd=$(command -v "${menucmd}")
|
||||
break
|
||||
fi
|
||||
|
@ -81,7 +81,7 @@ fn_bootstrap_fetch_file(){
|
||||
fi
|
||||
|
||||
# If curl exists download file.
|
||||
if [ -n "$(command -v curl 2>/dev/null)" ]; then
|
||||
if [ "$(command -v curl 2>/dev/null)" ]; then
|
||||
# Trap to remove part downloaded files.
|
||||
echo -en " fetching ${local_filename}...\c"
|
||||
curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
|
||||
@ -201,7 +201,7 @@ fn_install_menu() {
|
||||
options=$4
|
||||
# Get menu command.
|
||||
for menucmd in whiptail dialog bash; do
|
||||
if [ -x "$(command -v "${menucmd}")" ]; then
|
||||
if [ "$(command -v "${menucmd}")" ]; then
|
||||
menucmd=$(command -v "${menucmd}")
|
||||
break
|
||||
fi
|
||||
|
@ -81,7 +81,7 @@ fn_bootstrap_fetch_file(){
|
||||
fi
|
||||
|
||||
# If curl exists download file.
|
||||
if [ -n "$(command -v curl 2>/dev/null)" ]; then
|
||||
if [ "$(command -v curl 2>/dev/null)" ]; then
|
||||
# Trap to remove part downloaded files.
|
||||
echo -en " fetching ${local_filename}...\c"
|
||||
curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
|
||||
@ -201,7 +201,7 @@ fn_install_menu() {
|
||||
options=$4
|
||||
# Get menu command.
|
||||
for menucmd in whiptail dialog bash; do
|
||||
if [ -x "$(command -v "${menucmd}")" ]; then
|
||||
if [ "$(command -v "${menucmd}")" ]; then
|
||||
menucmd=$(command -v "${menucmd}")
|
||||
break
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user