| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- #!/bin/bash
- # LGSM core_functions.sh function
- # Author: Daniel Gibbs
- # Website: https://gameservermanagers.com
- lgsm_version="210516"
- # 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(){
- # Functions are defined in core_functions.sh.
- functionfile="${FUNCNAME}"
- fn_fetch_core_dl
- }
- core_getopt.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_core_dl
- }
- core_messages.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_core_dl
- }
- core_dl.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_core_dl
- }
- # Command
- command_console.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_debug.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_details.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_test_alert.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_backup.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_monitor.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_start.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_stop.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_validate.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_install.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_fastdl.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_ts3_server_pass.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fn_restart(){
- local modulename="Restarting"
- info_config.sh
- if [ -d "${scriptlogdir}" ]; then
- fn_scriptlog "${servername}"
- fi
- command_stop.sh
- command_start.sh
- }
- # Checks
- check.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_config.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_deps.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_glibc.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_ip.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_logs.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_permissions.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_root.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_status.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_steamcmd.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_system_dir.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- check_tmux.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Compress
- compress_unreal2_maps.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- compress_ut99_maps.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Dev
- command_dev_debug.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_dev_detect_deps.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Fix
- fix.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_arma3.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_csgo.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_dst.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_ins.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_steamcmd.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_glibc.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_ro.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_kf.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_ut2k4.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Info
- info_config.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- info_distro.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- info_glibc.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- info_parms.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Alert
- alert.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- alert_email.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- alert_pushbullet.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Logs
- logs.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Monitor
- monitor_gsquery.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Update
- update_check.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- command_update_functions.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- update_dl.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fn_update_functions.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- #
- ## Installer functions
- #
- fn_autoinstall(){
- autoinstall=1
- command_install.sh
- }
- install_complete.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_config.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_gsquery.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_gslt.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_header.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_logs.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_retry.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_server_dir.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_server_files.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_steamcmd.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_ts3.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_ts3db.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_ut2k4.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_dl_ut2k4.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- install_ut2k4_key.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- fix_ut99.sh(){
- functionfile="${FUNCNAME}"
- fn_fetch_function
- }
- # Calls on-screen messages
- core_messages.sh
- #Calls file downloader
- core_dl.sh
|