From db0ca3a27a51480346c6fe3dc74c9cb1cb53d8a3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 2 Nov 2014 22:47:24 +0000 Subject: [PATCH] created separate function fn_glibcfix First function to be migrated to its own file. This will slowly be done over time to more functions as changes are made. The idea is to reduce the requirement to copy the same changes to every script many times. This fixes the following issue: libstdc++.so.6 fix https://github.com/dgibbs64/linuxgameservers/issues/203 This is the first release of this new file function feature any bugs please report. To apply the fix to existing servers you will need to run the installer again. --- GarrysMod/gmodserver | 117 ++++------------------------------------- functions/README.md | 4 ++ functions/fn_fninstall | 10 ++++ functions/fn_glibcfix | 102 +++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 106 deletions(-) create mode 100644 functions/README.md create mode 100644 functions/fn_fninstall create mode 100644 functions/fn_glibcfix diff --git a/GarrysMod/gmodserver b/GarrysMod/gmodserver index c826a7ee8..737042d07 100644 --- a/GarrysMod/gmodserver +++ b/GarrysMod/gmodserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 061014 +# Version: 021114 #### Variables #### @@ -688,111 +688,7 @@ echo "" # fn_glibcfix(){ -if [ -z $(command -v ldd) ]; then - echo "" - echo -e "\r\033[K\e[0;31mFAIL\e[0;39m GLIBC is not detected." - sleep 1 - echo "Install GLIBC and retry installation" - sleep 1 - echo "" - while true; do - read -p "Continue install? [y/N]" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) echo Exiting; exit;; - * ) echo "Please answer yes or no.";; - esac - done -elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 ]; then - echo "GLIBC Fix required" - echo "============================" - sleep 1 - echo -e "\e[0;31mWARNING!\e[0;39m ${gamename} requires GLIBC_2.15 or above" - sleep 1 - echo "" - echo "Currently installed: GLIBC_$(ldd --version |grep ldd|awk '{print $NF}')" - echo "Required: => GLIBC_2.15" - echo "" - sleep 1 - echo "The installer will now detect and download the required files to allow ${gamename} server to run on a distro with GLIBC_2.14 or less." - echo "note: This will NOT upgrade GLIBC on your system" - sleep 1 - echo "" - echo "Downloading Required files" - echo "=================================" - sleep 1 - if [ "${gamename}" == "Insurgency" ];then - echo "Detected Insurgency" - sleep 1 - echo "Downloading files for Insurgency GLIBC Fix" - cd "${filesdir}/bin" - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libc.so.6 - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/librt.so.1 - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libpthread.so.0 - sleep 1 - elif [ "${gamename}" == "Garrys's Mod" ];then - echo "Detected Garrys's Mod" - sleep 1 - echo "Downloading files for Garrys's Mod GLIBC Fix" - sleep 1 - cd "${filesdir}/bin" - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libc.so.6 - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libm.so.6 - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libpthread.so.0 - sleep 1 - echo "" - elif [ "${gamename}" == "Natural Selection 2" ];then - echo "Detected Natural Selection 2" - sleep 1 - echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 - cd "${filesdir}" - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 - cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" - sleep 1 - echo "" - elif [ "${gamename}" == "No More Room in Hell" ];then - echo "Detected No More Room in Hell" - sleep 1 - echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 - cd "${filesdir}/srcds" - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 - cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" - sleep 1 - echo "" - elif [ "${gamename}" == "Blade Symphony" ];then - echo "Detected Blade Symphony" - sleep 1 - echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 - cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" - sleep 1 - echo "" - elif [ "${gamename}" == "Fistful of Frags" ];then - echo "Detected Fistful of Frags" - sleep 1 - echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 - cd "${filesdir}" - wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 - sleep 1 - echo "" - elif [ "${gamename}" == "ARMA 3" ];then - echo "Detected ARMA 3" - sleep 1 - echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 - cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" - sleep 1 - echo "" - else - echo "error: Unable to detect game. Fix not applied" - fi - echo "GLIBC fix has been applied!" - sleep 1 - echo "" -fi +source functions/fn_glibcfix } fn_libsteamfix(){ @@ -817,6 +713,14 @@ echo "=================================" echo "" } +fn_fninstall(){ +mkdir functions +cd functions +wget https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/fn_fninstall +cd ${rootdir} +source functions/fn_fninstall +} + fn_steamdl(){ echo "Installing SteamCMD" echo "=================================" @@ -940,6 +844,7 @@ while true; do esac done fn_header +fn_fninstall fn_steamdl fn_steaminstall fn_steamfix diff --git a/functions/README.md b/functions/README.md new file mode 100644 index 000000000..bb76d811c --- /dev/null +++ b/functions/README.md @@ -0,0 +1,4 @@ +

