Browse Source

Corrected curl paths

many curl references were not using curlpath
pull/1477/head
Daniel Gibbs 8 years ago
parent
commit
a98b72cb6f
  1. 2
      lgsm/functions/alert_pushbullet.sh
  2. 6
      lgsm/functions/command_postdetails.sh
  3. 19
      lgsm/functions/command_update_functions.sh
  4. 10
      lgsm/functions/core_dl.sh
  5. 79
      lgsm/functions/core_functions.sh
  6. 2
      lgsm/functions/update_factorio.sh
  7. 2
      lgsm/functions/update_minecraft.sh
  8. 2
      lgsm/functions/update_mumble.sh

2
lgsm/functions/alert_pushbullet.sh

@ -11,7 +11,7 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_print_dots "Sending Pushbullet alert"
sleep 1
pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d channel_tag="${channeltag}" -d type="note" -d body="${alertbody}" -d title="${alertsubject}" 'https://api.pushbullet.com/v2/pushes'|grep -o invalid_access_token|uniq)
pushbulletsend=$(${curlpath} --silent -u """${pushbullettoken}"":" -d channel_tag="${channeltag}" -d type="note" -d body="${alertbody}" -d title="${alertsubject}" 'https://api.pushbullet.com/v2/pushes'|grep -o invalid_access_token|uniq)
if [ "${pushbulletsend}" == "invalid_access_token" ]; then
fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token"

6
lgsm/functions/command_postdetails.sh

@ -112,12 +112,12 @@ if [ "${posttarget}" == "http://pastebin.com" ] ; then
fn_print_dots "Posting details to pastbin.com for ${postexpire}"
sleep 1
# grab the return from 'value' from an initial visit to pastebin.
csrftoken=$(curl -s "${posttarget}" |
csrftoken=$(${curlpath} -s "${posttarget}" |
sed -n 's/^.*input type="hidden" name="csrf_token_post" value="\(.*\)".*$/\1/p')
#
# Use the csrftoken to then post the content.
#
link=$(curl -s "${posttarget}/post.php" -D - -F "submit_hidden=submit_hidden" \
link=$(${curlpath} -s "${posttarget}/post.php" -D - -F "submit_hidden=submit_hidden" \
-F "post_key=${csrftoken}" -F "paste_expire_date=${postexpire}" \
-F "paste_name=${gamename} Debug Info" \
-F "paste_format=8" -F "paste_private=0" \
@ -133,7 +133,7 @@ elif [ "${posttarget}" == "https://hastebin.com" ] ; then
# hastebin is a bit simpler. If successful, the returned result
# should look like: {"something":"key"}, putting the reference that
# we need in "key". TODO - error handling. -CedarLUG
link=$(curl -H "HTTP_X_REQUESTED_WITH:XMLHttpRequest" -s -d "$(<${tmpfile})" "${posttarget}/documents" | cut -d\" -f4)
link=$(${curlpath} -H "HTTP_X_REQUESTED_WITH:XMLHttpRequest" -s -d "$(<${tmpfile})" "${posttarget}/documents" | cut -d\" -f4)
fn_print_ok_nl "Posting details to hastebin.com for ${postexpire}"
echo " Please share the following url for support: ${posttarget}/${link}"
else

19
lgsm/functions/command_update_functions.sh

@ -1,4 +1,4 @@
#!/bin/bash
aa#!/bin/bash
# LinuxGSM command_update_functions.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
@ -14,23 +14,6 @@ check.sh
fn_script_log_info "Updating functions"
echo -ne "\n"
# Removed legacy functions dir
if [ -n "${rootdir}" ]; then
if [ -d "${rootdir}/functions/" ]; then
rm -rfv "${rootdir}/functions/"
exitcode=$?
fi
fi
# 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 curlpath in ${curlpaths}
do
if [ -x "${curlpath}" ]; then
break
fi
done
echo -ne " checking _default.cfg...\c"
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${servername}/_default.cfg"))
if [ "${function_file_diff}" != "" ]; then

10
lgsm/functions/core_dl.sh

@ -236,3 +236,13 @@ fn_update_function(){
md5="nomd5"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
}
# Defines curl 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 curlpath in "${curlpaths}"
do
if [ -x "${curlpath}" ]; then
break
fi
done

79
lgsm/functions/core_functions.sh

@ -5,85 +5,6 @@
# 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 will not load.
# Fixes for legacy code
if [ "${gamename}" == "ARK: Survivial Evolved" ]; then
gamename="ARK: Survival Evolved"
elif [ "${gamename}" == "Teamspeak 3" ]; then
gamename="TeamSpeak 3"
elif [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
gamename="Counter-Strike: Global Offensive"
elif [ "${gamename}" == "Counter Strike: Source" ]; then
gamename="Counter-Strike: Source"
elif [ "${gamename}" == "Quake Live" ]; then
engine="idtech3_ql"
fi
if [ "${emailnotification}" == "on" ]; then
emailalert="on"
fi
## Code/functions for legacy servers
fn_functions(){
functionfile="${FUNCNAME}"
fn_fetch_function
}
fn_getopt(){
functionfile="${FUNCNAME}"
fn_fetch_function
}
## In case older versions are missing these vars
if [ -z "${lgsmdir}" ]||[ -z "${functionsdir}" ]||[ -z "${libdir}" ]||[ -z "${tmpdir}" ]; then
lgsmdir="${rootdir}/lgsm"
functionsdir="${lgsmdir}/functions"
libdir="${lgsmdir}/lib"
tmpdir="${lgsmdir}/tmp"
fi
## fn_fetch_core_dl placed here to allow legacy servers to still download core functions
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 curlpath in ${curlpaths}
do
if [ -x "${curlpath}" ]; then
break
fi
done
# If curl exists download file
if [ "$(basename ${curlpath})" == "curl" ]; then
curlcmd=$(${curlpath} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then
echo -e "${red}FAIL${default}\n"
echo "${curlcmd}"
echo -e "${githuburl}\n"
exit 1
else
echo -e "${green}OK${default}"
fi
else
echo -e "${red}FAIL${default}\n"
echo "Curl is not installed!"
echo -e ""
exit 1
fi
chmod +x "${filedir}/${filename}"
fi
source "${filedir}/${filename}"
}
# Creates tmp dir if missing
if [ ! -d "${tmpdir}" ]; then
mkdir -p "${tmpdir}"

2
lgsm/functions/update_factorio.sh

@ -76,7 +76,7 @@ fn_update_factorio_arch(){
fn_update_factorio_availablebuild(){
# Gets latest build info.
availablebuild=$(curl -s https://www.factorio.com/download-headless/stable | grep 'headless/linux64' | head -n 1 | grep -oP '(?<=get-download/).*?(?=/)')
availablebuild=$(${curlpath} -s https://www.factorio.com/download-headless/stable | grep 'headless/linux64' | head -n 1 | grep -oP '(?<=get-download/).*?(?=/)')
sleep 1
# Checks if availablebuild variable has been set

2
lgsm/functions/update_minecraft.sh

@ -69,7 +69,7 @@ fn_update_currentbuild(){
fn_update_availablebuild(){
# Gets latest build info.
availablebuild=$(curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | sed -e 's/^.*"release":"\([^"]*\)".*$/\1/')
availablebuild=$(${curlpath} -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | sed -e 's/^.*"release":"\([^"]*\)".*$/\1/')
sleep 1
# Checks if availablebuild variable has been set

2
lgsm/functions/update_mumble.sh

@ -76,7 +76,7 @@ fn_update_mumble_arch(){
fn_update_mumble_availablebuild(){
# Gets latest build info.
availablebuild=$(curl -s https://api.github.com/repos/mumble-voip/mumble/releases/latest | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
availablebuild=$(${curlpath} -s https://api.github.com/repos/mumble-voip/mumble/releases/latest | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
sleep 1
# Checks if availablebuild variable has been set

Loading…
Cancel
Save