Browse Source

Getting functions downloader working

pull/743/head
Daniel Gibbs 9 years ago
parent
commit
eee9851ded
  1. 12
      JustCause2/jc2server
  2. 43
      functions/core_dl.sh
  3. 149
      functions/core_functions.sh

12
JustCause2/jc2server

@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then
set -x
fi
version="271215"
version="160316"
#### Variables ####
@ -106,7 +106,7 @@ if [ ! -f "${filedir}/${filename}" ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curlfetch}"
echo -e "${githuburl}\n"
exit
exit 1
else
echo -e "\e[0;32mOK\e[0m"
fi
@ -114,7 +114,7 @@ if [ ! -f "${filedir}/${filename}" ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "Curl is not installed!"
echo -e ""
exit
exit 1
fi
chmod +x "${filedir}/${filename}"
fi
@ -127,6 +127,12 @@ functionfile="${FUNCNAME}"
fn_fetch_core_dl
}
core_functions.sh(){
# Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
}
core_dl.sh
core_functions.sh

43
functions/core_dl.sh

@ -71,25 +71,25 @@ fn_dl_md5
# Downloads file using curl and run it if required
fn_dl_file(){
fileurl="${1}"
filedir="${2}"
filename="${3}"
# fn_fetch_file "fileurl" "filedir" "filename" "run" "force" "md5"
fn_fetch_file(){
fileurl=${1}
filedir=${2}
filename=${3}
run=${4:-0}
force=${5:-0}
md5=${6}
# If the file is missing or forced, then download
if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; then
# 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 $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")"
for curlcmd in ${curlpaths}
do
if [ -x "${curlcmd}" ]; then
curlcmd=${curlcmd}
break
fi
done
@ -105,24 +105,12 @@ if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; th
fn_printfaileol
echo "${curlfetch}"
echo -e "${fileurl}\n"
fn_scriptlog "failed to download ${filedir}/${filename}"
fn_scriptlog "${curlfetch}"
fn_scriptlog -e "${fileurl}\n"
sleep 1
echo "Removing failed ${filename}..."
rm -f "${filedir}/${filename}"
if [ $? -ne 0 ]; then
fn_printfaileol
else
fn_printokeol
fi
exit 1
else
fn_printokeol
fn_scriptlog "downloaded ${filedir}/${filename}"
fi
else
echo -e "fn_printfaileol"
fn_printfaileol
echo "Curl is not installed!"
echo -e ""
exit 1
@ -158,4 +146,17 @@ force=${5:-0}
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
echo -e " fetching ${filename}...\c"
fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${run}" "${force}"
}
# Fetches functions
fn_fetch_function(){
github_file_url_dir="functions" # github dir containing the file
github_file_url_name="${functionfile}" # name of the github file
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
filedir="${functionsdir}" # local dir that will contain the file
filename="${github_file_url_name}" # name of the local file
run="run"
fn_fetch_file "${githuburl}" "${filedir}" "${filename}" "${run}"
}

149
functions/core_functions.sh

@ -2,97 +2,102 @@
# LGSM core_functions.sh function
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
lgsm_version="030216"
lgsm_version="160216"
# Description: Defines all functions to allow download and execution of functions using fn_runfunction.
# 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.
#Legacy functions
fn_functions(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fn_getopt(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
# Core
core_dl.sh(){
# Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
}
core_getopt.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_core_dl
}
core_messages.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_core_dl
}
core_dl.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_core_dl
}
# Command
command_console.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_debug.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_details.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_email_test.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_backup.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_monitor.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_start.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_stop.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_validate.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_install.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_ts3_server_pass.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fn_restart(){
@ -108,52 +113,52 @@ command_start.sh
check.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_config.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_deps.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_ip.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_logs.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_root.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_steamcmd.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_steamuser.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_systemdir.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
check_tmux.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -161,12 +166,12 @@ fn_runfunction
compress_unreal2_maps.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
compress_ut99_maps.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -174,12 +179,12 @@ fn_runfunction
command_dev_debug.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
command_dev_detect_deps.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -187,52 +192,52 @@ fn_runfunction
fix.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_arma3.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_csgo.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_dst.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_ins.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_steamcmd.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_glibc.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_ro.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_kf.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_ut2k4.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -240,22 +245,22 @@ fn_runfunction
info_config.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
info_distro.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
info_glibc.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
info_ts3status.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -263,14 +268,14 @@ fn_runfunction
email.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
# Logs
logs.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -278,7 +283,7 @@ fn_runfunction
monitor_gsquery.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -286,22 +291,22 @@ fn_runfunction
update_check.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
update_functions.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
update_dl.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
update_functions.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
@ -316,91 +321,91 @@ command_install.sh
install_complete.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_config.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_gsquery.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_gslt.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_header.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_logs.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_retry.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_serverdir.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_serverfiles.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_steamcmd.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_ts3.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_ts3db.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_ut2k4.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_dl_ut2k4.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_ut2k4_key.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_ut99.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
install_dl_ut99.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
fix_ut99.sh(){
functionfile="${FUNCNAME}"
fn_runfunction
fn_fetch_function
}
# Calls on-screen messages

Loading…
Cancel
Save