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 set -x
fi fi
version="271215" version="160316"
#### Variables #### #### Variables ####
@ -106,7 +106,7 @@ if [ ! -f "${filedir}/${filename}" ]; then
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curlfetch}" echo "${curlfetch}"
echo -e "${githuburl}\n" echo -e "${githuburl}\n"
exit exit 1
else else
echo -e "\e[0;32mOK\e[0m" echo -e "\e[0;32mOK\e[0m"
fi fi
@ -114,7 +114,7 @@ if [ ! -f "${filedir}/${filename}" ]; then
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "\e[0;31mFAIL\e[0m\n"
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit exit 1
fi fi
chmod +x "${filedir}/${filename}" chmod +x "${filedir}/${filename}"
fi fi
@ -127,6 +127,12 @@ functionfile="${FUNCNAME}"
fn_fetch_core_dl fn_fetch_core_dl
} }
core_functions.sh(){
# Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
}
core_dl.sh core_dl.sh
core_functions.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 # Downloads file using curl and run it if required
fn_dl_file(){ # fn_fetch_file "fileurl" "filedir" "filename" "run" "force" "md5"
fileurl="${1}" fn_fetch_file(){
filedir="${2}" fileurl=${1}
filename="${3}" filedir=${2}
filename=${3}
run=${4:-0} run=${4:-0}
force=${5:-0} force=${5:-0}
md5=${6} md5=${6}
# If the file is missing or forced, then download # If the file is missing, then download
if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; then if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then if [ ! -d "${filedir}" ]; then
mkdir -p "${filedir}" mkdir -p "${filedir}"
fi fi
echo -e " fetching ${filename}...\c"
# Check curl exists and use available path # 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")" 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} for curlcmd in ${curlpaths}
do do
if [ -x "${curlcmd}" ]; then if [ -x "${curlcmd}" ]; then
curlcmd=${curlcmd}
break break
fi fi
done done
@ -105,24 +105,12 @@ if [ ! -f "${filedir}" ] || [ "${force}" == "1" ] || [ "${force}" == "yes" ]; th
fn_printfaileol fn_printfaileol
echo "${curlfetch}" echo "${curlfetch}"
echo -e "${fileurl}\n" 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 exit 1
else else
fn_printokeol fn_printokeol
fn_scriptlog "downloaded ${filedir}/${filename}"
fi fi
else else
echo -e "fn_printfaileol" fn_printfaileol
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit 1 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}" githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
echo -e " fetching ${filename}...\c" echo -e " fetching ${filename}...\c"
fn_fetch_file "${githuburl}" "${filepath}" "${filename}" "${run}" "${force}" 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 # LGSM core_functions.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: http://gameservermanagers.com # 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. # This function is called first before any other function. Without this file other functions would not load.
#Legacy functions #Legacy functions
fn_functions(){ fn_functions(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fn_getopt(){ fn_getopt(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
# Core # Core
core_dl.sh(){
# Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
}
core_getopt.sh(){ core_getopt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_core_dl
} }
core_messages.sh(){ core_messages.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_core_dl
} }
core_dl.sh(){ core_dl.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_core_dl
} }
# Command # Command
command_console.sh(){ command_console.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_debug.sh(){ command_debug.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_details.sh(){ command_details.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_email_test.sh(){ command_email_test.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_backup.sh(){ command_backup.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_monitor.sh(){ command_monitor.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_start.sh(){ command_start.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_stop.sh(){ command_stop.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_validate.sh(){ command_validate.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_install.sh(){ command_install.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_ts3_server_pass.sh(){ command_ts3_server_pass.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fn_restart(){ fn_restart(){
@ -108,52 +113,52 @@ command_start.sh
check.sh(){ check.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_config.sh(){ check_config.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_deps.sh(){ check_deps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_ip.sh(){ check_ip.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_logs.sh(){ check_logs.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_root.sh(){ check_root.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_steamcmd.sh(){ check_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_steamuser.sh(){ check_steamuser.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_systemdir.sh(){ check_systemdir.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
check_tmux.sh(){ check_tmux.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -161,12 +166,12 @@ fn_runfunction
compress_unreal2_maps.sh(){ compress_unreal2_maps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
compress_ut99_maps.sh(){ compress_ut99_maps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -174,12 +179,12 @@ fn_runfunction
command_dev_debug.sh(){ command_dev_debug.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
command_dev_detect_deps.sh(){ command_dev_detect_deps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -187,52 +192,52 @@ fn_runfunction
fix.sh(){ fix.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_arma3.sh(){ fix_arma3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_csgo.sh(){ fix_csgo.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_dst.sh(){ fix_dst.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_ins.sh(){ fix_ins.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_steamcmd.sh(){ fix_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_glibc.sh(){ fix_glibc.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_ro.sh(){ fix_ro.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_kf.sh(){ fix_kf.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_ut2k4.sh(){ fix_ut2k4.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -240,22 +245,22 @@ fn_runfunction
info_config.sh(){ info_config.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
info_distro.sh(){ info_distro.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
info_glibc.sh(){ info_glibc.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
info_ts3status.sh(){ info_ts3status.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -263,14 +268,14 @@ fn_runfunction
email.sh(){ email.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
# Logs # Logs
logs.sh(){ logs.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -278,7 +283,7 @@ fn_runfunction
monitor_gsquery.sh(){ monitor_gsquery.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -286,22 +291,22 @@ fn_runfunction
update_check.sh(){ update_check.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
update_functions.sh(){ update_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
update_dl.sh(){ update_dl.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
update_functions.sh(){ update_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
@ -316,91 +321,91 @@ command_install.sh
install_complete.sh(){ install_complete.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_config.sh(){ install_config.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_gsquery.sh(){ install_gsquery.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_gslt.sh(){ install_gslt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_header.sh(){ install_header.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_logs.sh(){ install_logs.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_retry.sh(){ install_retry.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_serverdir.sh(){ install_serverdir.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_serverfiles.sh(){ install_serverfiles.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_steamcmd.sh(){ install_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_ts3.sh(){ install_ts3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_ts3db.sh(){ install_ts3db.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_ut2k4.sh(){ install_ut2k4.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_dl_ut2k4.sh(){ install_dl_ut2k4.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_ut2k4_key.sh(){ install_ut2k4_key.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_ut99.sh(){ install_ut99.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
install_dl_ut99.sh(){ install_dl_ut99.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
fix_ut99.sh(){ fix_ut99.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_function
} }
# Calls on-screen messages # Calls on-screen messages

Loading…
Cancel
Save