From 2aee8dafc418091971c99d82321e6205b8d36d94 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 18 Mar 2016 19:55:47 +0000 Subject: [PATCH] added legacy code back in --- lgsm/functions/core_functions.sh | 63 +++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 266333993..7240cfc12 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -7,6 +7,68 @@ lgsm_version="270216" # 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 would not load. +# Code/functions for legacy servers + +fn_functions(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + +fn_getopt(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + +# fn_fetch_core_dl also placed here to allow legecy servers to still download core functions +if [ -z "${lgsmdir}" ]; then + lgsmdir="${rootdir}/lgsm" + functionsdir="${lgsmdir}/functions" + libdir="${lgsmdir}/lib" +fi + +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 curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + chmod +x "${filedir}/${filename}" +fi +source "${filedir}/${filename}" +} + + # Core core_dl.sh(){ @@ -125,7 +187,6 @@ functionfile="${FUNCNAME}" fn_fetch_function } - check_ip.sh(){ functionfile="${FUNCNAME}" fn_fetch_function