Browse Source

code presentation

pull/820/merge
Daniel Gibbs 9 years ago
parent
commit
f373fe1201
  1. 140
      lgsm/functions/check_permissions.sh
  2. 490
      lgsm/functions/command_fastdl.sh
  3. 70
      lgsm/functions/command_ts3_server_pass.sh
  4. 48
      lgsm/functions/command_validate.sh
  5. 258
      lgsm/functions/core_dl.sh
  6. 200
      lgsm/functions/install_config.sh
  7. 8
      lgsm/functions/install_gsquery.sh
  8. 130
      lgsm/functions/install_server_files.sh
  9. 100
      lgsm/functions/update_dl.sh

140
lgsm/functions/check_permissions.sh

@ -14,84 +14,84 @@ scriptfullpath="${rootdir}/${selfname}"
conclusionpermissionerror="0"
fn_check_ownership(){
# Check script ownership
if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\""
echo " * To check the owner and allowed groups, run ls -l \"${selfname}\""
exit 1
fi
# Check script ownership
if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\""
echo " * To check the owner and allowed groups, run ls -l \"${selfname}\""
exit 1
fi
# Check rootdir ownership
if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${rootdir}\""
echo " * To check the owner and allowed groups, run ls -dl \"${rootdir}\""
exit 1
fi
# Check rootdir ownership
if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${rootdir}\""
echo " * To check the owner and allowed groups, run ls -dl \"${rootdir}\""
exit 1
fi
# Check functions ownership
funownfail="0"
if [ -n "${functionsdir}" ]; then
while read -r filename
do
if [ ! -O "${filename}" ] && [ ! -G "${filename}" ]; then
funownfail="1"
conclusionpermissionerror="1"
fi
done <<< "$(find "${functionsdir}" -name "*.sh")"
if [ "${funownfail}" == "1" ]; then
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own all scripts in \"${functionsdir}\""
echo " * To check the owner and allowed groups, run ls -l \"${functionsdir}\""
fi
fi
# Check functions ownership
funownfail="0"
if [ -n "${functionsdir}" ]; then
while read -r filename
do
if [ ! -O "${filename}" ] && [ ! -G "${filename}" ]; then
funownfail="1"
conclusionpermissionerror="1"
fi
done <<< "$(find "${functionsdir}" -name "*.sh")"
if [ "${funownfail}" == "1" ]; then
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own all scripts in \"${functionsdir}\""
echo " * To check the owner and allowed groups, run ls -l \"${functionsdir}\""
fi
fi
}
fn_check_permissions(){
# Check rootdir permissions
if [ -n "${rootdir}" ]; then
# Get permission numbers on folder under the form 775
rootdirperm="$(stat -c %a "${rootdir}")"
# Grab the first and second digit for user and group permission
userrootdirperm="${rootdirperm:0:1}"
grouprootdirperm="${rootdirperm:1:1}"
if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
fn_print_fail_nl "Oops ! Permission issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control of \"${rootdir}\""
echo " * You might wanna run : chmod -R 770 \"${rootdir}\""
conclusionpermissionerror="1"
fi
fi
# Check functions permissions
funcpermfail="0"
if [ -n "${functionsdir}" ]; then
while read -r filename
do
funcperm="$(stat -c %a "${filename}")"
userfuncdirperm="${funcperm:0:1}"
groupfuncdirperm="${funcperm:1:1}"
if [ "${userfuncdirperm}" != "7" ] && [ "${groupfuncdirperm}" != "7" ]; then
funcpermfail="1"
conclusionpermissionerror="1"
fi
done <<< "$(find "${functionsdir}" -name "*.sh")"
if [ "${funcpermfail}" == "1" ]; then
fn_print_fail_nl "Oops ! Permission issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control on scripts in \"${functionsdir}\""
echo " * You might wanna run : chmod -R 770 \"${functionsdir}\""
fi
fi
# Check rootdir permissions
if [ -n "${rootdir}" ]; then
# Get permission numbers on folder under the form 775
rootdirperm="$(stat -c %a "${rootdir}")"
# Grab the first and second digit for user and group permission
userrootdirperm="${rootdirperm:0:1}"
grouprootdirperm="${rootdirperm:1:1}"
if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
fn_print_fail_nl "Oops ! Permission issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control of \"${rootdir}\""
echo " * You might wanna run : chmod -R 770 \"${rootdir}\""
conclusionpermissionerror="1"
fi
fi
# Check functions permissions
funcpermfail="0"
if [ -n "${functionsdir}" ]; then
while read -r filename
do
funcperm="$(stat -c %a "${filename}")"
userfuncdirperm="${funcperm:0:1}"
groupfuncdirperm="${funcperm:1:1}"
if [ "${userfuncdirperm}" != "7" ] && [ "${groupfuncdirperm}" != "7" ]; then
funcpermfail="1"
conclusionpermissionerror="1"
fi
done <<< "$(find "${functionsdir}" -name "*.sh")"
if [ "${funcpermfail}" == "1" ]; then
fn_print_fail_nl "Oops ! Permission issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control on scripts in \"${functionsdir}\""
echo " * You might wanna run : chmod -R 770 \"${functionsdir}\""
fi
fi
}
fn_check_permissions_conclusion(){
# Exit if errors found
if [ "${conclusionpermissionerror}" == "1" ]; then
exit 1
fi
# Exit if errors found
if [ "${conclusionpermissionerror}" == "1" ]; then
exit 1
fi
}
fn_check_ownership

490
lgsm/functions/command_fastdl.sh

