|
|
@ -5,85 +5,6 @@ |
|
|
|
# Description: Defines all functions to allow download and execution of functions using fn_fetch_function. |
|
|
|
# This function is called first before any other function. Without this file other functions will not load. |
|
|
|
|
|
|
|
# Fixes for legacy code |
|
|
|
if [ "${gamename}" == "ARK: Survivial Evolved" ]; then |
|
|
|
gamename="ARK: Survival Evolved" |
|
|
|
elif [ "${gamename}" == "Teamspeak 3" ]; then |
|
|
|
gamename="TeamSpeak 3" |
|
|
|
elif [ "${gamename}" == "Counter Strike: Global Offensive" ]; then |
|
|
|
gamename="Counter-Strike: Global Offensive" |
|
|
|
elif [ "${gamename}" == "Counter Strike: Source" ]; then |
|
|
|
gamename="Counter-Strike: Source" |
|
|
|
elif [ "${gamename}" == "Quake Live" ]; then |
|
|
|
engine="idtech3_ql" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "${emailnotification}" == "on" ]; then |
|
|
|
emailalert="on" |
|
|
|
fi |
|
|
|
|
|
|
|
## Code/functions for legacy servers |
|
|
|
fn_functions(){ |
|
|
|
functionfile="${FUNCNAME}" |
|
|
|
fn_fetch_function |
|
|
|
} |
|
|
|
|
|
|
|
fn_getopt(){ |
|
|
|
functionfile="${FUNCNAME}" |
|
|
|
fn_fetch_function |
|
|
|
} |
|
|
|
|
|
|
|
## In case older versions are missing these vars |
|
|
|
if [ -z "${lgsmdir}" ]||[ -z "${functionsdir}" ]||[ -z "${libdir}" ]||[ -z "${tmpdir}" ]; then |
|
|
|
lgsmdir="${rootdir}/lgsm" |
|
|
|
functionsdir="${lgsmdir}/functions" |
|
|
|
libdir="${lgsmdir}/lib" |
|
|
|
tmpdir="${lgsmdir}/tmp" |
|
|
|
fi |
|
|
|
|
|
|
|
## fn_fetch_core_dl placed here to allow legacy servers to still download core functions |
|
|
|
fn_fetch_core_dl(){ |
|
|
|
github_file_url_dir="lgsm/functions" |
|
|
|
github_file_url_name="${functionfile}" |
|
|
|
filedir="${functionsdir}" |
|
|
|
filename="${github_file_url_name}" |
|
|
|
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" |
|
|
|
# If the file is missing, then download |
|
|
|
if [ ! -f "${filedir}/${filename}" ]; then |
|
|
|
if [ ! -d "${filedir}" ]; then |
|
|
|
mkdir -p "${filedir}" |
|
|
|
fi |
|
|
|
echo -e " fetching ${filename}...\c" |
|
|
|
# Check curl exists and use available path |
|
|
|
curlpaths="$(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 ${curlpaths} |
|
|
|
do |
|
|
|
if [ -x "${curlpath}" ]; then |
|
|
|
break |
|
|
|
fi |
|
|
|
done |
|
|
|
# If curl exists download file |
|
|
|
if [ "$(basename ${curlpath})" == "curl" ]; then |
|
|
|
curlcmd=$(${curlpath} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) |
|
|
|
if [ $? -ne 0 ]; then |
|
|
|
echo -e "${red}FAIL${default}\n" |
|
|
|
echo "${curlcmd}" |
|
|
|
echo -e "${githuburl}\n" |
|
|
|
exit 1 |
|
|
|
else |
|
|
|
echo -e "${green}OK${default}" |
|
|
|
fi |
|
|
|
else |
|
|
|
echo -e "${red}FAIL${default}\n" |
|
|
|
echo "Curl is not installed!" |
|
|
|
echo -e "" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
chmod +x "${filedir}/${filename}" |
|
|
|
fi |
|
|
|
source "${filedir}/${filename}" |
|
|
|
} |
|
|
|
|
|
|
|
# Creates tmp dir if missing |
|
|
|
if [ ! -d "${tmpdir}" ]; then |
|
|
|
mkdir -p "${tmpdir}" |
|
|
|