Browse Source

turned in to functions

pull/743/head
Daniel Gibbs 9 years ago
parent
commit
ea45e1adc0
  1. 103
      functions/check_steamcmd.sh

103
functions/check_steamcmd.sh

@ -4,60 +4,69 @@
# Website: http://gameservermanagers.com # Website: http://gameservermanagers.com
lgsm_version="281215" lgsm_version="281215"
# Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD # Description: Checks SteamCMD is installed and correct.
if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then fn_install_steamcmd(){
: # These servers do not require SteamCMD. Check is skipped. echo "Installing steamCMD..."
else if [ ! -d "${steamcmddir}" ]; then
# Checks steamuser is setup. mkdir -v "${steamcmddir}"
if [ "${steamuser}" == "username" ]; then fi
fn_fetch_file "http://media.steampowered.com/client/steamcmd_linux.tar.gz" "${steamcmddir}" "steamcmd_linux.tar.gz"
tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
chmod +x "${steamcmddir}/steamcmd.sh"
}
fn_check_steamcmd_user(){
# Checks steamuser is setup.
if [ "${steamuser}" == "username" ]; then
fn_printfailnl "Steam login not set. Update steamuser." fn_printfailnl "Steam login not set. Update steamuser."
echo " * Change steamuser=\"username\" to a valid steam login." echo " * Change steamuser=\"username\" to a valid steam login."
if [ -d ${scriptlogdir} ]; then if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login." fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
exit 1 exit 1
fi fi
fi
# Anonymous user is set if steamuser is missing
if [ -z "${steamuser}" ]; then
fn_printwarnnl "Steam login not set. Using anonymous login."
if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "Steam login not set. Using anonymous login."
fi fi
if [ -z "${steamuser}" ]; then steamuser="anonymous"
fn_printwarnnl "Steam login not set. Using anonymous login." steampass=""
if [ -d "${scriptlogdir}" ]; then sleep 2
fn_scriptlog "Steam login not set. Using anonymous login." fi
fi }
steamuser="anonymous"
steampass="" fn_check_steamcmd_sh(){
sleep 2 # Checks if SteamCMD exists when starting or updating a server.
fi # Re-installs if missing.
# Checks if SteamCMD exists when starting or updating a server. steamcmddir="${rootdir}/steamcmd"
# Re-installs if missing. if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
steamcmddir="${rootdir}/steamcmd" fn_printwarnnl "SteamCMD is missing"
if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then fn_scriptlog "SteamCMD is missing"
fn_printwarnnl "SteamCMD is missing" sleep 1
fn_scriptlog "SteamCMD is missing" fn_install_steamcmd
sleep 1 fi
if [ ! -d "${steamcmddir}" ]; then }
mkdir -v "${steamcmddir}"
fi fn_check_steamcmd_guard(){
curl=$(curl --fail -o "${steamcmddir}/steamcmd_linux.tar.gz" "http://media.steampowered.com/client/steamcmd_linux.tar.gz" 2>&1) if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then
exitcode=$? # Checks that steamcmd is working correctly and will prompt Steam Guard if required.
echo -e "downloading steamcmd_linux.tar.gz...\c" "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
if [ $exitcode -eq 0 ]; then if [ $? -ne 0 ]; then
fn_printokeol fn_printfailurenl "Error running SteamCMD"
else
fn_printfaileol
echo "${curl}"
echo -e "${githuburl}\n"
exit $exitcode
fi
tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
chmod +x "${steamcmddir}/steamcmd.sh"
fi fi
if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then fi
# Checks that steamcmd is working correctly and will prompt Steam Guard if required. }
"${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
if [ $? -ne 0 ]; then if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
fn_printfailurenl "Error running SteamCMD" : # These servers do not require SteamCMD. Check is skipped.
fi else
fi fn_check_steamcmd_user
fn_check_steamcmd_sh
fn_check_steamcmd_guard
fi fi

Loading…
Cancel
Save