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

490
lgsm/functions/command_fastdl.sh

@ -22,301 +22,301 @@ luafastdlfile="lgsm_cl_force_fastdl.lua"
luafastdlfullpath="${luasvautorundir}/${luafastdlfile}" luafastdlfullpath="${luasvautorundir}/${luafastdlfile}"
fn_check_bzip2(){ fn_check_bzip2(){
# Returns true if not installed # Returns true if not installed
if [ -z "$(command -v bzip2)" ]; then if [ -z "$(command -v bzip2)" ]; then
bzip2installed="0" bzip2installed="0"
fn_printinfo "bzip2 is not installed !" fn_printinfo "bzip2 is not installed !"
fn_scriptlog "bzip2 is not installed" fn_scriptlog "bzip2 is not installed"
echo -en "\n" echo -en "\n"
sleep 1 sleep 1
echo "We advise using it" echo "We advise using it"
echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/FastDL#bzip2-compression" echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/FastDL#bzip2-compression"
sleep 2 sleep 2
else else
bzip2installed="1" bzip2installed="1"
fi fi
} }
fn_fastdl_init(){ fn_fastdl_init(){
# User confirmation # User confirmation
fn_printok "Welcome to LGSM's FastDL generator" 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"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
clearoldfastdl="off" # Nothing to clear fn_scriptlog "Started FastDL creation"
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
while true; do 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 case $yn in
[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_printok "Clearing Enabled"; break;; [Yy]* ) break;;
[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_printok "Clearing Disabled"; break;; [Nn]* ) exit;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done 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" echo -en "\n"
fi # Prompt for clearing old files if folder was already here
# Prompt for using bzip2 if it's installed if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then
if [ ${bzip2installed} == 1 ]; 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 fn_printdots
while true; do 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 case $yn in
[Yy]* ) bzip2enable="on"; fn_scriptlog "bzip2 enabled"; fn_printok "bzip2 Enabled"; break;; [Yy]* ) luaressource="on"; fn_scriptlog "DL enforcer Enabled"; fn_printok "Enforcer Enabled"; break;;
[Nn]* ) bzip2enable="off"; fn_scriptlog "bzip2 disabled"; fn_printok "bzip2 Disabled"; break;; [Nn]* ) luaressource="off"; fn_scriptlog "DL enforcer Disabled"; fn_printok "Enforcer Disabled"; break;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
echo -en "\n" 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(){ fn_clear_old_fastdl(){
# Clearing old FastDL if user answered yes # Clearing old FastDL if user answered yes
if [ "${clearoldfastdl}" == "on" ]; then if [ "${clearoldfastdl}" == "on" ]; then
fn_printinfo "Clearing existing FastDL folder" fn_printinfo "Clearing existing FastDL folder"
fn_scriptlog "Clearing existing FastDL folder" fn_scriptlog "Clearing existing FastDL folder"
sleep 0.5 sleep 0.5
rm -R "${fastdldir:?}"/* rm -R "${fastdldir:?}"/*
fn_printok "Old FastDL folder cleared" fn_printok "Old FastDL folder cleared"
fn_scriptlog "Old FastDL folder cleared" fn_scriptlog "Old FastDL folder cleared"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
fi fi
} }
fn_gmod_fastdl(){ fn_gmod_fastdl(){
# Copy all needed files for FastDL # Copy all needed files for FastDL
echo "" echo ""
fn_printdots "Starting gathering all needed files" fn_printdots "Starting gathering all needed files"
fn_scriptlog "Starting gathering all needed files" fn_scriptlog "Starting gathering all needed files"
sleep 1 sleep 1
echo -en "\n" 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"
# Materials # No choice to cd to the directory, as find can't then display relative folder
fn_printdots "Copying materials..." cd "${systemdir}"
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"
# Models # Map Files
fn_printdots "Copying models..." fn_printdots "Copying map files..."
fn_scriptlog "Copying models" fn_scriptlog "Copying map files"
sleep 1 sleep 0.5
find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}" find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}" fn_printok "Map files copied"
find . -name '*.mdl' | cpio --quiet -updm "${fastdldir}" sleep 0.5
find . -name '*.phy' | cpio --quiet -updm "${fastdldir}" echo -en "\n"
fn_printok "Models copied"
sleep 0.5
echo -en "\n"
# Particles # Materials
fn_printdots "Copying particles..." fn_printdots "Copying materials..."
fn_scriptlog "Copying particles" fn_scriptlog "Copying materials"
sleep 0.5 sleep 0.5
find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}" find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
fn_printok "Particles copied" find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
sleep 0.5 fn_printok "Materials copied"
echo -en "\n" sleep 0.5
echo -en "\n"
# Sounds # Models
fn_printdots "Copying sounds..." fn_printdots "Copying models..."
fn_scriptlog "Copying sounds" fn_scriptlog "Copying models"
sleep 0.5 sleep 1
find . -name '*.wav' | cpio --quiet -updm "${fastdldir}" find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}" find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ogg' | cpio --quiet -updm "${fastdldir}" find . -name '*.mdl' | cpio --quiet -updm "${fastdldir}"
fn_printok "Sounds copied" find . -name '*.phy' | cpio --quiet -updm "${fastdldir}"
sleep 0.5 fn_printok "Models copied"
echo -en "\n" sleep 0.5
echo -en "\n"
# Resources (mostly fonts) # Particles
fn_printdots "Copying fonts and png..." fn_printdots "Copying particles..."
fn_scriptlog "Copying fonts and png" fn_scriptlog "Copying particles"
sleep 1 sleep 0.5
find . -name '*.otf' | cpio --quiet -updm "${fastdldir}" find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}" fn_printok "Particles copied"
find . -name '*.png' | cpio --quiet -updm "${fastdldir}" sleep 0.5
fn_printok "Fonts and png copied" echo -en "\n"
sleep 0.5
echo -en "\n"
# Going back to rootdir in order to prevent mistakes # Sounds
cd "${rootdir}" 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 # Resources (mostly fonts)
if [ -d "${fastdldir}/addons" ]; then fn_printdots "Copying fonts and png..."
fn_printinfo "Adjusting addons' file structure" fn_scriptlog "Copying fonts and png"
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 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" echo -en "\n"
fi
# Correct content that may be into a lua folder by mistake like some darkrpmodification addons # Going back to rootdir in order to prevent mistakes
if [ -d "${fastdldir}/lua" ]; then cd "${rootdir}"
fn_printdots "Typical DarkRP shit detected, fixing"
sleep 2 # Correct addons folder structure for FastDL
cp -Rf "${fastdldir}/lua/"* "${fastdldir}" if [ -d "${fastdldir}/addons" ]; then
fn_printok "Stupid DarkRP file structure fixed" fn_printinfo "Adjusting addons' file structure"
sleep 2 fn_scriptlog "Adjusting addon's file structure"
echo -en "\n" sleep 1
fi 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 # Generate lua file that will force download any file into the FastDL folder
fn_lua_fastdl(){ fn_lua_fastdl(){
# Remove lua file if luaressource is turned off and file exists # Remove lua file if luaressource is turned off and file exists
echo "" echo ""
if [ "${luaressource}" == "off" ]; then if [ "${luaressource}" == "off" ]; then
if [ -f "${luafastdlfullpath}" ]; then if [ -f "${luafastdlfullpath}" ]; then
fn_printdots "Removing download enforcer" 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 sleep 1
rm -R "${luafastdlfullpath:?}" # Read all filenames and put them into a lua file at the right path
fn_printok "Removed download enforcer" find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do
fn_scriptlog "Removed old download inforcer" echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath}
done
fn_printok "Download enforcer generated"
fn_scriptlog "Download enforcer generated"
echo -en "\n" echo -en "\n"
echo ""
sleep 2 sleep 2
fi fi
fi }
# Remove old lua file and generate a new one if user said yes
if [ "${luaressource}" == "on" ]; then fn_fastdl_bzip2(){
if [ -f "${luafastdlfullpath}" ]; then # Compressing using bzip2 if user said yes
fn_printdots "Removing old download enforcer" echo ""
sleep 1 if [ ${bzip2enable} == "on" ]; then
rm "${luafastdlfullpath}" fn_printinfo "Have a break, this step could take a while..."
fn_printok "Removed old download enforcer"
fn_scriptlog "Removed old download enforcer"
echo -en "\n" 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 sleep 1
echo -en "\n"
fi 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(){ fn_fastdl_completed(){
# Compressing using bzip2 if user said yes # Finished message
echo "" echo ""
if [ ${bzip2enable} == "on" ]; then fn_printok "Congratulations, it's done !"
fn_printinfo "Have a break, this step could take a while..." fn_scriptlog "FastDL job done"
sleep 2
echo -en "\n" echo -en "\n"
echo "" echo ""
fn_printdots "Compressing files using bzip2..." fn_printinfo "Need more doc ? See https://github.com/dgibbs64/linuxgsm/wiki/FastDL"
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" echo -en "\n"
fi if [ "$bzip2installed" == "0" ]; then
} echo "By the way, you'd better install bzip2 an re-run this command !"
fi
fn_fastdl_completed(){ echo "Credits : UltimateByte"
# 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"
} }
# Game checking and functions running # 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(){ fn_serveradmin_password_prompt(){
echo "" echo ""
echo "${gamename} ServerAdmin Password Change" echo "${gamename} ServerAdmin Password Change"
echo "=================================" echo "================================="
echo "" echo ""
echo "Press \"CTRL+b d\" to exit console." echo "Press \"CTRL+b d\" to exit console."
fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password." fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password."
fn_print_warning_nl "${gamename} will restart during this process." fn_print_warning_nl "${gamename} will restart during this process."
echo "" echo ""
while true; do while true; do
read -e -i "y" -p "Continue? [Y/n]" yn read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]* ) break;;
[Nn]* ) echo Exiting; exit;; [Nn]* ) echo Exiting; exit;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fn_scriptlog "Initiating ${gamename} ServerAdmin password change" fn_scriptlog "Initiating ${gamename} ServerAdmin password change"
read -p "Enter new password : " newpassword read -p "Enter new password : " newpassword
} }
fn_serveradmin_password_set(){ fn_serveradmin_password_set(){
fn_print_info_nl "Applying new password" fn_print_info_nl "Applying new password"
fn_scriptlog "Applying new password" fn_scriptlog "Applying new password"
sleep 1 sleep 1
# Stop any running server # Stop any running server
command_stop.sh command_stop.sh
# Start server in "new password mode" # Start server in "new password mode"
ts3serverpass="1" ts3serverpass="1"
fn_print_info_nl "Starting server with new password" fn_print_info_nl "Starting server with new password"
command_start.sh command_start.sh
# Stop server in "new password mode" # Stop server in "new password mode"
command_stop.sh command_stop.sh
ts3serverpass="0" ts3serverpass="0"
fn_print_ok_nl "Password applied" fn_print_ok_nl "Password applied"
fn_scriptlog "New ServerAdmin password applied" fn_scriptlog "New ServerAdmin password applied"
sleep 1 sleep 1
} }
# Running functions # Running functions

48
lgsm/functions/command_validate.sh

@ -10,30 +10,30 @@ local modulename="Validate"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_validation(){ fn_validation(){
fn_print_warn_nl "Validating may overwrite some customised files." fn_print_warn_nl "Validating may overwrite some customised files."
echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate" echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
sleep 5 sleep 5
echo -en "\n" echo -en "\n"
fn_print_dots "Checking server files" fn_print_dots "Checking server files"
sleep 1 sleep 1
fn_print_ok "Checking server files" fn_print_ok "Checking server files"
fn_scriptlog "Checking server files" fn_scriptlog "Checking server files"
sleep 1 sleep 1
cd "${rootdir}/steamcmd" cd "${rootdir}/steamcmd"
if [ $(command -v unbuffer) ]; then if [ $(command -v unbuffer) ]; then
unbuffer=unbuffer unbuffer=unbuffer
fi fi
if [ "${engine}" == "goldsource" ]; then 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}" ${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 else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
fi fi
fix.sh fix.sh
fn_scriptlog "Checking complete" fn_scriptlog "Checking complete"
} }
check_status.sh 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_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd"
fn_dl_md5(){ fn_dl_md5(){
# Runs MD5 Check if available # Runs MD5 Check if available
if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then
echo -ne "verifying ${filename} with MD5..." echo -ne "verifying ${filename} with MD5..."
sleep 1 sleep 1
local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}') local md5sumcmd=$(md5sum "${filedir}/${filename}"|awk '{print $1;}')
if [ "${md5sumcmd}" != "${md5}" ]; then if [ "${md5sumcmd}" != "${md5}" ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "${filename} returned MD5 checksum: ${md5sumcmd}"
echo "expected MD5 checksum: ${md5}" echo "expected MD5 checksum: ${md5}"
fn_scriptlog "verifying ${filename} with MD5: FAIL" fn_scriptlog "verifying ${filename} with MD5: FAIL"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}" fn_scriptlog "expected MD5 checksum: ${md5}"
exit 1 exit 1
else else
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "verifying ${filename} with MD5: OK" fn_scriptlog "verifying ${filename} with MD5: OK"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}" fn_scriptlog "expected MD5 checksum: ${md5}"
fi fi
fi fi
} }
# Extracts bzip2 or gzip files # Extracts bzip2 or gzip files
@ -46,28 +46,28 @@ fi
# fn_dl_extract "${filedir}" "${filename}" "${extractdir}" # fn_dl_extract "${filedir}" "${filename}" "${extractdir}"
# fn_dl_extract "/home/gameserver/lgsm/tmp" "file.tar.bz2" "/home/gamserver/serverfiles" # fn_dl_extract "/home/gameserver/lgsm/tmp" "file.tar.bz2" "/home/gamserver/serverfiles"
fn_dl_extract(){ fn_dl_extract(){
filedir="${1}" filedir="${1}"
filename="${2}" filename="${2}"
extractdir="${3}" extractdir="${3}"
# extracts archives # extracts archives
echo -ne "extracting ${filename}..." echo -ne "extracting ${filename}..."
fn_scriptlog "extracting download" fn_scriptlog "extracting download"
mime=$(file -b --mime-type "${filedir}/${filename}") mime=$(file -b --mime-type "${filedir}/${filename}")
if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then
tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}") tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}")
elif [ "${mime}" == "application/x-bzip2" ]; then elif [ "${mime}" == "application/x-bzip2" ]; then
tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}") tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}")
fi fi
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "extracting download: FAIL" fn_scriptlog "extracting download: FAIL"
echo "${tarcmd}" | tee -a "${scriptlog}" echo "${tarcmd}" | tee -a "${scriptlog}"
exit ${exitcode} exit ${exitcode}
else else
fn_print_ok_eol_nl fn_print_ok_eol_nl
fi fi
} }
# Trap to remove file download if canceled before completed # Trap to remove file download if canceled before completed
@ -85,78 +85,78 @@ fn_fetch_trap() {
} }
fn_fetch_file(){ fn_fetch_file(){
fileurl="${1}" fileurl="${1}"
filedir="${2}" filedir="${2}"
filename="${3}" filename="${3}"
executecmd="${4:-0}" executecmd="${4:-0}"
run="${5:-0}" run="${5:-0}"
force="${6:-0}" force="${6:-0}"
md5="${7:-0}" md5="${7:-0}"
# If the file is missing, then download # If the file is missing, then download
if [ ! -f "${filedir}/${filename}" ]; then if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then if [ ! -d "${filedir}" ]; then
mkdir -p "${filedir}" 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
fi fi
done
# If curl exists download file # Check curl exists and use available path
if [ "$(basename ${curlcmd})" == "curl" ]; then curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
# trap to remove part downloaded files for curlcmd in ${curlpaths}
trap fn_fetch_trap INT do
# if larger file shows progress bar if [ -x "${curlcmd}" ]; then
if [ ${filename##*.} == "bz2" ]; then break
echo -ne "downloading ${filename}..." fi
sleep 1 done
curlcmd=$(${curlcmd} --progress-bar --fail -o "${filedir}/${filename}" "${fileurl}") # If curl exists download file
echo -ne "downloading ${filename}..." 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 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 fn_print_fail_eol_nl
if [ -f "${scriptlog}" ]; then echo "Curl is not installed!"
fn_scriptlog "downloading ${filename}: FAIL" echo -e ""
fi exit 1
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 fi
# remove trap # make file executecmd if executecmd is set
trap - INT if [ "${executecmd}" == "executecmd" ]; then
else chmod +x "${filedir}/${filename}"
fn_print_fail_eol_nl fi
echo "Curl is not installed!"
echo -e ""
exit 1
fi fi
# make file executecmd if executecmd is set
if [ "${executecmd}" == "executecmd" ]; then
chmod +x "${filedir}/${filename}"
fi
fi
if [ -f "${filedir}/${filename}" ]; then if [ -f "${filedir}/${filename}" ]; then
fn_dl_md5 fn_dl_md5
# run file if run is set # run file if run is set
if [ "${run}" == "run" ]; then if [ "${run}" == "run" ]; then
source "${filedir}/${filename}" source "${filedir}/${filename}"
fi
fi fi
fi
} }
@ -172,31 +172,31 @@ fi
# Fetches files from the github repo # Fetches files from the github repo
fn_fetch_file_github(){ fn_fetch_file_github(){
github_file_url_dir="${1}" github_file_url_dir="${1}"
github_file_url_name="${2}" github_file_url_name="${2}"
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}"
fileurl="${githuburl}" fileurl="${githuburl}"
filedir="${3}" filedir="${3}"
filename="${github_file_url_name}" filename="${github_file_url_name}"
executecmd="${4:-0}" executecmd="${4:-0}"
run="${5:-0}" run="${5:-0}"
force="${6:-0}" force="${6:-0}"
md5="${7:-0}" md5="${7:-0}"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
} }
# Fetches functions # Fetches functions
fn_fetch_function(){ fn_fetch_function(){
github_file_url_dir="lgsm/functions" # github dir containing the file github_file_url_dir="lgsm/functions" # github dir containing the file
github_file_url_name="${functionfile}" # name of the github 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}" githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
fileurl="${githuburl}" fileurl="${githuburl}"
filedir="${functionsdir}" filedir="${functionsdir}"
filename="${github_file_url_name}" filename="${github_file_url_name}"
executecmd="executecmd" executecmd="executecmd"
run="run" run="run"
force="noforce" force="noforce"
md5="nomd5" md5="nomd5"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
} }

200
lgsm/functions/install_config.sh

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

8
lgsm/functions/install_gsquery.sh

@ -5,10 +5,10 @@
lgsm_version="190216" lgsm_version="190216"
fn_dlgsquery(){ fn_dlgsquery(){
cd "${rootdir}" cd "${rootdir}"
echo -e "downloading gsquery.py...\c" 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 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 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 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" local modulename="Install"
fn_install_server_files(){ fn_install_server_files(){
if [ "${gamename}" == "Unreal Tournament 99" ]; then 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" 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 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" 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 fi
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
fn_dl_extract "${filedir}" "${filename}" "${filesdir}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}"
} }
fn_install_server_files_steamcmd(){ fn_install_server_files_steamcmd(){
counter="0" counter="0"
while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do while [ "${counter}" == "0" ]||[ "${exitcode}" != "0" ]; do
counter=$((counter+1)) counter=$((counter+1))
cd "${rootdir}/steamcmd" cd "${rootdir}/steamcmd"
if [ "${counter}" -le "10" ]; then if [ "${counter}" -le "10" ]; then
# Attempt 1-4: Standard attempt # Attempt 1-4: Standard attempt
# Attempt 5-6: Validate attempt # Attempt 5-6: Validate attempt
# Attempt 7-8: Validate, delete long name dir # Attempt 7-8: Validate, delete long name dir
# Attempt 9-10: Validate, delete long name dir, re-download SteamCMD # Attempt 9-10: Validate, delete long name dir, re-download SteamCMD
# Attempt 11: Failure # 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
if [ "${counter}" -ge "7" ]; then if [ "${counter}" -ge "2" ]; then
echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')" fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fi fi
if [ "${counter}" -ge "9" ]; then
rm -rf "${rootdir}/steamcmd"
check_steamcmd.sh
fi
# Detects if unbuffer command is available. if [ "${counter}" -ge "7" ]; then
if [ $(command -v unbuffer) ]; then echo "Removing $(find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$')"
unbuffer=unbuffer find ${filesdir} -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf
fi fi
if [ "${counter}" -ge "9" ]; then
rm -rf "${rootdir}/steamcmd"
check_steamcmd.sh
fi
if [ "${counter}" -le "4" ]; then # Detects if unbuffer command is available.
if [ "${engine}" == "goldsource" ]; then if [ $(command -v unbuffer) ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit unbuffer=unbuffer
local exitcode=$?
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit
local exitcode=$?
fi fi
elif [ "${counter}" -ge "5" ]; then
if [ "${engine}" == "goldsource" ]; then if [ "${counter}" -le "4" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" -validate +quit if [ "${engine}" == "goldsource" ]; then
local exitcode=$? ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" +quit
else local exitcode=$?
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" -validate +quit else
local exitcode=$? ${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 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 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 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 "" echo ""

100
lgsm/functions/update_dl.sh

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

Loading…
Cancel
Save