|
|
@@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then
|
|
|
set -x
|
|
|
fi
|
|
|
|
|
|
-version="271215"
|
|
|
+version="150316"
|
|
|
|
|
|
#### Variables ####
|
|
|
|
|
|
@@ -83,55 +83,62 @@ consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-
|
|
|
##### Script #####
|
|
|
# Do not edit
|
|
|
|
|
|
-fn_getgithubfile(){
|
|
|
-filename=$1
|
|
|
-exec=$2
|
|
|
-fileurl=${3:-$filename}
|
|
|
-filepath="${rootdir}/${filename}"
|
|
|
-filedir=$(dirname "${filepath}")
|
|
|
-# If the function file is missing, then download
|
|
|
-if [ ! -f "${filepath}" ]; then
|
|
|
+# Fetches core_dl for file downloads
|
|
|
+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 "${filedir}"
|
|
|
+ mkdir -p "${filedir}"
|
|
|
fi
|
|
|
- githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
|
|
|
echo -e " fetching ${filename}...\c"
|
|
|
- if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
|
|
|
- :
|
|
|
- else
|
|
|
+ # 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
|
|
|
- fi
|
|
|
- curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
|
|
|
- if [ $? -ne 0 ]; then
|
|
|
- echo -e "\e[0;31mFAIL\e[0m\n"
|
|
|
- echo "${curl}"
|
|
|
- echo -e "${githuburl}\n"
|
|
|
- exit
|
|
|
- else
|
|
|
- echo -e "\e[0;32mOK\e[0m"
|
|
|
- fi
|
|
|
- if [ "${exec}" ]; then
|
|
|
- chmod +x "${filepath}"
|
|
|
+ exit 1
|
|
|
fi
|
|
|
+ chmod +x "${filedir}/${filename}"
|
|
|
fi
|
|
|
-if [ "${exec}" ]; then
|
|
|
- source "${filepath}"
|
|
|
-fi
|
|
|
+source "${filedir}/${filename}"
|
|
|
}
|
|
|
|
|
|
-fn_runfunction(){
|
|
|
- fn_getgithubfile "functions/${functionfile}" 1
|
|
|
+core_dl.sh(){
|
|
|
+# Functions are defined in core_functions.sh.
|
|
|
+functionfile="${FUNCNAME}"
|
|
|
+fn_fetch_core_dl
|
|
|
}
|
|
|
|
|
|
core_functions.sh(){
|
|
|
# Functions are defined in core_functions.sh.
|
|
|
functionfile="${FUNCNAME}"
|
|
|
-fn_runfunction
|
|
|
+fn_fetch_core_dl
|
|
|
}
|
|
|
|
|
|
+core_dl.sh
|
|
|
core_functions.sh
|
|
|
|
|
|
getopt=$1
|