diff --git a/q3aServ.sh b/q3aServ.sh index 9f1c285..13cf494 100755 --- a/q3aServ.sh +++ b/q3aServ.sh @@ -2,22 +2,22 @@ # -------------------------------------------- # Quake 3 Server Script | -# Created by q3aql (q3aql@openmailbox.org) | +# Created by q3aql (q3aql@protonmail.ch) | # Licensed by GPL v.3 | -# Last update: 02-04-2018 | +# Last update: 13-03-2021 | # -------------------------------------------- -VERSION="4.2" +VERSION="4.3" # Path with binary and game files RUN_PATH="/opt/Games/quake3" -cd $RUN_PATH +cd ${RUN_PATH} # Binary of server RUN_BINARY="ioq3ded.x86_64" # Baseq3 folder path -BASEQ3_PATH="$HOME/.q3a/baseq3" -mkdir -p $HOME/.q3a/baseq3 +BASEQ3_PATH="${HOME}/.q3a/baseq3" +mkdir -p ${HOME}/.q3a/baseq3 # Basic configs BOTS_LEVEL="2" @@ -33,33 +33,33 @@ STATUS_PATH=/var/www/html/quake3/status.txt # Note: Change to '/dev/null' if you want disable it. # Map selection -expr $2 + 1 &> /dev/null +expr ${2} + 1 &> /dev/null mapSelection=$? -if [ -z "$2" ] ; then - MAP_SELECT=$(expr $RANDOM % 5 + 1) +if [ -z "${2}" ] ; then + MAP_SELECT=$(expr ${RANDOM} % 5 + 1) else - if [ $mapSelection -ne 0 ] ; then + if [ ${mapSelection} -ne 0 ] ; then echo "" echo "<<[Error: Map-selection only must be numbers between 1 and 5]>>" echo "" exit - elif [ $2 -lt 1 ] || [ $2 -gt 5 ] ; then + elif [ ${2} -lt 1 ] || [ ${2} -gt 5 ] ; then echo "" echo "<<[Error: Map-selection must be between 1 and 5]>>" echo "" exit else - MAP_SELECT=$2 + MAP_SELECT=${2} fi fi # Function to stop a previous server and # remove the config. files function clear_server() { - killall -9 $RUN_BINARY 2> /dev/null - rm -rf ${BASEQ3_PATH}/basic.cfg - rm -rf ${BASEQ3_PATH}/server*.cfg - rm -rf ${BASEQ3_PATH}/bots*.cfg + killall -9 ${RUN_BINARY} 2> /dev/null + rm -rf ${BASEQ3_PATH}/basic.cfg + rm -rf ${BASEQ3_PATH}/server*.cfg + rm -rf ${BASEQ3_PATH}/bots*.cfg rm -rf ${BASEQ3_PATH}/levels*.cfg } @@ -101,27 +101,27 @@ function custom_game_menu() { # Function to check correct gametypes. function check_gametype() { - if [ "$1" == "CTF" ] ; then + if [ "${1}" == "CTF" ] ; then echo "Gametype selected = CTF" - elif [ "$1" == "FFA" ] ; then + elif [ "${1}" == "FFA" ] ; then echo "Gametype selected = FFA" - elif [ "$1" == "TD" ] ; then + elif [ "${1}" == "TD" ] ; then echo "Gametype selected = TD" - elif [ "$1" == "TOU" ] ; then + elif [ "${1}" == "TOU" ] ; then echo "Gametype selected = TOU" - elif [ "$1" == "FT" ] ; then + elif [ "${1}" == "FT" ] ; then echo "Gametype selected = FT" - elif [ "$1" == "CTFI" ] ; then + elif [ "${1}" == "CTFI" ] ; then echo "Gametype selected = CTFI" - elif [ "$1" == "TDI" ] ; then + elif [ "${1}" == "TDI" ] ; then echo "Gametype selected = TDI" - elif [ "$1" == "FFAI" ] ; then + elif [ "${1}" == "FFAI" ] ; then echo "Gametype selected = FFAI" - elif [ "$1" == "CA" ] ; then + elif [ "${1}" == "CA" ] ; then echo "Gametype selected = CA" - elif [ "$1" == "CAI" ] ; then + elif [ "${1}" == "CAI" ] ; then echo "Gametype selected = CAI" - elif [ -z "$1" ] ; then + elif [ -z "${1}" ] ; then echo "Empty" > /dev/null else echo "" @@ -132,104 +132,103 @@ function check_gametype() { } # Available options -case $1 in - -CTF|ctf) +case ${1} in + CTF|ctf) # Initialize "Capture The Flag" session clear_server - cp server/basic.cfg $BASEQ3_PATH - cp server/serverCTF.cfg $BASEQ3_PATH - cp server/bots.cfg $BASEQ3_PATH - cp server/levels/levelsCTF-${MAP_SELECT}.cfg $BASEQ3_PATH - echo "seta g_spskill $BOTS_LEVEL" >> ${BASEQ3_PATH}/bots.cfg - echo "seta bot_minplayers $MIN_PLAYERS" >> ${BASEQ3_PATH}/bots.cfg - echo "seta timelimit $TIME_LIMIT" >> ${BASEQ3_PATH}/serverCTF.cfg - echo "seta capturelimit $FLAGS_LIMIT" >> ${BASEQ3_PATH}/serverCTF.cfg + cp server/basic.cfg ${BASEQ3_PATH} + cp server/serverCTF.cfg ${BASEQ3_PATH} + cp server/bots.cfg ${BASEQ3_PATH} + cp server/levels/levelsCTF-${MAP_SELECT}.cfg ${BASEQ3_PATH} + echo "seta g_spskill ${BOTS_LEVEL}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta bot_minplayers ${MIN_PLAYERS}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta timelimit ${TIME_LIMIT}" >> ${BASEQ3_PATH}/serverCTF.cfg + echo "seta capturelimit ${FLAGS_LIMIT}" >> ${BASEQ3_PATH}/serverCTF.cfg echo "seta rconpassword ${RCON_PASSWORD}" >> ${BASEQ3_PATH}/serverCTF.cfg - echo "Running Capture The Flag ($MAP_SELECT)" > $STATUS_PATH + echo "Running Capture The Flag (${MAP_SELECT})" > ${STATUS_PATH} ./${RUN_BINARY} +exec basic.cfg +exec serverCTF.cfg +exec levelsCTF-${MAP_SELECT}.cfg +exec bots.cfg #clear_server - echo "Stopped" > $STATUS_PATH -;; -TD|td) + echo "Stopped" > ${STATUS_PATH} + ;; + TD|td) # Initialize "Team Deathmatch" session clear_server - cp server/basic.cfg $BASEQ3_PATH - cp server/serverTD.cfg $BASEQ3_PATH - cp server/bots.cfg $BASEQ3_PATH - cp server/levels/levelsTD-${MAP_SELECT}.cfg $BASEQ3_PATH - echo "seta g_spskill $BOTS_LEVEL" >> ${BASEQ3_PATH}/bots.cfg - echo "seta bot_minplayers $MIN_PLAYERS" >> ${BASEQ3_PATH}/bots.cfg - echo "seta timelimit $TIME_LIMIT" >> ${BASEQ3_PATH}/serverTD.cfg - echo "seta fraglimit $FRAGS_LIMIT" >> ${BASEQ3_PATH}/serverTD.cfg + cp server/basic.cfg ${BASEQ3_PATH} + cp server/serverTD.cfg ${BASEQ3_PATH} + cp server/bots.cfg ${BASEQ3_PATH} + cp server/levels/levelsTD-${MAP_SELECT}.cfg ${BASEQ3_PATH} + echo "seta g_spskill ${BOTS_LEVEL}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta bot_minplayers ${MIN_PLAYERS}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta timelimit ${TIME_LIMIT}" >> ${BASEQ3_PATH}/serverTD.cfg + echo "seta fraglimit ${FRAGS_LIMIT}" >> ${BASEQ3_PATH}/serverTD.cfg echo "seta rconpassword ${RCON_PASSWORD}" >> ${BASEQ3_PATH}/serverTD.cfg - echo "Running Team Deathmatch ($MAP_SELECT)" > $STATUS_PATH + echo "Running Team Deathmatch (${MAP_SELECT})" > ${STATUS_PATH} ./${RUN_BINARY} +exec basic.cfg +exec serverTD.cfg +exec levelsTD-${MAP_SELECT}.cfg +exec bots.cfg #clear_server - echo "Stopped" > $STATUS_PATH -;; -FFA|ffa) + echo "Stopped" > ${STATUS_PATH} + ;; + FFA|ffa) # Initialize "Free For All" session clear_server - cp server/basic.cfg $BASEQ3_PATH - cp server/serverFFA.cfg $BASEQ3_PATH - cp server/bots.cfg $BASEQ3_PATH - cp server/levels/levelsFFA-${MAP_SELECT}.cfg $BASEQ3_PATH - echo "seta g_spskill $BOTS_LEVEL" >> ${BASEQ3_PATH}/bots.cfg - echo "seta bot_minplayers $MIN_PLAYERS" >> ${BASEQ3_PATH}/bots.cfg - echo "seta timelimit $TIME_LIMIT" >> ${BASEQ3_PATH}/serverFFA.cfg - echo "seta fraglimit $FRAGS_LIMIT" >> ${BASEQ3_PATH}/serverFFA.cfg + cp server/basic.cfg ${BASEQ3_PATH} + cp server/serverFFA.cfg ${BASEQ3_PATH} + cp server/bots.cfg ${BASEQ3_PATH} + cp server/levels/levelsFFA-${MAP_SELECT}.cfg ${BASEQ3_PATH} + echo "seta g_spskill ${BOTS_LEVEL}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta bot_minplayers ${MIN_PLAYERS}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta timelimit ${TIME_LIMIT}" >> ${BASEQ3_PATH}/serverFFA.cfg + echo "seta fraglimit ${FRAGS_LIMIT}" >> ${BASEQ3_PATH}/serverFFA.cfg echo "seta rconpassword ${RCON_PASSWORD}" >> ${BASEQ3_PATH}/serverFFA.cfg - echo "Running Free For All ($MAP_SELECT)" > $STATUS_PATH + echo "Running Free For All (${MAP_SELECT})" > ${STATUS_PATH} ./${RUN_BINARY} +exec basic.cfg +exec serverFFA.cfg +exec levelsFFA-${MAP_SELECT}.cfg +exec bots.cfg #clear_server - echo "Stopped" > $STATUS_PATH -;; -TOU|tou|tourney) + echo "Stopped" > ${STATUS_PATH} + ;; + TOU|tou|tourney) # Initialize "Tournament" session clear_server - cp server/basic.cfg $BASEQ3_PATH - cp server/serverTOU.cfg $BASEQ3_PATH - cp server/bots.cfg $BASEQ3_PATH - cp server/levels/levelsTOU-${MAP_SELECT}.cfg $BASEQ3_PATH - echo "seta g_spskill $BOTS_LEVEL" >> ${BASEQ3_PATH}/bots.cfg + cp server/basic.cfg ${BASEQ3_PATH} + cp server/serverTOU.cfg ${BASEQ3_PATH} + cp server/bots.cfg ${BASEQ3_PATH} + cp server/levels/levelsTOU-${MAP_SELECT}.cfg ${BASEQ3_PATH} + echo "seta g_spskill ${BOTS_LEVEL}" >> ${BASEQ3_PATH}/bots.cfg echo "seta bot_minplayers 2" >> ${BASEQ3_PATH}/bots.cfg - echo "seta timelimit $TIME_LIMIT" >> ${BASEQ3_PATH}/serverTOU.cfg - echo "seta fraglimit $TOU_FRAGS_LIMIT" >> ${BASEQ3_PATH}/serverTOU.cfg + echo "seta timelimit ${TIME_LIMIT}" >> ${BASEQ3_PATH}/serverTOU.cfg + echo "seta fraglimit ${TOU_FRAGS_LIMIT}" >> ${BASEQ3_PATH}/serverTOU.cfg echo "seta rconpassword ${RCON_PASSWORD}" >> ${BASEQ3_PATH}/serverTOU.cfg - echo "Running Tournament ($MAP_SELECT)" > $STATUS_PATH + echo "Running Tournament (${MAP_SELECT})" > ${STATUS_PATH} ./${RUN_BINARY} +exec basic.cfg +exec serverTOU.cfg +exec levelsTOU-${MAP_SELECT}.cfg +exec bots.cfg #clear_server - echo "Stopped" > $STATUS_PATH -;; -CG|cg|custom) + echo "Stopped" > ${STATUS_PATH} + ;; + CG|cg|custom) # Initialize "Custom Game" session - check_gametype $3 - expr $4 + 1 &> /dev/null + check_gametype ${3} + expr ${4} + 1 &> /dev/null minPlayers=$? - expr $5 + 1 &> /dev/null + expr ${5} + 1 &> /dev/null botLevel=$? - expr $6 + 1 &> /dev/null + expr ${6} + 1 &> /dev/null timeLimit=$? - expr $7 + 1 &> /dev/null + expr ${7} + 1 &> /dev/null FFLimit=$? - if [ -z "$2" ] ; then + if [ -z "${2}" ] ; then custom_game_menu - elif [ "$2" == "-h" ] || [ "$2" == "--help" ] ; then + elif [ "${2}" == "-h" ] || [ "${2}" == "--help" ] ; then custom_game_menu - elif [ -z "$4" ] ; then + elif [ -z "${4}" ] ; then echo "" echo "<<[Error: Minplayers must be specified]>>" custom_game_menu - elif [ $minPlayers -ne 0 ] ; then + elif [ ${minPlayers} -ne 0 ] ; then echo "" echo "<<[Error: Minplayers only must be numbers between 0 and 10]>>" custom_game_menu - elif [ $4 -lt 0 ] || [ $4 -gt 10 ] ; then + elif [ ${4} -lt 0 ] || [ ${4} -gt 10 ] ; then echo "" echo "<<[Error: Minplayers must be between 0 and 10]>>" custom_game_menu - elif [ -z "$5" ] ; then + elif [ -z "${5}" ] ; then echo "" echo "<<[Error: Bot-level must be specified]>>" custom_game_menu @@ -237,88 +236,88 @@ CG|cg|custom) echo "" echo "<<[Error: Bot-level only must be numbers between 1 and 5]>>" custom_game_menu - elif [ $5 -lt 1 ] || [ $5 -gt 5 ] ; then + elif [ ${5} -lt 1 ] || [ ${5} -gt 5 ] ; then echo "" echo "<<[Error: Bot-level must be between 1 and 5]>>" custom_game_menu - elif [ -z "$6" ] ; then + elif [ -z "${6}" ] ; then echo "" echo "<<[Error: Time-limit must be specified]>>" custom_game_menu - elif [ $timeLimit -ne 0 ] ; then + elif [ ${timeLimit} -ne 0 ] ; then echo "" echo "<<[Error: Time-limit only must be numbers between 0 and 999]>>" custom_game_menu - elif [ $6 -lt 0 ] || [ $6 -gt 999 ] ; then + elif [ ${6} -lt 0 ] || [ ${6} -gt 999 ] ; then echo "" echo "<<[Error: Time-limit must be between 0 and 999]>>" custom_game_menu - elif [ -z "$7" ] ; then + elif [ -z "${7}" ] ; then echo "" echo "<<[Error: Flags/frags-limit must be specified]>>" custom_game_menu - elif [ $FFLimit -ne 0 ] ; then + elif [ ${FFLimit} -ne 0 ] ; then echo "" echo "<<[Error: Flags/frags-limit only must be numbers between 0 and 999]>>" custom_game_menu - elif [ $7 -lt 0 ] || [ $7 -gt 999 ] ; then + elif [ ${7} -lt 0 ] || [ ${7} -gt 999 ] ; then echo "" echo "<<[Error: Flags/frags-limit must be between 0 and 999]>>" custom_game_menu else clear_server - cp server/basic.cfg $BASEQ3_PATH - cp server/server${3}.cfg $BASEQ3_PATH - cp server/bots.cfg $BASEQ3_PATH - cp server/levels/levels${3}-${2}.cfg $BASEQ3_PATH - echo "seta g_spskill $5" >> ${BASEQ3_PATH}/bots.cfg - echo "seta bot_minplayers $4" >> ${BASEQ3_PATH}/bots.cfg - echo "seta timelimit $6" >> ${BASEQ3_PATH}/server${3}.cfg - if [ "$3" == "CTF" ] ; then - echo "seta capturelimit $7" >> ${BASEQ3_PATH}/server${3}.cfg - elif [ "$3" == "CTFI" ] ; then - echo "seta capturelimit $7" >> ${BASEQ3_PATH}/server${3}.cfg + cp server/basic.cfg ${BASEQ3_PATH} + cp server/server${3}.cfg ${BASEQ3_PATH} + cp server/bots.cfg ${BASEQ3_PATH} + cp server/levels/levels${3}-${2}.cfg ${BASEQ3_PATH} + echo "seta g_spskill ${5}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta bot_minplayers ${4}" >> ${BASEQ3_PATH}/bots.cfg + echo "seta timelimit ${6}" >> ${BASEQ3_PATH}/server${3}.cfg + if [ "${3}" == "CTF" ] ; then + echo "seta capturelimit ${7}" >> ${BASEQ3_PATH}/server${3}.cfg + elif [ "${3}" == "CTFI" ] ; then + echo "seta capturelimit ${7}" >> ${BASEQ3_PATH}/server${3}.cfg else - echo "seta fraglimit $7" >> ${BASEQ3_PATH}/server${3}.cfg + echo "seta fraglimit ${7}" >> ${BASEQ3_PATH}/server${3}.cfg fi echo "seta rconpassword ${RCON_PASSWORD}" >> ${BASEQ3_PATH}/server${3}.cfg - echo "Running $3 (Custom Game) ($2)" > $STATUS_PATH - if [ "$3" == "FT" ] ; then + echo "Running ${3} (Custom Game) ($2)" > ${STATUS_PATH} + if [ "${3}" == "FT" ] ; then ./${RUN_BINARY} +set fs_game osp +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg - elif [ "$3" == "CTFI" ] ; then + elif [ "${3}" == "CTFI" ] ; then ./${RUN_BINARY} +set fs_game osp +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg - elif [ "$3" == "TDI" ] ; then + elif [ "${3}" == "TDI" ] ; then ./${RUN_BINARY} +set fs_game osp +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg - elif [ "$3" == "FFAI" ] ; then + elif [ "${3}" == "FFAI" ] ; then ./${RUN_BINARY} +set fs_game osp +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg - elif [ "$3" == "CA" ] ; then + elif [ "${3}" == "CA" ] ; then ./${RUN_BINARY} +set fs_game osp +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg - elif [ "$3" == "CAI" ] ; then + elif [ "${3}" == "CAI" ] ; then ./${RUN_BINARY} +set fs_game osp +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg else ./${RUN_BINARY} +exec basic.cfg +exec server${3}.cfg +exec levels${3}-${2}.cfg +exec bots.cfg fi #clear_server - echo "Stopped" > $STATUS_PATH + echo "Stopped" > ${STATUS_PATH} fi -;; -ST|st|stop|STOP) + ;; + ST|st|stop|STOP) # Close previous sessions clear_server - echo "Stopped" > $STATUS_PATH -;; -CL|cl) + echo "Stopped" > ${STATUS_PATH} + ;; + CL|cl) # Clear all server logs clear_server_logs -;; -*) + ;; + *) # Show menu echo "" echo "Quake 3 Server Script v${VERSION}" echo "" echo "Config.files: ${RUN_PATH}/server/*.cfg" echo "Log.files: ${BASEQ3_PATH}/*.log" - echo "Status: $STATUS_PATH" + echo "Status: ${STATUS_PATH}" echo "" echo "Syntax: q3aServ.sh