Linux Game Server Manager - Functions

+ +These functions are universal functions that work in all scripts. + diff --git a/functions/fn_fninstall b/functions/fn_fninstall new file mode 100644 index 000000000..704c10871 --- /dev/null +++ b/functions/fn_fninstall @@ -0,0 +1,10 @@ +#!/bin/bash +# LGSM fn_fninstall function +# Author: Daniel Gibbs +# Website: http://danielgibbs.co.uk +# Version: 021114 + +cd functions +#fn_glibcfix +wget https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/fn_glibcfix +chmod +x fn_glibcfix \ No newline at end of file diff --git a/functions/fn_glibcfix b/functions/fn_glibcfix new file mode 100644 index 000000000..18b5da447 --- /dev/null +++ b/functions/fn_glibcfix @@ -0,0 +1,102 @@ +#!/bin/bash +# LGSM fn_glibcfix function +# Author: Daniel Gibbs +# Website: http://danielgibbs.co.uk +# Version: 021114 + +fn_glibcfixmsg(){ +echo "Detected ${gamename}" +sleep 1 +echo "Downloading files for ${gamename} GLIBC Fix" +sleep 1 +} + +if [ -z $(command -v ldd) ]; then + echo "" + echo -e "\r\033[K\e[0;31mFAIL\e[0;39m GLIBC is not detected." + sleep 1 + echo "Install GLIBC and retry installation" + sleep 1 + echo "" + while true; do + read -p "Continue install? [y/N]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) echo Exiting; exit;; + * ) echo "Please answer yes or no.";; + esac + done +elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 ]; then + echo "GLIBC Fix required" + echo "============================" + sleep 1 + echo -e "\e[0;31mWARNING!\e[0;39m ${gamename} requires GLIBC_2.15 or above" + sleep 1 + echo "" + echo "Currently installed: GLIBC_$(ldd --version |grep ldd|awk '{print $NF}')" + echo "Required: => GLIBC_2.15" + echo "" + sleep 1 + echo "The installer will now detect and download the required files to allow ${gamename} server to run on a distro with GLIBC_2.14 or less." + echo "note: This will NOT upgrade GLIBC on your system" + sleep 1 + echo "" + echo "Downloading Required files" + echo "=================================" + sleep 1 + if [ "${gamename}" == "Insurgency" ];then + fn_glibcfixmsg + cd "${filesdir}/bin" + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libc.so.6 + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/librt.so.1 + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libpthread.so.0 + sleep 1 + elif [ "${gamename}" == "Garrys's Mod" ];then + fn_glibcfixmsg + cd "${filesdir}/bin" + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libc.so.6 + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libm.so.6 + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libpthread.so.0 + cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" + sleep 1 + echo "" + elif [ "${gamename}" == "Natural Selection 2" ];then + fn_glibcfixmsg + cd "${filesdir}" + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 + cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" + sleep 1 + echo "" + elif [ "${gamename}" == "No More Room in Hell" ];then + fn_glibcfixmsg + cd "${filesdir}/srcds" + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 + cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" + sleep 1 + echo "" + elif [ "${gamename}" == "Blade Symphony" ];then + fn_glibcfixmsg + cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" + sleep 1 + echo "" + elif [ "${gamename}" == "Fistful of Frags" ];then + echo "Detected ${gamename}" + sleep 1 + echo "Downloading files for ${gamename} GLIBC Fix" + sleep 1 + cd "${filesdir}" + wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 + sleep 1 + echo "" + elif [ "${gamename}" == "ARMA 3" ];then + fn_glibcfixmsg + cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" + sleep 1 + echo "" + else + echo "error: Unable to detect game. Fix not applied" + fi + echo "GLIBC fix has been applied!" + sleep 1 + echo "" +fi \ No newline at end of file