@ -22,301 +22,301 @@ luafastdlfile="lgsm_cl_force_fastdl.lua"
luafastdlfullpath="${luasvautorundir}/${luafastdlfile}"
fn_check_bzip2(){
# Returns true if not installed
if [ -z "$(command -v bzip2)" ]; then
bzip2installed="0"
fn_printinfo "bzip2 is not installed !"
fn_scriptlog "bzip2 is not installed"
echo -en "\n"
sleep 1
echo "We advise using it"
echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/FastDL#bzip2-compression"
sleep 2
else
bzip2installed="1"
fi
# Returns true if not installed
if [ -z "$(command -v bzip2)" ]; then
bzip2installed="0"
fn_printinfo "bzip2 is not installed !"
fn_scriptlog "bzip2 is not installed"
echo -en "\n"
sleep 1
echo "We advise using it"
echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/FastDL#bzip2-compression"
sleep 2
else
bzip2installed="1"
fi
}
fn_fastdl_init(){
# User confirmation
fn_printok "Welcome to LGSM's FastDL generator"
sleep 1
echo -en "\n"
fn_scriptlog "Started FastDL creation"
while true; do
read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fn_scriptlog "Initiating FastDL creation"
# Check and create folders
if [ ! -d "${webdir}" ]; then
echo ""
fn_printinfo "Creating FastDL directories"
echo -en "\n"
sleep 1
fn_printdots "Creating www directory"
sleep 0.5
mkdir "${webdir}"
fn_printok "Created www directory"
fn_scriptlog "FastDL created www directory"
sleep 1
echo -en "\n"
fi
if [ ! -d "${fastdldir}" ]; then
# No folder, won't ask for removing old ones
newfastdl=1
fn_printdots "Creating fastdl directory"
sleep 0.5
mkdir "${fastdldir}"
fn_printok "Created fastdl directory"
fn_scriptlog "FastDL created fastdl directory"
# User confirmation
fn_printok "Welcome to LGSM's FastDL generator"
sleep 1
echo -en "\n"
clearoldfastdl="off" # Nothing to clear
elif [ "$(ls -A "${fastdldir}")" ]; then
newfastdl=0
fi
}
fn_fastdl_config(){
# Global settings for FastDL creation
fn_printinfo "Entering configuration"
fn_scriptlog "Configuration"
sleep 2
echo -en "\n"
# Prompt for clearing old files if folder was already here
if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then
fn_printdots
fn_scriptlog "Started FastDL creation"
while true; do
read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn
read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in
[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_printok "Clearing Enabled"; break;;
[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_printok "Clearing Disabled"; break;;
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fn_scriptlog "Initiating FastDL creation"
# Check and create folders
if [ ! -d "${webdir}" ]; then
echo ""
fn_printinfo "Creating FastDL directories"
echo -en "\n"
sleep 1
fn_printdots "Creating www directory"
sleep 0.5
mkdir "${webdir}"
fn_printok "Created www directory"
fn_scriptlog "FastDL created www directory"
sleep 1
echo -en "\n"
fi
if [ ! -d "${fastdldir}" ]; then
# No folder, won't ask for removing old ones
newfastdl=1
fn_printdots "Creating fastdl directory"
sleep 0.5
mkdir "${fastdldir}"
fn_printok "Created fastdl directory"
fn_scriptlog "FastDL created fastdl directory"
sleep 1
echo -en "\n"
clearoldfastdl="off" # Nothing to clear
elif [ "$(ls -A "${fastdldir}")" ]; then
newfastdl=0
fi
}
fn_fastdl_config(){
# Global settings for FastDL creation
fn_printinfo "Entering configuration"
fn_scriptlog "Configuration"
sleep 2
echo -en "\n"
fi
# Prompt for using bzip2 if it's installed
if [ ${bzip2installed} == 1 ]; then
# Prompt for clearing old files if folder was already here
if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then
fn_printdots
while true; do
read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn
case $yn in
[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_printok "Clearing Enabled"; break;;
[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_printok "Clearing Disabled"; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -en "\n"
fi
# Prompt for using bzip2 if it's installed
if [ ${bzip2installed} == 1 ]; then
fn_printdots
while true; do
read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn
case $yn in
[Yy]* ) bzip2enable="on"; fn_scriptlog "bzip2 enabled"; fn_printok "bzip2 Enabled"; break;;
[Nn]* ) bzip2enable="off"; fn_scriptlog "bzip2 disabled"; fn_printok "bzip2 Disabled"; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -en "\n"
fi
}
fn_fastdl_gmod_config(){
# Prompt for download enforcer, that is using a .lua addfile resource generator
fn_printdots
while true; do
read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn
read -e -i "y" -p "Use client download enforcer? [Y/n]" yn
case $yn in
[Yy]* ) bzip2enable="on"; fn_scriptlog "bzip2 enabled"; fn_printok "bzip2 Enabled"; break;;
[Nn]* ) bzip2enable="off"; fn_scriptlog "bzip2 disabled"; fn_printok "bzip2 Disabled"; break;;
[Yy]* ) luaressource="on"; fn_scriptlog "DL enforcer Enabled"; fn_printok "Enforcer Enabled"; break;;
[Nn]* ) luaressource="off"; fn_scriptlog "DL enforcer Disabled"; fn_printok "Enforcer Disabled"; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -en "\n"
fi
}
fn_fastdl_gmod_config(){
# Prompt for download enforcer, that is using a .lua addfile resource generator
fn_printdots
while true; do
read -e -i "y" -p "Use client download enforcer? [Y/n]" yn
case $yn in
[Yy]* ) luaressource="on"; fn_scriptlog "DL enforcer Enabled"; fn_printok "Enforcer Enabled"; break;;
[Nn]* ) luaressource="off"; fn_scriptlog "DL enforcer Disabled"; fn_printok "Enforcer Disabled"; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -en "\n"
}
fn_clear_old_fastdl(){
# Clearing old FastDL if user answered yes
if [ "${clearoldfastdl}" == "on" ]; then
fn_printinfo "Clearing existing FastDL folder"
fn_scriptlog "Clearing existing FastDL folder"
sleep 0.5
rm -R "${fastdldir:?}"/*
fn_printok "Old FastDL folder cleared"
fn_scriptlog "Old FastDL folder cleared"
sleep 1
echo -en "\n"
fi
# Clearing old FastDL if user answered yes
if [ "${clearoldfastdl}" == "on" ]; then
fn_printinfo "Clearing existing FastDL folder"
fn_scriptlog "Clearing existing FastDL folder"
sleep 0.5
rm -R "${fastdldir:?}"/*
fn_printok "Old FastDL folder cleared"
fn_scriptlog "Old FastDL folder cleared"
sleep 1
echo -en "\n"
fi
}
fn_gmod_fastdl(){
# Copy all needed files for FastDL
echo ""
fn_printdots "Starting gathering all needed files"
fn_scriptlog "Starting gathering all needed files"
sleep 1
echo -en "\n"
# No choice to cd to the directory, as find can't then display relative folder
cd "${systemdir}"
# Map Files
fn_printdots "Copying map files..."
fn_scriptlog "Copying map files"
sleep 0.5
find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
fn_printok "Map files copied"
sleep 0.5
echo -en "\n"
# Copy all needed files for FastDL
echo ""
fn_printdots "Starting gathering all needed files"
fn_scriptlog "Starting gathering all needed files"
sleep 1
echo -en "\n"
# Materials
fn_printdots "Copying materials..."
fn_scriptlog "Copying materials"
sleep 0.5
find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
fn_printok "Materials copied"
sleep 0.5
echo -en "\n"
# No choice to cd to the directory, as find can't then display relative folder
cd "${systemdir}"
# Models
fn_printdots "Copying models..."
fn_scriptlog "Copying models"
sleep 1
find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
find . -name '*.mdl' | cpio --quiet -updm "${fastdldir}"
find . -name '*.phy' | cpio --quiet -updm "${fastdldir}"
fn_printok "Models copied"
sleep 0.5
echo -en "\n"
# Map Files
fn_printdots "Copying map files..."
fn_scriptlog "Copying map files"
sleep 0.5
find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
fn_printok "Map files copied"
sleep 0.5
echo -en "\n"
# Particles
fn_printdots "Copying particles..."
fn_scriptlog "Copying particles"
sleep 0.5
find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
fn_printok "Particles copied"
sleep 0.5
echo -en "\n"
# Materials
fn_printdots "Copying materials..."
fn_scriptlog "Copying materials"
sleep 0.5
find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
fn_printok "Materials copied"
sleep 0.5
echo -en "\n"
# Sounds
fn_printdots "Copying sounds..."
fn_scriptlog "Copying sounds"
sleep 0.5
find . -name '*.wav' | cpio --quiet -updm "${fastdldir}"
find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ogg' | cpio --quiet -updm "${fastdldir}"
fn_printok "Sounds copied"
sleep 0.5
echo -en "\n"
# Models
fn_printdots "Copying models..."
fn_scriptlog "Copying models"
sleep 1
find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
find . -name '*.mdl' | cpio --quiet -updm "${fastdldir}"
find . -name '*.phy' | cpio --quiet -updm "${fastdldir}"
fn_printok "Models copied"
sleep 0.5
echo -en "\n"
# Resources (mostly fonts)
fn_printdots "Copying fonts and png..."
fn_scriptlog "Copying fonts and png"
sleep 1
find . -name '*.otf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.png' | cpio --quiet -updm "${fastdldir}"
fn_printok "Fonts and png copied"
sleep 0.5
echo -en "\n"
# Particles
fn_printdots "Copying particles..."
fn_scriptlog "Copying particles"
sleep 0.5
find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
fn_printok "Particles copied"
sleep 0.5
echo -en "\n"
# Going back to rootdir in order to prevent mistakes
cd "${rootdir}"
# Sounds
fn_printdots "Copying sounds..."
fn_scriptlog "Copying sounds"
sleep 0.5
find . -name '*.wav' | cpio --quiet -updm "${fastdldir}"
find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ogg' | cpio --quiet -updm "${fastdldir}"
fn_printok "Sounds copied"
sleep 0.5
echo -en "\n"
# Correct addons folder structure for FastDL
if [ -d "${fastdldir}/addons" ]; then
fn_printinfo "Adjusting addons' file structure"
fn_scriptlog "Adjusting addon's file structure"
sleep 1
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
#Don't remove yet rm -R "${fastdldir:?}/addons"
fn_printok "Adjusted addon's file structure"
# Resources (mostly fonts)
fn_printdots "Copying fonts and png..."
fn_scriptlog "Copying fonts and png"
sleep 1
find . -name '*.otf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.png' | cpio --quiet -updm "${fastdldir}"
fn_printok "Fonts and png copied"
sleep 0.5
echo -en "\n"
fi
# Correct content that may be into a lua folder by mistake like some darkrpmodification addons
if [ -d "${fastdldir}/lua" ]; then
fn_printdots "Typical DarkRP shit detected, fixing"
sleep 2
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
fn_printok "Stupid DarkRP file structure fixed"
sleep 2
echo -en "\n"
fi
# Going back to rootdir in order to prevent mistakes
cd "${rootdir}"
# Correct addons folder structure for FastDL
if [ -d "${fastdldir}/addons" ]; then
fn_printinfo "Adjusting addons' file structure"
fn_scriptlog "Adjusting addon's file structure"
sleep 1
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
#Don't remove yet rm -R "${fastdldir:?}/addons"
fn_printok "Adjusted addon's file structure"
sleep 1
echo -en "\n"
fi
# Correct content that may be into a lua folder by mistake like some darkrpmodification addons
if [ -d "${fastdldir}/lua" ]; then
fn_printdots "Typical DarkRP shit detected, fixing"
sleep 2
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
fn_printok "Stupid DarkRP file structure fixed"
sleep 2
echo -en "\n"
fi
}
# Generate lua file that will force download any file into the FastDL folder
fn_lua_fastdl(){
# Remove lua file if luaressource is turned off and file exists
echo ""
if [ "${luaressource}" == "off" ]; then
if [ -f "${luafastdlfullpath}" ]; then
fn_printdots "Removing download enforcer"
# Remove lua file if luaressource is turned off and file exists
echo ""
if [ "${luaressource}" == "off" ]; then
if [ -f "${luafastdlfullpath}" ]; then
fn_printdots "Removing download enforcer"
sleep 1
rm -R "${luafastdlfullpath:?}"
fn_printok "Removed download enforcer"
fn_scriptlog "Removed old download inforcer"
echo -en "\n"
sleep 2
fi
fi
# Remove old lua file and generate a new one if user said yes
if [ "${luaressource}" == "on" ]; then
if [ -f "${luafastdlfullpath}" ]; then
fn_printdots "Removing old download enforcer"
sleep 1
rm "${luafastdlfullpath}"
fn_printok "Removed old download enforcer"
fn_scriptlog "Removed old download enforcer"
echo -en "\n"
sleep 1
fi
fn_printdots "Generating new download enforcer"
fn_scriptlog "Generating new download enforcer"
sleep 1
rm -R "${luafastdlfullpath:?}"
fn_printok "Removed download enforcer"
fn_scriptlog "Removed old download inforcer"
# Read all filenames and put them into a lua file at the right path
find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do
echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath}
done
fn_printok "Download enforcer generated"
fn_scriptlog "Download enforcer generated"
echo -en "\n"
echo ""
sleep 2
fi
fi
# Remove old lua file and generate a new one if user said yes
if [ "${luaressource}" == "on" ]; then
if [ -f "${luafastdlfullpath}" ]; then
fn_printdots "Removing old download enforcer"
sleep 1
rm "${luafastdlfullpath}"
fn_printok "Removed old download enforcer"
fn_scriptlog "Removed old download enforcer"
}
fn_fastdl_bzip2(){
# Compressing using bzip2 if user said yes
echo ""
if [ ${bzip2enable} == "on" ]; then
fn_printinfo "Have a break, this step could take a while..."
echo -en "\n"
echo ""
fn_printdots "Compressing files using bzip2..."
fn_scriptlog "Compressing files using bzip2..."
# bzip2 all files that are not already compressed (keeping original files)
find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \;
fn_printok "bzip2 compression done"
fn_scriptlog "bzip2 compression done"
sleep 1
echo -en "\n"
fi
fn_printdots "Generating new download enforcer"
fn_scriptlog "Generating new download enforcer"
sleep 1
# Read all filenames and put them into a lua file at the right path
find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do
echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath}
done
fn_printok "Download enforcer generated"
fn_scriptlog "Download enforcer generated"
echo -en "\n"
echo ""
sleep 2
fi
}
fn_fastdl_bzip2(){
# Compressing using bzip2 if user said yes
echo ""
if [ ${bzip2enable} == "on" ]; then
fn_printinfo "Have a break, this step could take a while..."
fn_fastdl_completed(){
# Finished message
echo ""
fn_printok "Congratulations, it's done !"
fn_scriptlog "FastDL job done"
sleep 2
echo -en "\n"
echo ""
fn_printdots "Compressing files using bzip2..."
fn_scriptlog "Compressing files using bzip2..."
# bzip2 all files that are not already compressed (keeping original files)
find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \;
fn_printok "bzip2 compression done"
fn_scriptlog "bzip2 compression done"
sleep 1
fn_printinfo "Need more doc ? See https://github.com/dgibbs64/linuxgsm/wiki/FastDL"
echo -en "\n"
fi
}
fn_fastdl_completed(){
# Finished message
echo ""
fn_printok "Congratulations, it's done !"
fn_scriptlog "FastDL job done"
sleep 2
echo -en "\n"
echo ""
fn_printinfo "Need more doc ? See https://github.com/dgibbs64/linuxgsm/wiki/FastDL"
echo -en "\n"
if [ "$bzip2installed" == "0" ]; then
echo "By the way, you'd better install bzip2 an re-run this command !"
fi
echo "Credits : UltimateByte"
if [ "$bzip2installed" == "0" ]; then
echo "By the way, you'd better install bzip2 an re-run this command !"
fi
echo "Credits : UltimateByte"
}
# Game checking and functions running

70
lgsm/functions/command_ts3_server_pass.sh

@ -12,43 +12,43 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_serveradmin_password_prompt(){
echo ""
echo "${gamename} ServerAdmin Password Change"
echo "================================="
echo ""
echo "Press \"CTRL+b d\" to exit console."
fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password."
fn_print_warning_nl "${gamename} will restart during this process."
echo ""
while true; do
read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) echo Exiting; exit;;
* ) echo "Please answer yes or no.";;
esac
done
fn_scriptlog "Initiating ${gamename} ServerAdmin password change"
read -p "Enter new password : " newpassword
}
echo ""
echo "${gamename} ServerAdmin Password Change"
echo "================================="
echo ""
echo "Press \"CTRL+b d\" to exit console."
fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password."
fn_print_warning_nl "${gamename} will restart during this process."
echo ""
while true; do
read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) echo Exiting; exit;;
* ) echo "Please answer yes or no.";;
esac
done
fn_scriptlog "Initiating ${gamename} ServerAdmin password change"
read -p "Enter new password : " newpassword
}
fn_serveradmin_password_set(){
fn_print_info_nl "Applying new password"
fn_scriptlog "Applying new password"
sleep 1
# Stop any running server
command_stop.sh
# Start server in "new password mode"
ts3serverpass="1"
fn_print_info_nl "Starting server with new password"
command_start.sh
# Stop server in "new password mode"
command_stop.sh
ts3serverpass="0"
fn_print_ok_nl "Password applied"
fn_scriptlog "New ServerAdmin password applied"
sleep 1
fn_serveradmin_password_set(){
fn_print_info_nl "Applying new password"
fn_scriptlog "Applying new password"
sleep 1
# Stop any running server
command_stop.sh
# Start server in "new password mode"
ts3serverpass="1"
fn_print_info_nl "Starting server with new password"
command_start.sh
# Stop server in "new password mode"
command_stop.sh
ts3serverpass="0"
fn_print_ok_nl "Password applied"
fn_scriptlog "New ServerAdmin password applied"
sleep 1
}
# Running functions

48
lgsm/functions/command_validate.sh

@ -10,30 +10,30 @@ local modulename="Validate"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_validation(){
fn_print_warn_nl "Validating may overwrite some customised files."
echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
sleep 5
echo -en "\n"
fn_print_dots "Checking server files"
sleep 1
fn_print_ok "Checking server files"
fn_scriptlog "Checking server files"
sleep 1
cd "${rootdir}/steamcmd"
if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer
fi
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
fi
fix.sh
fn_scriptlog "Checking complete"
fn_print_warn_nl "Validating may overwrite some customised files."
echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
sleep 5
echo -en "\n"
fn_print_dots "Checking server files"
sleep 1
fn_print_ok "Checking server files"
fn_scriptlog "Checking server files"
sleep 1
cd "${rootdir}/steamcmd"
if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer
fi
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
fi
fix.sh
fn_scriptlog "Checking complete"
}
check_status.sh

258
lgsm/functions/core_dl.sh

@ -19,26 +19,26 @@ lgsm_version="050216"
# fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd"
fn_dl_md5(){
# Runs MD5 Check if available
if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then
echo -ne "verifying ${filename} with MD5..."
sleep 1
local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}')
if [ "${md5sumcmd}" != "${md5}" ]; then
fn_print_fail_eol_nl
echo "${filename} returned MD5 checksum: ${md5sumcmd}"
echo "expected MD5 checksum: ${md5}"
fn_scriptlog "verifying ${filename} with MD5: FAIL"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}"
exit 1
else
fn_print_ok_eol_nl
fn_scriptlog "verifying ${filename} with MD5: OK"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}"
fi
fi
# Runs MD5 Check if available
if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then
echo -ne "verifying ${filename} with MD5..."
sleep 1
local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}')
if [ "${md5sumcmd}" != "${md5}" ]; then
fn_print_fail_eol_nl
echo "${filename} returned MD5 checksum: ${md5sumcmd}"
echo "expected MD5 checksum: ${md5}"
fn_scriptlog "verifying ${filename} with MD5: FAIL"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}"
exit 1
else
fn_print_ok_eol_nl
fn_scriptlog "verifying ${filename} with MD5: OK"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}"
fi
fi
}
# Extracts bzip2 or gzip files
@ -46,28 +46,28 @@ fi
# fn_dl_extract "${filedir}" "${filename}" "${extractdir}"
# fn_dl_extract "/home/gameserver/lgsm/tmp" "file.tar.bz2" "/home/gamserver/serverfiles"
fn_dl_extract(){
filedir="${1}"
filename="${2}"
extractdir="${3}"
# extracts archives
echo -ne "extracting ${filename}..."
fn_scriptlog "extracting download"
mime=$(file -b --mime-type "${filedir}/${filename}")
if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then
tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}")
elif [ "${mime}" == "application/x-bzip2" ]; then
tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}")
fi
local exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl
fn_scriptlog "extracting download: FAIL"
echo "${tarcmd}" | tee -a "${scriptlog}"
exit ${exitcode}
else
fn_print_ok_eol_nl
fi
filedir="${1}"
filename="${2}"
extractdir="${3}"
# extracts archives
echo -ne "extracting ${filename}..."
fn_scriptlog "extracting download"
mime=$(file -b --mime-type "${filedir}/${filename}")
if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then
tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}")
elif [ "${mime}" == "application/x-bzip2" ]; then
tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}")
fi
local exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl
fn_scriptlog "extracting download: FAIL"
echo "${tarcmd}" | tee -a "${scriptlog}"
exit ${exitcode}
else
fn_print_ok_eol_nl
fi
}
# Trap to remove file download if canceled before completed
@ -85,78 +85,78 @@ fn_fetch_trap() {
}
fn_fetch_file(){
fileurl="${1}"
filedir="${2}"
filename="${3}"
executecmd="${4:-0}"
run="${5:-0}"
force="${6:-0}"
md5="${7:-0}"
# If the file is missing, then download
if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then
mkdir -p "${filedir}"
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 curlcmd in ${curlpaths}
do
if [ -x "${curlcmd}" ]; then
break
fileurl="${1}"
filedir="${2}"
filename="${3}"
executecmd="${4:-0}"
run="${5:-0}"
force="${6:-0}"
md5="${7:-0}"
# If the file is missing, then download
if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then
mkdir -p "${filedir}"
fi
done
# If curl exists download file
if [ "$(basename ${curlcmd})" == "curl" ]; then
# trap to remove part downloaded files
trap fn_fetch_trap INT
# if larger file shows progress bar
if [ ${filename##*.} == "bz2" ]; then
echo -ne "downloading ${filename}..."
sleep 1
curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}")
echo -ne "downloading ${filename}..."
# 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
# trap to remove part downloaded files
trap fn_fetch_trap INT
# if larger file shows progress bar
if [ ${filename##*.} == "bz2" ]; then
echo -ne "downloading ${filename}..."
sleep 1
curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}")
echo -ne "downloading ${filename}..."
else
echo -ne " fetching ${filename}...\c"
curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1)
fi
local exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl
if [ -f "${scriptlog}" ]; then
fn_scriptlog "downloading ${filename}: FAIL"
fi
echo "${curlcmd}" | tee -a "${scriptlog}"
echo -e "${fileurl}\n" | tee -a "${scriptlog}"
exit ${exitcode}
else
fn_print_ok_eol_nl
if [ -f "${scriptlog}" ]; then
fn_scriptlog "downloading ${filename}: OK"
fi
fi
# remove trap
trap - INT
else
echo -ne " fetching ${filename}...\c"
curlcmd=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${fileurl}" 2>&1)
fi
local exitcode=$?
if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl
if [ -f "${scriptlog}" ]; then
fn_scriptlog "downloading ${filename}: FAIL"
fi
echo "${curlcmd}" | tee -a "${scriptlog}"
echo -e "${fileurl}\n" | tee -a "${scriptlog}"
exit ${exitcode}
else
fn_print_ok_eol_nl
if [ -f "${scriptlog}" ]; then
fn_scriptlog "downloading ${filename}: OK"
fi
echo "Curl is not installed!"
echo -e ""
exit 1
fi
# remove trap
trap - INT
else
fn_print_fail_eol_nl
echo "Curl is not installed!"
echo -e ""
exit 1
# make file executecmd if executecmd is set
if [ "${executecmd}" == "executecmd" ]; then
chmod +x "${filedir}/${filename}"
fi
fi
# make file executecmd if executecmd is set
if [ "${executecmd}" == "executecmd" ]; then
chmod +x "${filedir}/${filename}"
fi
fi
if [ -f "${filedir}/${filename}" ]; then
fn_dl_md5
# run file if run is set
if [ "${run}" == "run" ]; then
source "${filedir}/${filename}"
if [ -f "${filedir}/${filename}" ]; then
fn_dl_md5
# run file if run is set
if [ "${run}" == "run" ]; then
source "${filedir}/${filename}"
fi
fi
fi
}
@ -172,31 +172,31 @@ fi
# Fetches files from the github repo
fn_fetch_file_github(){
github_file_url_dir="${1}"
github_file_url_name="${2}"
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
fileurl="${githuburl}"
filedir="${3}"
filename="${github_file_url_name}"
executecmd="${4:-0}"
run="${5:-0}"
force="${6:-0}"
md5="${7:-0}"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
github_file_url_dir="${1}"
github_file_url_name="${2}"
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
fileurl="${githuburl}"
filedir="${3}"
filename="${github_file_url_name}"
executecmd="${4:-0}"
run="${5:-0}"
force="${6:-0}"
md5="${7:-0}"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
}
# Fetches functions
fn_fetch_function(){
github_file_url_dir="lgsm/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}"
fileurl="${githuburl}"
filedir="${functionsdir}"
filename="${github_file_url_name}"
executecmd="executecmd"
run="run"
force="noforce"
md5="nomd5"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
github_file_url_dir="lgsm/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}"
fileurl="${githuburl}"
filedir="${functionsdir}"
filename="${github_file_url_name}"
executecmd="executecmd"
run="run"
force="noforce"
md5="nomd5"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
}

200
lgsm/functions/install_config.sh

@ -13,133 +13,133 @@ fn_defaultconfig(){
}
fn_userinputconfig(){
# allow user to input server name and password
if [ -z "${autoinstall}" ]; then
echo ""
echo "Configuring ${gamename} Server"
echo "================================="
sleep 1
read -p "Enter server name: " servername
read -p "Enter rcon password: " rconpass
else
servername="${servicename}"
rconpass="rconpassword"
fi
echo "changing hostname."
sed -i "s/\"<hostname>\"/\"${servername}\"/g" "${servercfgfullpath}"
sleep 1
echo "changing rconpassword."
sed -i "s/\"<rconpassword>\"/\"${rconpass}\"/g" "${servercfgfullpath}"
sleep 1
}
# allow user to input server name and password
if [ -z "${autoinstall}" ]; then
echo ""
echo "Configuring ${gamename} Server"
echo "================================="
sleep 1
read -p "Enter server name: " servername
read -p "Enter rcon password: " rconpass
else
servername="${servicename}"
rconpass="rconpassword"
fi
echo "changing hostname."
sed -i "s/\"<hostname>\"/\"${servername}\"/g" "${servercfgfullpath}"
sleep 1
echo "changing rconpassword."
sed -i "s/\"<rconpassword>\"/\"${rconpass}\"/g" "${servercfgfullpath}"
sleep 1
}
fn_arma3config(){
fn_defaultconfig
echo "creating ${networkcfg} config file."
cp -v "${networkcfgdefault}" "${networkcfgfullpath}"
sleep 1
echo ""
fn_arma3config(){
fn_defaultconfig
echo "creating ${networkcfg} config file."
cp -v "${networkcfgdefault}" "${networkcfgfullpath}"
sleep 1
echo ""
}
fn_goldsourceconfig(){
fn_defaultconfig
fn_defaultconfig
# server.cfg redirects to ${servercfg} for added security
echo "creating server.cfg."
touch "server.cfg"
sleep 1
echo "creating redirect."
echo "server.cfg > ${servercfg}."
echo "exec ${servercfg}" > "server.cfg"
sleep 1
# server.cfg redirects to ${servercfg} for added security
echo "creating server.cfg."
touch "server.cfg"
sleep 1
echo "creating redirect."
echo "server.cfg > ${servercfg}."
echo "exec ${servercfg}" > "server.cfg"
sleep 1
# creating other files required
echo "creating listip.cfg."
touch "${systemdir}/listip.cfg"
sleep 1
echo "creating banned.cfg."
touch "${systemdir}/banned.cfg"
sleep 1
# creating other files required
echo "creating listip.cfg."
touch "${systemdir}/listip.cfg"
sleep 1
echo "creating banned.cfg."
touch "${systemdir}/banned.cfg"
sleep 1
fn_userinputconfig
echo ""
fn_userinputconfig
echo ""
}
fn_serious3config(){
fn_defaultconfig
echo ""
echo "To edit ${gamename} server config use SS3 Server GUI 3 tool"
echo "http://mrag.nl/sgui3/"
sleep 1
echo ""
fn_defaultconfig
echo ""
echo "To edit ${gamename} server config use SS3 Server GUI 3 tool"
echo "http://mrag.nl/sgui3/"
sleep 1
echo ""
}
fn_sourceconfig(){
fn_defaultconfig
fn_defaultconfig
# server.cfg redirects to ${servercfg} for added security
echo "creating server.cfg."
touch "server.cfg"
sleep 1
echo "creating redirect."
echo "server.cfg > ${servercfg}."
echo "exec ${servercfg}" > "server.cfg"
sleep 1
# server.cfg redirects to ${servercfg} for added security
echo "creating server.cfg."
touch "server.cfg"
sleep 1
echo "creating redirect."
echo "server.cfg > ${servercfg}."
echo "exec ${servercfg}" > "server.cfg"
sleep 1
fn_userinputconfig
echo ""
fn_userinputconfig
echo ""
}
fn_teeworldsconfig(){
fn_defaultconfig
fn_defaultconfig
echo "adding logfile location to config."
sed -i "s@\"<logfile>\"@\"${gamelog}\"@g" "${servercfgfullpath}"
sleep 1
echo "removing password holder."
sed -i "s/<password>//" "${servercfgfullpath}"
sleep 1
echo "adding logfile location to config."
sed -i "s@\"<logfile>\"@\"${gamelog}\"@g" "${servercfgfullpath}"
sleep 1
echo "removing password holder."
sed -i "s/<password>//" "${servercfgfullpath}"
sleep 1
fn_userinputconfig
echo ""
fn_userinputconfig
echo ""
}
fn_ut99config(){
echo "${servercfgdefault} > ${servercfgfullpath}"
tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}"
sleep 1
echo ""
echo "Configuring ${gamename} Server"
echo "================================="
sleep 1
echo "enabling WebAdmin."
sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
sleep 1
echo "setting WebAdmin port to 8076."
sed -i '467i\ListenPort=8076' "${servercfgfullpath}"
sleep 1
echo ""
echo "${servercfgdefault} > ${servercfgfullpath}"
tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}"
sleep 1
echo ""
echo "Configuring ${gamename} Server"
echo "================================="
sleep 1
echo "enabling WebAdmin."
sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
sleep 1
echo "setting WebAdmin port to 8076."
sed -i '467i\ListenPort=8076' "${servercfgfullpath}"
sleep 1
echo ""
}
fn_unreal2config(){
fn_defaultconfig
echo ""
echo "Configuring ${gamename} Server"
echo "================================="
sleep 1
echo "setting WebAdmin username and password."
sed -i 's/AdminName=/AdminName=admin/g' "${servercfgfullpath}"
sed -i 's/AdminPassword=/AdminPassword=admin/g' "${servercfgfullpath}"
sleep 1
echo "enabling WebAdmin."
sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
if [ "${gamename}" == "Unreal Tournament 2004" ]; then
fn_defaultconfig
echo ""
echo "Configuring ${gamename} Server"
echo "================================="
sleep 1
echo "setting WebAdmin port to 8075."
sed -i 's/ListenPort=80/ListenPort=8075/g' "${servercfgfullpath}"
fi
sleep 1
echo ""
echo "setting WebAdmin username and password."
sed -i 's/AdminName=/AdminName=admin/g' "${servercfgfullpath}"
sed -i 's/AdminPassword=/AdminPassword=admin/g' "${servercfgfullpath}"
sleep 1
echo "enabling WebAdmin."
sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
if [ "${gamename}" == "Unreal Tournament 2004" ]; then
sleep 1
echo "setting WebAdmin port to 8075."
sed -i 's/ListenPort=80/ListenPort=8075/g' "${servercfgfullpath}"
fi
sleep 1
echo ""
}
echo ""

8
lgsm/functions/install_gsquery.sh

@ -5,10 +5,10 @@
lgsm_version="190216"
fn_dlgsquery(){
cd "${rootdir}"
echo -e "downloading gsquery.py...\c"
wget -N /dev/null "https://gameservermanagers.com/dl/gsquery.py" 2>&1 | grep -F "HTTP" | grep -v "Moved Permanently" | cut -c45- | uniq
chmod +x gsquery.py
cd "${rootdir}"
echo -e "downloading gsquery.py...\c"
wget -N /dev/null "https://gameservermanagers.com/dl/gsquery.py" 2>&1 | grep -F "HTTP" | grep -v "Moved Permanently" | cut -c45- | uniq
chmod +x gsquery.py
}
if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "idtech3" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${gamename}" == "Hurtworld" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then

130
lgsm/functions/install_server_files.sh

@ -7,81 +7,81 @@ lgsm_version="270216"
local modulename="Install"
fn_install_server_files(){
if [ "${gamename}" == "Unreal Tournament 99" ]; then
fileurl="https://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="49cb24d0550ff6ddeaba6007045c6edd"
elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
fileurl="https://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="67c5e2cd9c2a4b04f163962ee41eff54"
fi
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
if [ "${gamename}" == "Unreal Tournament 99" ]; then
fileurl="https://gameservermanagers.com/files/UnrealTournament99/ut99-server-451-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut99-server-451-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="49cb24d0550ff6ddeaba6007045c6edd"
elif [ "${gamename}" == "Unreal Tournament 2004" ]; then
fileurl="https://gameservermanagers.com/files/UnrealTournament2004/ut2004-server-3339-ultimate-linux.tar.bz2"; filedir="${lgsmdir}/tmp"; filename="ut2004-server-3339-ultimate-linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="67c5e2cd9c2a4b04f163962ee41eff54"
fi
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
}
fn_install_server_files_steamcmd(){
counter="0"
while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
counter=$((counter+1))
cd "${rootdir}/steamcmd"
if [ "${counter}" -le "10" ]; then
# Attempt 1-4: Standard attempt
# Attempt 5-6: Validate attempt
# Attempt 7-8: Validate, delete long name dir
# Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
# Attempt 11: Failure
if [ "${counter}" -ge "2" ]; then
fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fi
counter="0"
while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
counter=$((counter+1))
cd "${rootdir}/steamcmd"
if [ "${counter}" -le "10" ]; then
# Attempt 1-4: Standard attempt
# Attempt 5-6: Validate attempt
# Attempt 7-8: Validate, delete long name dir
# Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
# Attempt 11: Failure
if [ "${counter}" -ge "7" ]; then
echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
fi
if [ "${counter}" -ge "9" ]; then
rm -rf "${rootdir}/steamcmd"
check_steamcmd.sh
fi
if [ "${counter}" -ge "2" ]; then
fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fi
# Detects if unbuffer command is available.
if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer
fi
if [ "${counter}" -ge "7" ]; then
echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
fi
if [ "${counter}" -ge "9" ]; then
rm -rf "${rootdir}/steamcmd"
check_steamcmd.sh
fi
if [ "${counter}" -le "4" ]; then
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit
local exitcode=$?
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
local exitcode=$?
# Detects if unbuffer command is available.
if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer
fi
elif [ "${counter}" -ge "5" ]; then
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit
local exitcode=$?
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit
local exitcode=$?
if [ "${counter}" -le "4" ]; then
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit
local exitcode=$?
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
local exitcode=$?
fi
elif [ "${counter}" -ge "5" ]; then
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit
local exitcode=$?
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit
local exitcode=$?
fi
fi
elif [ "${counter}" -ge "11" ]; then
fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
fn_scriptlog "SteamCMD did not complete the download, too many retrys"
break
fi
elif [ "${counter}" -ge "11" ]; then
fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
fn_scriptlog "SteamCMD did not complete the download, too many retrys"
break
fi
done
# Goldsource servers commonly fail to download all the server files required.
# Validating a few of times may reduce the chance of this issue.
if [ "${engine}" == "goldsource" ]; then
fn_print_infomation_nl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue."
counter="0"
while [ "${counter}" -le "4" ]; do
counter=$((counter+1))
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit
local exitcode=$?
done
fi
# Goldsource servers commonly fail to download all the server files required.
# Validating a few of times may reduce the chance of this issue.
if [ "${engine}" == "goldsource" ]; then
fn_print_infomation_nl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue."
counter="0"
while [ "${counter}" -le "4" ]; do
counter=$((counter+1))
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" -validate +quit
local exitcode=$?
done
fi
}
echo ""

100
lgsm/functions/update_dl.sh

@ -10,63 +10,63 @@ local modulename="Update"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_steamcmd_dl(){
cd "${rootdir}"
cd "steamcmd"
cd "${rootdir}"
cd "steamcmd"
# Detects if unbuffer command is available.
if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer
fi
# Detects if unbuffer command is available.
if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer
fi
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit| tee -a "${scriptlog}"
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit| tee -a "${scriptlog}"
fi
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit| tee -a "${scriptlog}"
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit| tee -a "${scriptlog}"
fi
fix.sh
fix.sh
}
fn_teamspeak3_dl(){
cd "${rootdir}"
echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
fn_scriptlog "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
sleep 1
echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
fn_scriptlog "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
fn_scriptlog "Failed to extract - Exit status ${status}"
cd "${rootdir}"
echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
fn_scriptlog "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
sleep 1
cat "${scriptlogdir}/.${servicename}-tar-error.tmp"
cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}"
rm "${scriptlogdir}/.${servicename}-tar-error.tmp"
fn_scriptlog "Failure! Unable to update"
exit ${status}
fi
echo -e "copying to ${filesdir}...\c"
fn_scriptlog "Copying to ${filesdir}"
cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
fn_scriptlog "Failed to copy - Exit status ${status}"
sleep 1
cat "${scriptlogdir}/.${servicename}-cp-error.tmp"
cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}"
rm "${scriptlogdir}/.${servicename}-cp-error.tmp"
fn_scriptlog "Failure! Unable to update"
exit ${status}
fi
rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"
echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
fn_scriptlog "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
fn_scriptlog "Failed to extract - Exit status ${status}"
sleep 1
cat "${scriptlogdir}/.${servicename}-tar-error.tmp"
cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}"
rm "${scriptlogdir}/.${servicename}-tar-error.tmp"
fn_scriptlog "Failure! Unable to update"
exit ${status}
fi
echo -e "copying to ${filesdir}...\c"
fn_scriptlog "Copying to ${filesdir}"
cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
fn_scriptlog "Failed to copy - Exit status ${status}"
sleep 1
cat "${scriptlogdir}/.${servicename}-cp-error.tmp"
cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}"
rm "${scriptlogdir}/.${servicename}-cp-error.tmp"
fn_scriptlog "Failure! Unable to update"
exit ${status}
fi
rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"
}
check.sh

Loading…
Cancel
Save