|
|
@ -55,13 +55,8 @@ backupdir="backups" |
|
|
|
steamclient="${filesdir}/bin/steamclient.so" |
|
|
|
|
|
|
|
# Server Details |
|
|
|
<<<<<<< HEAD |
|
|
|
servername=$(grep -s hostname "${servercfg}" | sed 's/hostname //g'|sed 's/"//g') |
|
|
|
rcon=$(grep -s rcon_password "${servercfg}" | sed 's/rcon_password //g'|sed 's/"//g') |
|
|
|
======= |
|
|
|
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g') |
|
|
|
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g') |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
|
|
|
|
# Logging |
|
|
|
logdays="7" |
|
|
@ -93,13 +88,8 @@ fi |
|
|
|
} |
|
|
|
|
|
|
|
fn_syscheck(){ |
|
|
|
<<<<<<< HEAD |
|
|
|
if [ ! -e "${filesdir}" ]; then |
|
|
|
echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Cannot access ${filesdir}: No such directory" |
|
|
|
======= |
|
|
|
if [ ! -e "${systemdir}" ]; then |
|
|
|
echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Cannot access ${systemdir}: No such directory" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
exit |
|
|
|
fi |
|
|
|
} |
|
|
@ -111,13 +101,8 @@ getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|gre |
|
|
|
getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) |
|
|
|
if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then |
|
|
|
if [ "${getipwc}" -ge "2" ]; then |
|
|
|
<<<<<<< HEAD |
|
|
|
echo -en "[\e[1;33m WARN \e[0;39m] Multiple active interfaces.\n\n" |
|
|
|
echo -en "Manually specify the IP in ${selfname}\n" |
|
|
|
======= |
|
|
|
echo -en "[\e[1;33m WARN \e[0;39m] Multiple active network interfaces.\n\n" |
|
|
|
echo -en "Manually specify the IP you want to use in ${selfname}.\n" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" |
|
|
|
echo -en "${getip}\n" |
|
|
|
exit |
|
|
@ -132,24 +117,15 @@ if [ ! -e "${consolelog}" ]; then |
|
|
|
touch "${consolelog}" |
|
|
|
fi |
|
|
|
# log manager will active if finds logs older than ${logdays} |
|
|
|
<<<<<<< HEAD |
|
|
|
if [ `find "${scriptlogdir}"/* -mtime +${logdays} |wc -l` -ne "0" ]; then |
|
|
|
======= |
|
|
|
if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
echo -e "\r\033[K[\e[0;32m OK \e[0;39m] Starting log cleaner" |
|
|
|
fn_scriptlog "Starting log cleaner" |
|
|
|
sleep 1 |
|
|
|
echo -e "[\e[0;36m INFO \e[0;39m] Removing logs older than ${logdays} days" |
|
|
|
fn_scriptlog "Removing logs older than ${logdays} days" |
|
|
|
sleep 1 |
|
|
|
<<<<<<< HEAD |
|
|
|
find "${scriptlogdir}"/* -mtime +${logdays} |tee >> "${scriptlog}" |
|
|
|
find "${consolelogdir}"/* -mtime +${logdays} |tee >> "${scriptlog}" |
|
|
|
======= |
|
|
|
find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" |
|
|
|
find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
scriptcount=$(find "${scriptlogdir}/*" -mtime +${logdays}|wc -l) |
|
|
|
consolecount=$(find "${consolelogdir}/*" -mtime +${logdays}|wc -l) |
|
|
|
count=$((${scriptcount} + ${consolecount})) |
|
|
@ -188,19 +164,11 @@ fn_stopserver |
|
|
|
echo -en "\r\033[K[ .... ] Starting debug mode ${servicename}: ${servername}" |
|
|
|
sleep 0.5 |
|
|
|
echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Starting debug mode ${servicename}: ${servername}" |
|
|
|
<<<<<<< HEAD |
|
|
|
fn_scriptlog "Started debug mode ${servername} " |
|
|
|
sleep 0.5 |
|
|
|
echo -en "\n" |
|
|
|
cd "${filesdir}" |
|
|
|
./srcds_run "${parms}" -debug |
|
|
|
======= |
|
|
|
fn_scriptlog "Started debug mode ${servername}" |
|
|
|
sleep 0.5 |
|
|
|
echo -en "\n" |
|
|
|
cd "${executabledir}" |
|
|
|
${executable} ${parms} -debug |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
} |
|
|
|
|
|
|
|
fn_console(){ |
|
|
@ -282,11 +250,7 @@ fn_scriptlog "Backup started" |
|
|
|
sleep 1 |
|
|
|
echo -en "\n" |
|
|
|
cd "${rootdir}" |
|
|
|
<<<<<<< HEAD |
|
|
|
mkdir -p "${backupdir}" > /dev/null 2>&1 |
|
|
|
======= |
|
|
|
mkdir -pv "${backupdir}" > /dev/null 2>&1 |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
tar -cvzf "${backupdir}/${backupname}.tar.gz" --exclude "${backupdir}" * |
|
|
|
echo -en "\r\033[K${servicename} Backup complete" |
|
|
|
fn_scriptlog "Backup complete" |
|
|
@ -347,11 +311,7 @@ if [ ! -z "${consolelog}" ]; then |
|
|
|
fi |
|
|
|
if [ ! -z "${gamelogdir}" ]; then |
|
|
|
echo -e "\n\nServer log\n====================\n" >> "${emaillog}" |
|
|
|
<<<<<<< HEAD |
|
|
|
tail "${gamelogdir}"/* | grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}" |
|
|
|
======= |
|
|
|
tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
fi |
|
|
|
mail -s "${subject}" ${email} < "${emaillog}" |
|
|
|
echo -en "[\e[0;36m INFO \e[0;39m] Sent email notification to ${email}" |
|
|
@ -388,21 +348,13 @@ if [ -f gsquery.py ]; then |
|
|
|
port=$((${port} + 1)) |
|
|
|
fi |
|
|
|
echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Detected gsquery.py" |
|
|
|
<<<<<<< HEAD |
|
|
|
fn_scriptlog "Detected gsquery.py " |
|
|
|
======= |
|
|
|
fn_scriptlog "Detected gsquery.py" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
sleep 1 |
|
|
|
echo -en "\r\033[K[ .... ] Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" |
|
|
|
fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" |
|
|
|
serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) |
|
|
|
exitcode=$? |
|
|
|
<<<<<<< HEAD |
|
|
|
sleep 1 |
|
|
|
======= |
|
|
|
sleep 1 |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then |
|
|
|
echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Monitoring ${servicename}: Querying port: ${ip}:${port}: ${serverquery}" |
|
|
|
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" |
|
|
@ -475,11 +427,7 @@ if [ "${updatecheck}" = "0" ]; then |
|
|
|
echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Monitoring ${servicename}: Checking session: FAIL" |
|
|
|
fn_scriptlog "Checking session: FAIL" |
|
|
|
sleep 1 |
|
|
|
<<<<<<< HEAD |
|
|
|
echo -en "\n" |
|
|
|
======= |
|
|
|
echo -en "\n" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
if [ "${emailnotification}" = "on" ]; then |
|
|
|
subject="${servicename} Monitor - Starting ${servername}" |
|
|
|
failurereason="${servicename} process not running" |
|
|
@ -487,11 +435,7 @@ if [ "${updatecheck}" = "0" ]; then |
|
|
|
fn_emailnotification |
|
|
|
fi |
|
|
|
fn_scriptlog "Monitor is starting ${servername}" |
|
|
|
<<<<<<< HEAD |
|
|
|
fn_startserver |
|
|
|
======= |
|
|
|
fn_startserver |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
fi |
|
|
|
else |
|
|
|
echo -e "[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Detected SteamCMD is checking for updates" |
|
|
@ -510,13 +454,8 @@ sleep 0.5 |
|
|
|
echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Updating ${servicename}: ${servername}" |
|
|
|
fn_scriptlog "Updating ${servername}" |
|
|
|
cd "${rootdir}" |
|
|
|
<<<<<<< HEAD |
|
|
|
cd steamcmd |
|
|
|
./steamcmd.sh +login anonymous +force_install_dir "${filesdir}" +app_update ${appid} validate +quit |tee -a "${scriptlog}" |
|
|
|
======= |
|
|
|
cd "steamcmd" |
|
|
|
./steamcmd.sh +login ${steamuser} ${steampass} +force_install_dir "${filesdir}" +app_update ${appid} validate +quit|tee -a "${scriptlog}" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
} |
|
|
|
|
|
|
|
fn_restartserver(){ |
|
|
@ -565,13 +504,8 @@ if [ ${tmuxwc} -eq 1 ]; then |
|
|
|
echo -en "\n" |
|
|
|
exit |
|
|
|
fi |
|
|
|
<<<<<<< HEAD |
|
|
|
cd "${filesdir}" |
|
|
|
tmux new-session -d -s ${servicename} "./srcds_run ${parms} |tee -a '${consolelog}'" |
|
|
|
======= |
|
|
|
cd "${executabledir}" |
|
|
|
tmux new-session -d -s ${servicename} "${executable} ${parms}|tee -a '${consolelog}'" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
sleep 1 |
|
|
|
tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) |
|
|
|
if [ ${tmuxwc} -eq 0 ]; then |
|
|
@ -599,15 +533,8 @@ echo "RCON password: ${rcon}" |
|
|
|
echo "Config file: ${servercfg}" |
|
|
|
echo "" |
|
|
|
echo "${servername} Ports" |
|
|
|
<<<<<<< HEAD |
|
|
|
echo "=======================" |
|
|
|
servername=$(grep -s hostname "${servercfg}" | sed 's/hostname //g'|sed 's/"//g') |
|
|
|
rcon=$(grep -s rcon_password "${servercfg}" | sed 's/rcon_password //g'|sed 's/"//g') |
|
|
|
echo "Ports the server is currently using" |
|
|
|
======= |
|
|
|
echo "============================" |
|
|
|
echo "Ports the server is currently using." |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
echo "" |
|
|
|
echo "DIRECTION DESCRIPTION PORT" |
|
|
|
echo "INBOUND Game/RCON port ${port}" |
|
|
@ -646,14 +573,9 @@ fn_steamdl(){ |
|
|
|
echo "Installing SteamCMD" |
|
|
|
echo "=================================" |
|
|
|
cd "${rootdir}" |
|
|
|
<<<<<<< HEAD |
|
|
|
mkdir -p steamcmd |
|
|
|
cd steamcmd |
|
|
|
======= |
|
|
|
mkdir -pv "steamcmd" |
|
|
|
sleep 1 |
|
|
|
cd "steamcmd" |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
if [ ! -f steamcmd.sh ]; then |
|
|
|
wget http://media.steampowered.com/client/steamcmd_linux.tar.gz |
|
|
|
tar --verbose -zxf steamcmd_linux.tar.gz |
|
|
@ -757,61 +679,20 @@ while true; do |
|
|
|
done |
|
|
|
fn_header |
|
|
|
fn_steamdl |
|
|
|
<<<<<<< HEAD |
|
|
|
echo "" |
|
|
|
echo "Installing ${gamename} Server" |
|
|
|
echo "=================================" |
|
|
|
cd "${rootdir}/steamcmd" |
|
|
|
mkdir -pv "${filesdir}" |
|
|
|
# Steam's installscript does not support quotes!! |
|
|
|
# That is why the block below is commented out |
|
|
|
# touch install.txt |
|
|
|
# chmod 0600 install.txt |
|
|
|
# echo "login anonymous" > install.txt |
|
|
|
# echo "force_install_dir '${filesdir}'" >> install.txt |
|
|
|
# echo "app_update ${appid} validate" >> install.txt |
|
|
|
# echo "quit" >> install.txt |
|
|
|
#STEAMEXE=steamcmd ./steamcmd.sh +runscript install.txt |
|
|
|
#rm install.txt |
|
|
|
STEAMEXE=steamcmd ./steamcmd.sh +login anonymous +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit |
|
|
|
echo "" |
|
|
|
echo "=================================" |
|
|
|
while true; do |
|
|
|
read -p "Was the install successful? [y/N]" yn |
|
|
|
case $yn in |
|
|
|
[Yy]* ) break;; |
|
|
|
[Nn]* ) fn_retryinstall;; |
|
|
|
* ) echo "Please answer yes or no.";; |
|
|
|
esac |
|
|
|
done |
|
|
|
fn_header |
|
|
|
======= |
|
|
|
fn_steaminstall |
|
|
|
fn_steamfix |
|
|
|
fn_loginstall |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
echo "Configuring ${gamename} Server" |
|
|
|
echo "=================================" |
|
|
|
sleep 1 |
|
|
|
read -p "Enter server name: " servername |
|
|
|
read -p "Enter rcon password: " rconpass |
|
|
|
sleep 1 |
|
|
|
<<<<<<< HEAD |
|
|
|
echo "" |
|
|
|
echo "Creating server.cfg" |
|
|
|
touch "${filesdir}/left4dead2/cfg/server.cfg" |
|
|
|
echo "exec ${servicename}.cfg" > "${filesdir}/left4dead2/cfg/server.cfg" |
|
|
|
sleep 1 |
|
|
|
echo "Creating default config file:" |
|
|
|
sleep 0.5 |
|
|
|
echo "${servercfg}" |
|
|
|
======= |
|
|
|
echo "Creating server.cfg." |
|
|
|
touch "${defaultcfg}" |
|
|
|
echo "exec ${servicename}.cfg" > "${defaultcfg}" |
|
|
|
sleep 1 |
|
|
|
echo "Creating ${servicename}.cfg config file." |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
touch "${servercfg}" |
|
|
|
{ |
|
|
|
echo -e "// server name" |
|
|
@ -832,26 +713,6 @@ echo "=================================" |
|
|
|
}|tee "${servercfg}" > /dev/null 2>&1 |
|
|
|
sleep 1 |
|
|
|
echo "" |
|
|
|
<<<<<<< HEAD |
|
|
|
echo "Creating log directorys" |
|
|
|
mkdir -pv "${rootdir}/log" |
|
|
|
mkdir -pv "${scriptlogdir}" |
|
|
|
mkdir -pv "${consolelogdir}" |
|
|
|
touch "${consolelog}" |
|
|
|
if [ ! -h ${rootdir}/log/server ]; then |
|
|
|
ln -sv "${gamelogdir}" "${rootdir}/log/server" |
|
|
|
else |
|
|
|
echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!" |
|
|
|
fi |
|
|
|
sleep 1 |
|
|
|
echo "" |
|
|
|
echo "Applying steamclient.so fix" |
|
|
|
mkdir -pv ${HOME}/.steam |
|
|
|
mkdir -pv ${HOME}/.steam/sdk32 |
|
|
|
cp -v "${filesdir}/bin/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" |
|
|
|
sleep 1 |
|
|
|
======= |
|
|
|
>>>>>>> Major update 240114 |
|
|
|
fn_header |
|
|
|
sleep 1 |
|
|
|
fn_details |
|
|
@ -893,4 +754,4 @@ case "$1" in |
|
|
|
echo "Usage: $0 {start|stop|restart|update|monitor|email-test|details|backup|console|debug|install}" |
|
|
|
exit 1;; |
|
|
|
esac |
|
|
|
exit |
|
|
|
exit |