├── .gitattributes ├── .gitignore ├── README.md ├── releases └── nquakesv_installer-linux-latest.tar.gz ├── scripts ├── config.example ├── start_servers.sh ├── stop_servers.sh ├── update.sh ├── update_binaries.sh ├── update_configs.sh ├── update_maps.sh └── update_scripts.sh └── src ├── INSTALL ├── LICENSE └── install_nquakesv.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | * eol=lf 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nQuake Server for Linux 2 | 3 | ### Docker 4 | 5 | If you're interested in running nQuakesv in Docker, you can find the relevant projects here: 6 | 7 | * [nQuakesv](https://github.com/nQuake/nquakesv) - Docker Compose project 8 | * [nQuakesv Docker](https://github.com/niclaslindstedt/nquakesv-docker) - Docker server image 9 | * [QTV Docker](https://github.com/niclaslindstedt/qtv-docker) - Docker QTV image 10 | * [QWFWD Docker](https://github.com/niclaslindstedt/qwfwd-docker) - Docker QWFWD image 11 | 12 | ## Install 13 | 14 | Run the following in a Linux shell: 15 | 16 | ``` 17 | sh <(curl -s https://raw.githubusercontent.com/nQuake/server-linux/master/src/install_nquakesv.sh) 18 | ``` 19 | 20 | You might need to install some prerequisites before running the install script: 21 | 22 | ``` 23 | apt-get install curl realpath screen unzip wget libc6-i386 24 | ``` 25 | 26 | ## Running nQuakesv 27 | 28 | ``` 29 | $(cat ~/.nquakesv/install_dir)/start_servers.sh 30 | ``` 31 | 32 | ## Stopping nQuakesv 33 | 34 | ``` 35 | $(cat ~/.nquakesv/install_dir)/stop_servers.sh 36 | ``` 37 | 38 | ## Crontab 39 | 40 | During installation, you can choose to install nQuakesv in your crontab. 41 | 42 | To do this manually, add the following to your crontab (or put a file with the contents below in /etc/cron.d/): 43 | 44 | ``` 45 | echo "*/10 * * * * \$(cat ~/.nquakesv/install_dir)/start_servers.sh >/dev/null 2>&1" | sudo tee /etc/cron.d/nquakesv >/dev/null 46 | ``` 47 | 48 | ## Settings 49 | 50 | Settings are contained in `~/.nquakesv/config`. 51 | 52 | To apply settings, you need to restart nQuakesv. 53 | 54 | ### Change number of ports 55 | 56 | Add a new port (28508): 57 | 58 | ``` 59 | touch ~/.nquakesv/ports/28508 60 | ``` 61 | 62 | Remove a port (28508): 63 | 64 | ``` 65 | rm ~/.nquakesv/ports/28508 66 | ``` 67 | 68 | ### QTV 69 | 70 | To enable qtv (port 28000): 71 | 72 | ``` 73 | echo 28000 > ~/.nquakesv/qtv 74 | ``` 75 | 76 | To disable qtv: 77 | 78 | ``` 79 | rm ~/.nquakesv/qtv 80 | ``` 81 | 82 | ### QWFWD 83 | 84 | To enable qwfwd (port 30000): 85 | 86 | ``` 87 | echo 30000 > ~/.nquakesv/qwfwd 88 | ``` 89 | 90 | To disable qwfwd: 91 | 92 | ``` 93 | rm ~/.nquakesv/qwfwd 94 | ``` 95 | 96 | ## Uninstallation 97 | 98 | ``` 99 | rm -rf $(cat ~/.nquakesv/install_dir) ~/.nquakesv 100 | ``` 101 | -------------------------------------------------------------------------------- /releases/nquakesv_installer-linux-latest.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nQuake/server-linux/6b683aa72943e42bf772b0d6d69c71ad0efe5cd0/releases/nquakesv_installer-linux-latest.tar.gz -------------------------------------------------------------------------------- /scripts/config.example: -------------------------------------------------------------------------------- 1 | SV_HOSTNAME="KTX Allround" 2 | SV_SERVERIP="127.0.0.1" 3 | SV_ADMININFO="Empezar " 4 | SV_RCON="myrconpassword" 5 | SV_QTVPASS="myqtvpassword" -------------------------------------------------------------------------------- /scripts/start_servers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | REGENERATE="" 4 | GENERATE_ONLY="" 5 | 6 | for i in "$@"; do 7 | case ${i} in 8 | --regenerate) 9 | REGENERATE=1 10 | shift 11 | ;; 12 | --generate-only) 13 | GENERATE_ONLY=1 14 | shift 15 | ;; 16 | esac 17 | done 18 | 19 | installdir=$(cat ~/.nquakesv/install_dir) 20 | 21 | . ~/.nquakesv/config 22 | 23 | generate_server_config() { 24 | inputfile=$1 25 | outputfile=${installdir}/ktx/pwd.cfg 26 | 27 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 28 | echo "rcon_password \"${SV_RCON}\"" > ${inputfile} 29 | echo "qtv_password \"\"" >> ${inputfile} 30 | [ "$(readlink -f $inputfile)" != "$(readlink -f $outputfile)" ] && cp -fn ${inputfile} ${outputfile} 31 | } 32 | } 33 | 34 | generate_qtv_config() { 35 | port=$1 36 | inputfile=$2 37 | outputfile=$3 38 | 39 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 40 | [ "$(readlink -f $inputfile)" != "$(readlink -f $outputfile)" ] && cp -r ${inputfile} ${outputfile} 41 | echo "hostname \"${SV_HOSTNAME} Qtv\"" >> ${outputfile} 42 | echo "admin_password \"${SV_QTVPASS}\"" >> ${outputfile} 43 | echo "mvdport ${port}" >> ${outputfile} 44 | 45 | ip=$(cat ~/.nquakesv/ip) 46 | echo "address ${ip}:${port}" >> ${outputfile} 47 | 48 | for f in ~/.nquakesv/ports/*; do 49 | port=$(basename ${f}) 50 | echo "qtv ${ip}:${port}" >> ${outputfile} 51 | done 52 | } 53 | } 54 | 55 | generate_qtv_script() { 56 | outputfile=${installdir}/run/qtv.sh 57 | 58 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 59 | echo "cd \$(cat ~/.nquakesv/install_dir)/qtv/ && screen -dmS qtv ./qtv.bin +exec qtv.cfg" > ${outputfile} 60 | chmod +x ${outputfile} 61 | } 62 | } 63 | 64 | generate_qwfwd_config() { 65 | port=$1 66 | inputfile=$2 67 | outputfile=$3 68 | 69 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 70 | [ "$(readlink -f $inputfile)" != "$(readlink -f $outputfile)" ] && cp -r ${inputfile} ${outputfile} 71 | echo "set hostname \"${SV_HOSTNAME} QWfwd\"" >> ${outputfile} 72 | echo "set net_port ${port}" >> ${outputfile} 73 | } 74 | } 75 | 76 | generate_qwfwd_script() { 77 | outputfile=${installdir}/run/qwfwd.sh 78 | 79 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 80 | echo "cd \$(cat ~/.nquakesv/install_dir)/qwfwd/ && screen -dmS qwfwd ./qwfwd.bin" > ${outputfile} 81 | chmod +x ${outputfile} 82 | } 83 | } 84 | 85 | generate_port_config() { 86 | port=$1 87 | num=$2 88 | outputfile=$3 89 | 90 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 91 | cat ${installdir}/ktx/port_template.cfg > ${outputfile} 92 | echo "set k_motd1 \"${SV_HOSTNAME} #${num}\"" >> ${outputfile} 93 | echo "hostname \"${SV_HOSTNAME}:${port}\"" >> ${outputfile} 94 | echo "sv_admininfo \"${SV_ADMININFO}\"" >> ${outputfile} 95 | echo "sv_serverip \"$(cat ~/.nquakesv/ip):${port}\"" >> ${outputfile} 96 | echo "qtv_streamport \"${port}\"" >> ${outputfile} 97 | } 98 | } 99 | 100 | generate_port_script() { 101 | port=$1 102 | num=$2 103 | outputfile=$3 104 | 105 | ( [ ! -f ${outputfile} ] || [ ! -z ${REGENERATE} ] ) && { 106 | echo "cd \$(cat ~/.nquakesv/install_dir)/ && screen -dmS qw_$port ./mvdsv -port ${port} -mem 64 -game ktx +exec port_${port}.cfg" > ${outputfile} 107 | chmod +x ${outputfile} 108 | } 109 | } 110 | 111 | generate_server_config ${installdir}/ktx/pwd.cfg 112 | 113 | num=0 114 | for f in ~/.nquakesv/ports/*; do 115 | num=$((${num}+1)) 116 | port=$(basename ${f}) 117 | generate_port_config ${port} ${num} ${installdir}/ktx/port_${port}.cfg 118 | generate_port_script ${port} ${num} ${installdir}/run/port_${port}.sh 119 | if [ -z "${GENERATE_ONLY}" ]; then 120 | printf "* Starting mvdsv #${num} (port ${port})..." 121 | count=$(ps ax | grep -v grep | grep "mvdsv -port ${port}" | wc -l) 122 | if [ ${count} -eq 0 ]; then 123 | ${installdir}/run/port_${port}.sh > /dev/null & 124 | echo "[OK]" 125 | else 126 | echo "[ALREADY RUNNING]" 127 | fi 128 | fi 129 | done 130 | 131 | if [ -f ~/.nquakesv/qtv ]; then 132 | qtvport=$(cat ~/.nquakesv/qtv) 133 | generate_qtv_config ${qtvport} ${installdir}/qtv/qtv_template.cfg ${installdir}/qtv/qtv.cfg 134 | generate_qtv_script 135 | if [ -z "${GENERATE_ONLY}" ]; then 136 | printf "* Starting qtv (port ${qtvport})..." 137 | count=$(ps ax | grep -v grep | grep "qtv.bin +exec qtv.cfg" | wc -l) 138 | if [ ${count} -eq 0 ]; then 139 | $(cat ~/.nquakesv/install_dir)/run/qtv.sh > /dev/null & 140 | echo "[OK]" 141 | else 142 | echo "[ALREADY RUNNING]" 143 | fi 144 | fi 145 | fi 146 | 147 | if [ -f ~/.nquakesv/qwfwd ]; then 148 | qwfwdport=$(cat ~/.nquakesv/qwfwd) 149 | generate_qwfwd_config ${qwfwdport} ${installdir}/qwfwd/qwfwd_template.cfg ${installdir}/qwfwd/qwfwd.cfg 150 | generate_qwfwd_script 151 | if [ -z "${GENERATE_ONLY}" ]; then 152 | printf "* Starting qwfwd (port ${qwfwdport})..." 153 | count=$(ps ax | grep -v grep | grep "./qwfwd.bin" | wc -l) 154 | if [ ${count} -eq 0 ]; then 155 | $(cat ~/.nquakesv/install_dir)/run/qwfwd.sh > /dev/null & 156 | echo "[OK]" 157 | else 158 | echo "[ALREADY RUNNING]" 159 | fi 160 | fi 161 | fi 162 | -------------------------------------------------------------------------------- /scripts/stop_servers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $(ps ax | grep -v grep | grep "start_servers.sh" | wc -l) -gt 0 ]; then 4 | killall -9 start_servers.sh 5 | fi 6 | 7 | for f in ~/.nquakesv/ports/*; do 8 | port=$(basename ${f}) 9 | count=$(ps ax | grep -v grep | grep "mvdsv.*-port ${port}" | wc -l) 10 | printf "* Stopping mvdsv (port ${port})..." 11 | if [ ${count} -gt 0 ]; then 12 | pid=$(ps ax | grep -v grep | grep "mvdsv.*-port ${port}" | grep "SCREEN" | awk '{print $1}') 13 | kill -9 ${pid} >/dev/null 14 | echo "[OK]" 15 | else 16 | echo "[NOT RUNNING]" 17 | fi 18 | done 19 | 20 | if [ -f ~/.nquakesv/qtv ]; then 21 | qtvport=$(cat ~/.nquakesv/qtv) 22 | printf "* Stopping qtv (port ${qtvport})..." 23 | count=$(ps ax | grep -v grep | grep "qtv.bin +exec qtv.cfg" | wc -l) 24 | if [ ${count} -gt 0 ]; then 25 | pid=$(ps ax | grep -v grep | grep "qtv.bin +exec qtv.cfg" | grep "SCREEN" | awk '{print $1}') 26 | kill -9 ${pid} >/dev/null 27 | echo "[OK]" 28 | else 29 | echo "[NOT RUNNING]" 30 | fi 31 | fi 32 | 33 | if [ -f ~/.nquakesv/qwfwd ]; then 34 | qwfwdport=$(cat ~/.nquakesv/qwfwd) 35 | printf "* Stopping qwfwd (port ${qwfwdport})..." 36 | count=$(ps ax | grep -v grep | grep "qwfwd.bin" | wc -l) 37 | if [ ${count} -gt 0 ]; then 38 | pid=$(ps ax | grep -v grep | grep "qwfwd.bin" | grep "SCREEN" | awk '{print $1}') 39 | kill -9 ${pid} >/dev/null 40 | echo "[OK]" 41 | else 42 | echo "[NOT RUNNING]" 43 | fi 44 | fi 45 | 46 | screen -wipe 47 | -------------------------------------------------------------------------------- /scripts/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Obsolete file, replaced by update_scripts.sh - Only here for backwards compatibility 4 | 5 | directory=$(cat ~/.nquakesv/install_dir) 6 | 7 | nqecho() { 8 | nqnecho "$* \n" 9 | } 10 | 11 | nqnecho() { 12 | [ -z "${quiet}" ] && printf "$*" 13 | } 14 | 15 | nqeecho() { 16 | [ -z "${extraquiet}" ] && printf "$*" 17 | } 18 | 19 | nqiecho() { 20 | [ -z "${noninteractive}" ] && nqecho $* 21 | } 22 | 23 | nqwget() { 24 | [ -n "${quiet}" ] && { 25 | wget -q $* >/dev/null 2>&1 26 | } || { 27 | wget $* 28 | } 29 | } 30 | 31 | githubdl() { 32 | localpath=$1 33 | remotepath=$2 34 | nqwget -q -O ${localpath} https://raw.githubusercontent.com/nQuake/server-linux/master/${remotepath} 35 | chmod +x ${localpath} 36 | } 37 | 38 | githubd2() { 39 | localpath=$1 40 | remotepath=$2 41 | nqwget -q -O ${localpath} https://raw.githubusercontent.com/ciscon/random/master/${remotepath} 42 | chmod +x ${localpath} 43 | } 44 | 45 | nqnecho "* Downloading shell scripts..." 46 | (githubdl ${directory}/start_servers.sh scripts/start_servers.sh && \ 47 | githubdl ${directory}/stop_servers.sh scripts/stop_servers.sh && \ 48 | githubdl ${directory}/update_scripts.sh scripts/update_scripts.sh && \ 49 | githubdl ${directory}/update_binaries.sh scripts/update_binaries.sh && \ 50 | githubdl ${directory}/update_configs.sh scripts/update_configs.sh && \ 51 | githubdl ${directory}/update_maps.sh scripts/update_maps.sh && \ 52 | githubd2 ${directory}/nquakesv-build-mvdsv.sh quake-scripts/build/nquakesv-build-mvdsv.sh && \ 53 | githubd2 ${directory}/nquakesv-build-ktx.sh quake-scripts/build/nquakesv-build-ktx.sh && echo done) || nqecho fail 54 | nqecho 55 | 56 | # Convert DOS files to UNIX 57 | nqnecho "* Converting DOS files to UNIX..." 58 | for file in $(find ${directory} -iname "*.sh"); do 59 | [ -f "${file}" ] && sed -i 's/\r$//' ${file} 60 | done 61 | nqecho "done" 62 | 63 | nqecho "IMPORTANT: update.sh has been replaced by update_scripts.sh" 64 | nqecho "You can delete update.sh" 65 | nqecho 66 | 67 | exit 0 68 | -------------------------------------------------------------------------------- /scripts/update_binaries.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # nQuakesv binary update bash script (for Linux) 4 | # by Empezar 5 | 6 | # Parameters: --random-mirror --restart --no-restart 7 | 8 | # Check if unzip is installed 9 | unzip=`which unzip` 10 | if [ "$unzip" = "" ] 11 | then 12 | echo "Unzip is not installed. Please install it and run the nQuakesv installation again." 13 | exit 14 | fi 15 | 16 | # Change folder to nQuakesv 17 | cd `cat ~/.nquakesv/install_dir` 18 | 19 | # Check if QTV and QWFWD is installed 20 | if [ -d "qtv" ]; then qtv="1"; fi; 21 | if [ -d "qwfwd" ]; then qwfwd=1; fi; 22 | 23 | echo 24 | echo "Welcome to the nQuakesv binary updater" 25 | echo "======================================" 26 | echo 27 | 28 | # What binaries to use 29 | binary=`uname -m` 30 | 31 | # Download nquake.ini 32 | mkdir tmp 33 | cd tmp 34 | wget --inet4-only -q -O nquake.ini https://raw.githubusercontent.com/nQuake/client-win32/master/etc/nquake.ini 35 | if [ -s "nquake.ini" ] 36 | then 37 | echo foo >> /dev/null 38 | else 39 | echo "Error: Could not download nquake.ini. Better luck next time. Exiting." 40 | exit 41 | fi 42 | 43 | # List all the available mirrors 44 | echo "From what mirror would you like to download the binaries?" 45 | grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl 46 | if [ "$1" == "--random-mirror" ] || [ "$2" == "--random-mirror" ] || [ "$3" == "--random-mirror" ] || [ "$4" == "--random-mirror" ]; then 47 | mirror="" 48 | else 49 | read -p "Enter mirror number [random]: " mirror 50 | fi 51 | mirror=$(grep "^$mirror=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 52 | if [ "$mirror" = "" ] 53 | then 54 | echo;echo -n "* Using mirror: " 55 | RANGE=$(expr$(grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl | tail -n1 | cut -f1) + 1) 56 | while [ "$mirror" = "" ] 57 | do 58 | number=$RANDOM 59 | let "number %= $RANGE" 60 | mirror=$(grep "^$number=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 61 | mirrorname=$(grep "^$number=\".*" nquake.ini | cut -d "\"" -f2) 62 | done 63 | echo "$mirrorname" 64 | fi 65 | mkdir -p id1 66 | echo 67 | 68 | # Download binaries 69 | echo "=== Downloading ===" 70 | if [ "$binary" == "x86_64" ] 71 | then 72 | wget --inet4-only -O sv-bin-x64.zip $mirror/sv-bin-x64.zip 73 | else 74 | wget --inet4-only -O sv-bin-x86.zip $mirror/sv-bin-x86.zip 75 | fi 76 | 77 | # Terminate installation if not all packages were downloaded 78 | if [ -s "sv-bin-x86.zip" -o -s "sv-bin-x64.zip" ] 79 | then 80 | if [ -s "sv-bin-x86.zip" ] 81 | then 82 | if [ "$(du sv-bin-x86.zip | cut -f1)" \> "0" ] 83 | then 84 | echo foo >> /dev/null 85 | else 86 | echo "Error: The binaries failed to download. Better luck next time. Exiting." 87 | rm -rf sv-bin-x86.zip nquake.ini 88 | if [ "$created" = "1" ] 89 | then 90 | cd .. 91 | read -p "The directory $directory is about to be removed, press Enter to confirm or CTRL+C to exit." remove 92 | rm -rf tmp 93 | fi 94 | exit 95 | fi 96 | else 97 | if [ "$(du sv-bin-x64.zip | cut -f1)" \> "0" ] 98 | then 99 | echo foo >> /dev/null 100 | else 101 | echo "Error: The binaries failed to download. Better luck next time. Exiting." 102 | rm -rf sv-bin-x64.zip nquake.ini 103 | if [ "$created" = "1" ] 104 | then 105 | cd .. 106 | read -p "The directory $directory is about to be removed, press Enter to confirm or CTRL+C to exit." remove 107 | rm -rf tmp 108 | fi 109 | exit 110 | fi 111 | fi 112 | else 113 | echo "Error: The binaries failed to download. Better luck next time. Exiting." 114 | cd .. 115 | rm -rf tmp 116 | exit 117 | fi 118 | 119 | # Ask to restart servers 120 | if [ "$1" == "--restart" ] || [ "$2" == "--restart" ] || [ "$3" == "--restart" ] || [ "$4" == "--restart" ]; then 121 | restart="y" 122 | else 123 | if [ "$1" == "--no-restart" ] || [ "$2" == "--no-restart" ] || [ "$3" == "--no-restart" ] || [ "$4" == "--no-restart" ]; then 124 | restart="n" 125 | else 126 | read -p "Do you want the script to stop and restart your servers and proxies? (y/n) [n]: " restart 127 | echo 128 | fi 129 | fi 130 | 131 | # Install updates 132 | echo "=== Installing ===" 133 | # Extract binaries 134 | echo -n "* Extracting binaries..." 135 | if [ "$binary" == "x86_64" ] 136 | then 137 | unzip -qqo sv-bin-x64.zip 2> /dev/null;echo "done" 138 | else 139 | unzip -qqo sv-bin-x86.zip 2> /dev/null;echo "done" 140 | fi 141 | 142 | # Set the correct permissions 143 | echo -n "* Setting permissions..." 144 | chmod -f +x mvdsv 2> /dev/null 145 | chmod -f -x ../mvdsv 2> /dev/null 146 | chmod 644 ktx/qwprogs.so 2> /dev/null 147 | if [ "$qtv" == "1" ] 148 | then 149 | chmod -f +x qtv/qtv.bin 2> /dev/null 150 | chmod -f -x ../qtv/qtv.bin 2> /dev/null 151 | fi 152 | if [ "$qwfwd" == "1" ] 153 | then 154 | chmod -f +x qwfwd/qwfwd.bin 2> /dev/null 155 | chmod -f -x ../qwfwd/qwfwd.bin 2> /dev/null 156 | fi 157 | echo "done" 158 | 159 | # Stop servers 160 | if [ "$restart" == "y" ] 161 | then 162 | echo "* Stopping servers and proxies...done" 163 | ../stop_servers.sh 164 | fi 165 | 166 | # Move binaries into place 167 | echo -n "* Moving binaries into place..." 168 | if [ -f ../mvdsv ]; then 169 | mv ../mvdsv ../mvdsv.old 170 | fi 171 | mv mvdsv ../ 172 | if [ -f ../ktx/qwprogs.so ]; then 173 | mv ../ktx/qwprogs.so ../ktx/qwprogs.so.old 174 | fi 175 | mv ktx/qwprogs.so ../ktx/ 176 | if [ "$qtv" == "1" ] 177 | then 178 | if [ -f ../qtv/qtv.bin ]; then 179 | mv ../qtv/qtv.bin ../qtv/qtv.bin.old 180 | fi 181 | mv qtv/qtv.bin ../qtv/ 182 | fi 183 | if [ "$qwfwd" == "1" ] 184 | then 185 | if [ -f ../qwfwd/qwfwd.bin ]; then 186 | mv ../qwfwd/qwfwd.bin ../qwfwd/qwfwd.bin.old 187 | fi 188 | mv qwfwd/qwfwd.bin ../qwfwd/ 189 | fi 190 | echo "done" 191 | 192 | # Remove temporary directory 193 | echo -n "* Cleaning up..." 194 | cd .. 195 | rm -rf tmp 196 | echo "done" 197 | 198 | # Restart servers 199 | if [ "$restart" == "y" ] 200 | then 201 | echo "* Starting servers and proxies...done" 202 | ./start_servers.sh > /dev/null 2>&1 203 | fi 204 | 205 | echo;echo "Upgrade complete." 206 | echo 207 | -------------------------------------------------------------------------------- /scripts/update_configs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # nQuakesv config update bash script (for Linux) 4 | # by Empezar 5 | 6 | # Parameters: --random-mirror --restart --no-restart --sure 7 | 8 | # Check if unzip is installed 9 | unzip=`which unzip` 10 | if [ "$unzip" = "" ] 11 | then 12 | echo "Unzip is not installed. Please install it and run the nQuakesv installation again." 13 | exit 14 | fi 15 | 16 | # Change folder to nQuakesv 17 | cd `cat ~/.nquakesv/install_dir` 18 | 19 | echo 20 | echo "Welcome to the nQuakesv config updater" 21 | echo "======================================" 22 | echo 23 | 24 | # Download nquake.ini 25 | mkdir tmp 26 | cd tmp 27 | wget --inet4-only -q -O nquake.ini https://raw.githubusercontent.com/nQuake/client-win32/master/etc/nquake.ini 28 | if [ -s "nquake.ini" ] 29 | then 30 | echo foo >> /dev/null 31 | else 32 | echo "Error: Could not download nquake.ini. Better luck next time. Exiting." 33 | cd .. 34 | rm -rf tmp 35 | exit 36 | fi 37 | 38 | # List all the available mirrors 39 | echo "From what mirror would you like to download the configs?" 40 | grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl 41 | if [ "$1" == "--random-mirror" ] || [ "$2" == "--random-mirror" ] || [ "$3" == "--random-mirror" ] || [ "$4" == "--random-mirror" ]; then 42 | mirror="" 43 | else 44 | read -p "Enter mirror number [random]: " mirror 45 | fi 46 | mirror=$(grep "^$mirror=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 47 | if [ "$mirror" = "" ] 48 | then 49 | echo;echo -n "* Using mirror: " 50 | RANGE=$(expr$(grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl | tail -n1 | cut -f1) + 1) 51 | while [ "$mirror" = "" ] 52 | do 53 | number=$RANDOM 54 | let "number %= $RANGE" 55 | mirror=$(grep "^$number=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 56 | mirrorname=$(grep "^$number=\".*" nquake.ini | cut -d "\"" -f2) 57 | done 58 | echo "$mirrorname" 59 | fi 60 | echo 61 | 62 | # Download maps 63 | echo "=== Downloading ===" 64 | wget --inet4-only -O sv-configs.zip $mirror/sv-configs.zip 65 | 66 | # Terminate installation if not all packages were downloaded 67 | if [ -s "sv-configs.zip" ] 68 | then 69 | if [ "$(du sv-configs.zip | cut -f1)" \> "0" ] 70 | then 71 | echo foo >> /dev/null 72 | else 73 | echo "Error: The configs failed to download. Better luck next time. Exiting." 74 | cd .. 75 | rm -rf tmp 76 | exit 77 | fi 78 | else 79 | echo "Error: The configs failed to download. Better luck next time. Exiting." 80 | cd .. 81 | rm -rf tmp 82 | exit 83 | fi 84 | 85 | # Ask to restart servers 86 | if [ "$1" == "--restart" ] || [ "$2" == "--restart" ] || [ "$3" == "--restart" ] || [ "$4" == "--restart" ]; then 87 | restart="y" 88 | else 89 | if [ "$1" == "--no-restart" ] || [ "$2" == "--no-restart" ] || [ "$3" == "--no-restart" ] || [ "$4" == "--no-restart" ]; then 90 | restart="n" 91 | else 92 | read -p "Do you want the script to stop and restart your servers and proxies? (y/n) [n]: " restart 93 | echo 94 | fi 95 | fi 96 | 97 | # Install updates 98 | echo "=== Installing ===" 99 | echo -n "* Extracting configs..." 100 | unzip -qqo sv-configs.zip 2> /dev/null;echo "done" 101 | echo -n "* Setting permissions..." 102 | find . -type f -exec chmod -f 644 {} \; 103 | find . -type d -exec chmod -f 755 {} \; 104 | echo "done" 105 | # Convert DOS files to UNIX 106 | echo -n "* Converting DOS files to UNIX..." 107 | for file in $(find .) 108 | do 109 | if [ -f "$file" ] 110 | then 111 | awk '{ sub("\r$", ""); print }' $file > /tmp/.nquakesv.tmp 112 | mv /tmp/.nquakesv.tmp $file 113 | fi 114 | done 115 | echo "done" 116 | 117 | # Stop servers 118 | if [ "$restart" == "y" ] 119 | then 120 | echo "* Stopping servers and proxies...done" 121 | ../stop_servers.sh 122 | fi 123 | 124 | # Move configs into place 125 | if [ "$1" == "--sure" ] || [ "$2" == "--sure" ] || [ "$3" == "--sure" ] || [ "$4" == "--sure" ]; then 126 | sure="y" 127 | else 128 | echo;echo "Your old configuration files will now be removed and replaced. The settings that you picked during setup will be untouched." 129 | echo;read -p "Are you sure you want to continue? (y/n) [y]: " sure 130 | echo 131 | fi 132 | if [ "$sure" != "n" ] 133 | then 134 | echo -n "* Moving configs into place..." 135 | rm -rf ../ktx/bots ../ktx/configs ../ktx/modes ../ktx/race 136 | mv ktx/bots ../ktx/bots 137 | mv ktx/configs ../ktx/configs 138 | mv ktx/modes ../ktx/modes 139 | mv ktx/race ../ktx/race 140 | mv ktx/* ../ktx/ 141 | echo "done" 142 | fi 143 | 144 | # Remove temporary directory 145 | echo -n "* Cleaning up..." 146 | cd .. 147 | rm -rf tmp 148 | echo "done" 149 | 150 | # Restart servers 151 | if [ "$restart" == "y" ] 152 | then 153 | echo "* Starting servers and proxies...done" 154 | ./start_servers.sh > /dev/null 2>&1 155 | fi 156 | 157 | echo;echo "Update complete." 158 | echo 159 | -------------------------------------------------------------------------------- /scripts/update_maps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # nQuakesv maps update bash script (for Linux) 4 | # by Empezar 5 | 6 | # Parameters: --random-mirror --restart --no-restart 7 | 8 | # Check if unzip is installed 9 | unzip=`which unzip` 10 | if [ "$unzip" = "" ] 11 | then 12 | echo "Unzip is not installed. Please install it and run the nQuakesv installation again." 13 | exit 14 | fi 15 | 16 | # Change folder to nQuakesv 17 | cd `cat ~/.nquakesv/install_dir` 18 | 19 | echo 20 | echo "Welcome to the nQuakesv maps updater" 21 | echo "====================================" 22 | echo 23 | 24 | # Download nquake.ini 25 | mkdir -p tmp 26 | cd tmp 27 | wget --inet4-only -q -O nquake.ini https://raw.githubusercontent.com/nQuake/client-win32/master/etc/nquake.ini 28 | if [ -s "nquake.ini" ] 29 | then 30 | echo foo >> /dev/null 31 | else 32 | echo "Error: Could not download nquake.ini. Better luck next time. Exiting." 33 | cd .. 34 | rm -rf tmp 35 | exit 36 | fi 37 | 38 | # List all the available mirrors 39 | echo "From what mirror would you like to download the maps?" 40 | grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl 41 | if [ "$1" == "--random-mirror" ] || [ "$2" == "--random-mirror" ] || [ "$3" == "--random-mirror" ] || [ "$4" == "--random-mirror" ]; then 42 | mirror="" 43 | else 44 | read -p "Enter mirror number [random]: " mirror 45 | fi 46 | mirror=$(grep "^$mirror=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 47 | if [ "$mirror" = "" ] 48 | then 49 | echo;echo -n "* Using mirror: " 50 | RANGE=$(expr$(grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl | tail -n1 | cut -f1) + 1) 51 | while [ "$mirror" = "" ] 52 | do 53 | number=$RANDOM 54 | let "number %= $RANGE" 55 | mirror=$(grep "^$number=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 56 | mirrorname=$(grep "^$number=\".*" nquake.ini | cut -d "\"" -f2) 57 | done 58 | echo "$mirrorname" 59 | fi 60 | echo 61 | 62 | # Download maps 63 | echo "=== Downloading ===" 64 | wget --inet4-only -O sv-maps.zip $mirror/sv-maps.zip 65 | if [ -s "sv-maps.zip" ] 66 | then 67 | if [ "$(du sv-maps.zip | cut -f1)" \> "0" ] 68 | then 69 | wget --inet4-only -O sv-maps-gpl.zip $mirror/sv-maps-gpl.zip 70 | fi 71 | fi 72 | 73 | # Terminate installation if not all packages were downloaded 74 | if [ -s "sv-maps-gpl.zip" ] 75 | then 76 | if [ "$(du sv-maps-gpl.zip | cut -f1)" \> "0" ] 77 | then 78 | echo foo >> /dev/null 79 | else 80 | echo "Error: The maps failed to download. Better luck next time. Exiting." 81 | cd .. 82 | rm -rf tmp 83 | exit 84 | fi 85 | else 86 | echo "Error: The maps failed to download. Better luck next time. Exiting." 87 | cd .. 88 | rm -rf tmp 89 | exit 90 | fi 91 | 92 | echo -n "* Extracting maps..." 93 | unzip -qqo sv-maps.zip 2> /dev/null;echo "done" 94 | 95 | echo -n "* Extracting GPL maps..." 96 | unzip -qqo sv-maps-gpl.zip 2> /dev/null;echo "done" 97 | 98 | echo -n "* Downloading core maps..." 99 | wget -P qw/maps -r --no-parent -N -nd -A "*.bsp" -A "*.ent" https://maps.quakeworld.nu/core/ 100 | 101 | echo -n "* Setting permissions..." 102 | chmod 644 qw/maps/* 2> /dev/null 103 | 104 | echo "done" 105 | 106 | # Ask to restart servers 107 | if [ "$1" == "--restart" ] || [ "$2" == "--restart" ] || [ "$3" == "--restart" ] || [ "$4" == "--restart" ]; then 108 | restart="y" 109 | else 110 | if [ "$1" == "--no-restart" ] || [ "$2" == "--no-restart" ] || [ "$3" == "--no-restart" ] || [ "$4" == "--no-restart" ]; then 111 | restart="n" 112 | else 113 | read -p "Do you want the script to stop and restart your servers and proxies? (y/n) [n]: " restart 114 | echo 115 | fi 116 | fi 117 | 118 | # Install updates 119 | echo "=== Installing ===" 120 | 121 | # Stop servers 122 | if [ "$restart" == "y" ] 123 | then 124 | echo "* Stopping servers and proxies...done" 125 | ../stop_servers.sh 126 | fi 127 | 128 | # Move maps into place 129 | echo -n "* Moving maps into place..." 130 | mv qw/maps/* ../qw/maps/ 131 | echo "done" 132 | 133 | # Remove temporary directory 134 | echo -n "* Cleaning up..." 135 | cd .. 136 | rm -rf tmp 137 | echo "done" 138 | 139 | # Restart servers 140 | if [ "$restart" == "y" ] 141 | then 142 | echo "* Starting servers and proxies...done" 143 | ./start_servers.sh > /dev/null 2>&1 144 | fi 145 | 146 | echo;echo "Update complete." 147 | echo 148 | -------------------------------------------------------------------------------- /scripts/update_scripts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | directory=$(cat ~/.nquakesv/install_dir) 4 | 5 | nqecho() { 6 | nqnecho "$* \n" 7 | } 8 | 9 | nqnecho() { 10 | [ -z "${quiet}" ] && printf "$*" 11 | } 12 | 13 | nqeecho() { 14 | [ -z "${extraquiet}" ] && printf "$*" 15 | } 16 | 17 | nqiecho() { 18 | [ -z "${noninteractive}" ] && nqecho $* 19 | } 20 | 21 | nqwget() { 22 | [ -n "${quiet}" ] && { 23 | wget -q $* >/dev/null 2>&1 24 | } || { 25 | wget $* 26 | } 27 | } 28 | 29 | githubdl() { 30 | localpath=$1 31 | remotepath=$2 32 | nqwget -q -O ${localpath} https://raw.githubusercontent.com/nQuake/server-linux/master/${remotepath} 33 | chmod +x ${localpath} 34 | } 35 | 36 | githubd2() { 37 | localpath=$1 38 | remotepath=$2 39 | nqwget -q -O ${localpath} https://raw.githubusercontent.com/ciscon/random/master/${remotepath} 40 | chmod +x ${localpath} 41 | } 42 | 43 | nqnecho "* Downloading shell scripts..." 44 | (githubdl ${directory}/start_servers.sh scripts/start_servers.sh && \ 45 | githubdl ${directory}/stop_servers.sh scripts/stop_servers.sh && \ 46 | githubdl ${directory}/update_scripts.sh scripts/update_scripts.sh && \ 47 | githubdl ${directory}/update_binaries.sh scripts/update_binaries.sh && \ 48 | githubdl ${directory}/update_configs.sh scripts/update_configs.sh && \ 49 | githubdl ${directory}/update_maps.sh scripts/update_maps.sh && \ 50 | githubd2 ${directory}/nquakesv-build-mvdsv.sh quake-scripts/build/nquakesv-build-mvdsv.sh && \ 51 | githubd2 ${directory}/nquakesv-build-ktx.sh quake-scripts/build/nquakesv-build-ktx.sh && echo done) || nqecho fail 52 | nqecho 53 | 54 | # Convert DOS files to UNIX 55 | nqnecho "* Converting DOS files to UNIX..." 56 | for file in $(find ${directory} -iname "*.sh"); do 57 | [ -f "${file}" ] && sed -i 's/\r$//' ${file} 58 | done 59 | nqecho "done" 60 | 61 | exit 0 62 | -------------------------------------------------------------------------------- /src/INSTALL: -------------------------------------------------------------------------------- 1 | nQuakesv for Linux 2 | ================== 3 | To install nQuakesv, locate the installer tarball and extract it. 4 | 5 | 6 | $ tar xvzf nquakesv_installer-linux-latest.tar.gz 7 | 8 | 9 | Once you have extracted the package, run the install script. 10 | 11 | $ ./install_nquakesv.sh 12 | 13 | Follow the instructions and answer the questions. Do not simply press ENTER 14 | through the setup, or your server will be indistinguishable from others and 15 | very insecure. If you have access to a full version of Quake, please specify 16 | where pak1.pak is located to make the server more complete. 17 | 18 | Thank you for downloading nQuakesv 19 | - 20 | 2018-03-14 21 | -------------------------------------------------------------------------------- /src/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 6 | 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | Preamble 10 | The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. 11 | 12 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. 13 | 14 | To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. 15 | 16 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 17 | 18 | We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. 19 | 20 | Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. 21 | 22 | Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. 23 | 24 | The precise terms and conditions for copying, distribution and modification follow. 25 | 26 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 27 | 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". 28 | 29 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 30 | 31 | 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 32 | 33 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 34 | 35 | 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 36 | 37 | 38 | a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. 39 | 40 | b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. 41 | 42 | c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) 43 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 44 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. 45 | 46 | In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 47 | 48 | 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: 49 | 50 | a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 51 | 52 | b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 53 | 54 | c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) 55 | The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 56 | If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 57 | 58 | 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 59 | 60 | 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 61 | 62 | 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 63 | 64 | 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. 65 | 66 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. 67 | 68 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 69 | 70 | This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 71 | 72 | 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 73 | 74 | 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 75 | 76 | Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 77 | 78 | 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 79 | 80 | NO WARRANTY 81 | 82 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 83 | 84 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 85 | 86 | 87 | END OF TERMS AND CONDITIONS 88 | -------------------------------------------------------------------------------- /src/install_nquakesv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Usage info 4 | show_help() { 5 | cat << EOF 6 | usage: install_nquakesv.sh [-h|--help] [-n|--non-interactive] 7 | [-q|--quiet] [-qq|--extra-quiet] 8 | [-o|--hostname=] 9 | [-p|--number-of-ports=] [-nt|--no-qtv] [-nf|--no-qwfwd] 10 | [-l|--listen-address=
] 11 | [-a|--admin=] [-e|--admin-email=] 12 | [-r|--rcon-password=] [-y|--qtv-password=] 13 | [-s[=]|--search-pak[=]] 14 | [-c|--no-cron] [TARGETDIR] 15 | [-u|--no-update-config] 16 | [-b|--no-build] 17 | 18 | -h, --help display this help and exit. 19 | -n, --non-interactive non-interactive mode (use defaults or command line 20 | parameters, and do not prompt for anything). 21 | -q, --quiet do not output informative messages during setup. this 22 | will not silence messages that require interaction. 23 | -qq, --extra-quiet do not output errors during setup. 24 | -o, --hostname hostname of the server. 25 | -p, --number-of-ports number of ports to run. 26 | -t, --qtv install qtv (default, kept for backwards compatibility). 27 | -f, --qwfwd install qwfwd proxy (default, kept for backwards compatibility). 28 | -nt, --no-qtv do not install qtv. 29 | -nf, --no-qwfwd do not install qwfwd proxy. 30 | -l, --listen-address fully qualified domain name (fqdn) or IP address. 31 | -a, --admin administrator name. 32 | -e, --admin-email administrator e-mail. 33 | -r, --rcon-password rcon password. 34 | -y, --qtv-password qtv password. 35 | -s, --search-pak search for pak1.pak during setup, specify a directory 36 | to start searching there instead of in home folder. 37 | -c, --no-cron don't add cron job. 38 | -u, --no-update-config don't update configuration files in ~/.nquakesv. 39 | -b, --no-build don't run nquakesv-build-mvdsv.sh and nquakesv-build-ktx.sh scripts to build mvdsv and ktx. 40 | EOF 41 | } 42 | 43 | created=0 44 | nondefaultrcon= 45 | 46 | # Parse command line parameters 47 | noninteractive="" 48 | quiet="" 49 | extraquiet="" 50 | nqhostname="" 51 | nqnumports="" 52 | nqinstallqtv="" 53 | nqinstallqwfwd="" 54 | nqaddr="" 55 | nqadmin="" 56 | nqemail="" 57 | nqrcon="" 58 | nqqtvpassword="" 59 | nqsearchpak="" 60 | searchdir="" 61 | nqaddcron="" 62 | nqupdateconfig="" 63 | nqbuild="" 64 | nqinstalldir="" 65 | 66 | for i in "$@"; do 67 | case ${i} in 68 | -h|--help) 69 | show_help 70 | exit 0 71 | ;; 72 | -n|--non-interactive) 73 | noninteractive=1 74 | shift 75 | ;; 76 | -q|--quiet) 77 | quiet=1 78 | shift 79 | ;; 80 | -qq|--extra-quiet) 81 | extraquiet=1 82 | shift 83 | ;; 84 | -o=*|--hostname=*) 85 | nqhostname="${i#*=}" 86 | shift 87 | ;; 88 | -p=*|--number-of-ports=*) 89 | nqnumports="${i#*=}" 90 | shift 91 | ;; 92 | -t|--qtv) 93 | nqinstallqtv="y" 94 | shift 95 | ;; 96 | -f|--qwfwd) 97 | nqinstallqwfwd="y" 98 | shift 99 | ;; 100 | -nt|--no-qtv) 101 | nqinstallqtv="n" 102 | shift 103 | ;; 104 | -nf|--no-qwfwd) 105 | nqinstallqwfwd="n" 106 | shift 107 | ;; 108 | -l=*|--listen-address=*) 109 | nqaddr="${i#*=}" 110 | shift 111 | ;; 112 | -a=*|--admin=*) 113 | nqadmin="${i#*=}" 114 | shift 115 | ;; 116 | -e=*|--admin-email=*) 117 | nqemail="${i#*=}" 118 | shift 119 | ;; 120 | -r=*|--rcon-password=*) 121 | nqrcon="${i#*=}" 122 | nondefaultrcon=1 123 | shift 124 | ;; 125 | -y=*|--qtv-password=*) 126 | nqqtvpassword="${i#*=}" 127 | shift 128 | ;; 129 | -s=*|--search-pak=*) 130 | nqsearchpak="y" 131 | searchdir="${i#*=}" 132 | shift 133 | ;; 134 | -s|--search-pak) 135 | nqsearchpak="y" 136 | shift 137 | ;; 138 | -c|--no-cron) 139 | nqaddcron="n" 140 | shift 141 | ;; 142 | -u|--no-update-config) 143 | nqupdateconfig="n" 144 | shift 145 | ;; 146 | -b|--no-build) 147 | nqbuild="n" 148 | shift 149 | ;; 150 | *) 151 | nqinstalldir="${i#*=}" 152 | ;; 153 | esac 154 | done 155 | 156 | # Defaults (use cmdline parameters) 157 | defaultdir=${nqinstalldir:-\~/nquakesv} 158 | defaulthostname=${nqhostname:-"KTX Allround"} 159 | defaultports=${nqnumports:-4} 160 | defaultqtv=${nqinstallqtv:-y} 161 | defaultqwfwd=${nqinstallqwfwd:-y} 162 | defaultadmin=${nqadmin:-${USER}} 163 | defaultemail=${nqemail:-${defaultadmin}@example.com} 164 | defaultrcon=${nqrcon:-$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12;echo)} 165 | defaultqtvpass=${nqqtvpassword:-$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12;echo)} 166 | defaultsearchoption=${nqsearchpak:-n} 167 | defaultsearchdir=${searchdir:-\~/} 168 | defaultaddcron=${nqaddcron:-y} 169 | defaultupdateconfig=${nqupdateconfig:-y} 170 | defaultbuild=${nqbuild:-y} 171 | 172 | error() { 173 | printf "ERROR: %s\n" "$*" 174 | [ "${created}" -eq 1 ] && { 175 | cd 176 | nqeecho "The directory ${directory} is about to be removed, press ENTER to confirm or CTRL+C to exit." 177 | read dummy 178 | rm -rf ${directory} 179 | } 180 | exit 1 181 | } 182 | 183 | nqecho() { 184 | nqnecho "$* \n" 185 | } 186 | 187 | nqnecho() { 188 | [ -z "${quiet}" ] && printf "$*" 189 | } 190 | 191 | nqeecho() { 192 | [ -z "${extraquiet}" ] && printf "$*" 193 | } 194 | 195 | nqiecho() { 196 | [ -z "${noninteractive}" ] && nqecho $* 197 | } 198 | 199 | nqwget() { 200 | [ -n "${quiet}" ] && { 201 | wget -q $* >/dev/null 2>&1 202 | } || { 203 | wget $* 204 | } 205 | } 206 | 207 | githubdl() { 208 | localpath=$1 209 | remotepath=$2 210 | nqwget -q -O ${localpath} https://raw.githubusercontent.com/nQuake/server-linux/master/${remotepath} 211 | chmod +x ${localpath} 212 | } 213 | 214 | githubd2() { 215 | localpath=$1 216 | remotepath=$2 217 | nqwget -q -O ${localpath} https://raw.githubusercontent.com/ciscon/random/master/${remotepath} 218 | chmod +x ${localpath} 219 | } 220 | 221 | # Check if unzip, curl, wget and screen is installed 222 | which unzip >/dev/null || error "The package 'unzip' is not installed. Please install it and run the nQuakesv installation again." 223 | which curl >/dev/null || error "The package 'curl' is not installed. Please install it and run the nQuakesv installation again." 224 | which wget >/dev/null || error "The package 'wget' is not installed. Please install it and run the nQuakesv installation again." 225 | which screen >/dev/null || error "The package 'screen' is not installed. Please install it and run the nQuakesv installation again."; 226 | 227 | nqecho 228 | nqecho "Welcome to the nQuakesv installation" 229 | nqecho "====================================" 230 | nqiecho 231 | nqiecho "Press ENTER to use [default] option." 232 | nqiecho 233 | 234 | # Interactive stuff 235 | [ -z "${noninteractive}" ] && { 236 | # Install dir 237 | printf "Where do you want to install nQuakesv? [${defaultdir}]: " 238 | read directory 239 | eval directory=${directory} 240 | 241 | # Hostname 242 | printf "Enter a descriptive hostname [${defaulthostname}]: " 243 | read hostname 244 | 245 | # FQDN/IP 246 | [ -z "${nqaddr}" ] && { 247 | printf "Enter your server's fully qualified domain name (or IP address). [use external IP]: " 248 | } || { 249 | printf "Enter your server's fully qualified domain name (or IP address). [${nqaddr}]: " 250 | } 251 | read hostdns 252 | 253 | # Ports 254 | printf "How many ports of KTX do you wish to run (max 64)? [${defaultports}]: " 255 | read ports 256 | 257 | # Rcon 258 | printf "What should the rcon password be? [${defaultrcon}]: " 259 | read rcon 260 | 261 | # QTV 262 | printf "Do you wish to run a qtv? (y/n) [${defaultqtv}]: " 263 | read qtv 264 | [ "${qtv}" = "y" ] && { 265 | printf "What should the qtv admin password be? [${defaultqtvpass}]: " 266 | read qtvpass 267 | } 268 | 269 | # QWFWD 270 | printf "Do you wish to run a qwfwd proxy? (y/n) [${defaultqwfwd}]: " 271 | read qwfwd 272 | 273 | # Admin name 274 | printf "Who is the admin of this server? [${defaultadmin}]: " 275 | read admin 276 | 277 | # Admin email 278 | printf "What is the admin's e-mail? [${defaultemail}]: " 279 | read email 280 | 281 | # Search for Pak1 282 | printf "Do you want setup to search for pak1.pak? (y/n) [${defaultsearchoption}]: " 283 | read search 284 | [ "${search}" = "y" ] || ([ "${defaultsearchoption}" = "y" ] && [ -z "${search}" ]) && { 285 | printf "Enter path to recursively search for pak1.pak [${defaultsearchdir}]: " 286 | read path 287 | } 288 | } 289 | 290 | review="" 291 | nqecho 292 | nqiecho "Please review the following settings:" 293 | nqecho "=========================================" 294 | # Set defaults if nothing was entered (non-interactive mode or just use defaults) 295 | [ -z "${directory}" ] && eval directory=${defaultdir} 296 | [ -z "${hostname}" ] && hostname=${defaulthostname} 297 | [ -z "${hostdns}" ] && hostdns=${nqaddr} 298 | [ -z "${ports}" ] && ports=${defaultports} 299 | [ -z "${rcon}" ] && rcon=${defaultrcon} 300 | [ -z "${qtv}" ] && qtv=${defaultqtv} 301 | [ -z "${qtvpass}" ] && qtvpass=${defaultqtvpass} 302 | [ -z "${qwfwd}" ] && qwfwd=${defaultqwfwd} 303 | [ -z "${admin}" ] && admin=${defaultadmin} 304 | [ -z "${email}" ] && email=${defaultemail} 305 | [ -z "${search}" ] && search=${defaultsearchoption} 306 | [ -z "${path}" ] && path=${defaultsearchdir} 307 | 308 | nqecho "Install directory: ${directory}" 309 | nqecho "Hostname: ${hostname}" 310 | nqnecho "Listen address: " 311 | [ -z "${hostdns}" ] && nqecho "" || nqecho "${hostdns}" 312 | nqecho "Number of ports: ${ports}" 313 | nqecho "RCON password: ${rcon}" 314 | nqnecho "Install QTV: " 315 | [ "${qtv}" = "y" ] && nqecho "yes (password: ${qtvpass})" || nqecho "no" 316 | nqnecho "Install QWFWD: " 317 | [ "${qwfwd}" = "y" ] && nqecho "yes" || nqecho "no" 318 | nqecho "Admin: ${admin} <${email}>" 319 | nqnecho "Search for pak1: " 320 | [ "${search}" = "y" ] && nqecho "${path}" || nqecho "" 321 | nqecho "=========================================" 322 | 323 | [ -z "${noninteractive}" ] && { 324 | nqecho 325 | nqecho "Press any key to continue..." 326 | read review 327 | } 328 | 329 | # Adjust invalid ports 330 | [ "${ports}" -gt 64 ] && ports=64 331 | [ "${ports}" -lt 1 ] && ports=1 332 | 333 | nqecho "Installation proceeding..." 334 | 335 | # Create the nQuakesv folder 336 | [ -d "${directory}" ] && { 337 | [ -w "${directory}" ] && { 338 | created=0 339 | } || error "You do not have write access to '${directory}'. Exiting." 340 | } || { 341 | [ -e "${directory}" ] && { 342 | error "'${directory}' already exists but is a file, not a directory. Exiting." 343 | } || { 344 | mkdir -p ${directory} 2>/dev/null || error "Failed to create install directory: '${directory}'" 345 | created=1 346 | } 347 | } 348 | 349 | [ -w "${directory}" ] && { 350 | cd ${directory} 351 | directory=$(pwd) 352 | } || error "You do not have write access to ${directory}. Exiting." 353 | 354 | # Search for pak1.pak 355 | pak="" 356 | [ "${search}" = "y" ] && { 357 | eval path=${path} 358 | pak=$(echo $(find ${path} -type f -iname "pak1.pak" -size 33M -exec echo "{}" \; 2> /dev/null) | cut -d " " -f1) 359 | [ -n "${pak}" ] && { 360 | nqecho 361 | nqecho "* Found pak1.pak at location: ${pak}" 362 | } || { 363 | nqecho 364 | nqecho "* Could not find pak1.pak" 365 | } 366 | } 367 | nqecho 368 | 369 | # Download nquake.ini 370 | nqwget -q -O nquake.ini https://raw.githubusercontent.com/nQuake/client-win32/master/etc/nquake.ini || error "Failed to download nquake.ini" 371 | [ ! -s "nquake.ini" ] && error "Downloaded nquake.ini but file is empty?! Exiting." 372 | 373 | # List all the available mirrors 374 | [ -z "${noninteractive}" ] && { 375 | nqecho "From what mirror would you like to download nQuakesv?" 376 | grep "[0-9]\{1,2\}=\".*" nquake.ini | cut -d "\"" -f2 | nl 377 | nqnecho "Enter mirror number [random]: " 378 | read mirror 379 | mirror=$(grep "^${mirror}=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 380 | nqecho 381 | } 382 | [ -z "${mirror}" ] && { 383 | nqnecho "Using mirror: " 384 | range=$(expr $(grep "[0-9]\{1,2\}=\".*" nquake.ini | wc -l) + 1) 385 | while [ -z "${mirror}" ]; do 386 | number=$((((RANDOM<<15)|RANDOM) % $range + 1)) 387 | mirror=$(grep "^${number}=\(http\|https\|ftp\)://[^ ]*$" nquake.ini | cut -d "=" -f2) 388 | mirrorname=$(grep "^${number}=\".*" nquake.ini | cut -d "\"" -f2) 389 | done 390 | nqecho "${mirrorname}" 391 | } 392 | mkdir -p id1 393 | mkdir -p demos_archive 394 | nqecho 395 | 396 | # Download all the packages 397 | nqecho "=== Downloading ===" 398 | nqwget -O qsw106.zip ${mirror}/qsw106.zip || error "Failed to download ${mirror}/qsw106.zip" 399 | [ ! -s "qsw106.zip" ] && error "Downloaded qwsv106.zip but file is empty?!" 400 | nqwget -O sv-gpl.zip ${mirror}/sv-gpl.zip || error "Failed to download ${mirror}/sv-gpl.zip" 401 | [ ! -s "sv-gpl.zip" ] && error "Downloaded sv-gpl.zip but file is empty?!" 402 | nqwget -O sv-non-gpl.zip ${mirror}/sv-non-gpl.zip || error "Failed to download ${mirror}/sv-non-gpl.zip" 403 | [ ! -s "sv-non-gpl.zip" ] && error "Downloaded sv-non-gpl.zip but file is empty?!" 404 | nqwget -O sv-bin-x64.zip ${mirror}/sv-bin-x64.zip || error "Failed to download ${mirror}/sv-bin-x64.zip" 405 | [ ! -s "sv-bin-x64.zip" ] && error "Downloaded sv-bin-x64.zip but file is empty?!" 406 | nqwget -O sv-configs.zip ${mirror}/sv-configs.zip || error "Failed to download ${mirror}/sv-configs.zip" 407 | [ ! -s "sv-configs.zip" ] && error "Downloaded sv-configs.zip but file is empty?!" 408 | nqwget -O sv-maps.zip ${mirror}/sv-maps.zip || error "Failed to download ${mirror}/sv-maps.zip" 409 | [ ! -s "sv-maps.zip" ] && error "Downloaded sv-maps.zip but file is empty?!" 410 | 411 | # Get external IP address 412 | nqnecho "Resolving external IP address... " 413 | remote_ip=$(curl -f -s https://api.ipify.org/?format=txt) 414 | [ -z "${remote_ip}" ] && error "Failed retrieving external IP address" 415 | [ -z "${hostdns}" ] && hostdns=${remote_ip} 416 | nqecho "Resolved: ${remote_ip}" 417 | nqecho 418 | 419 | # Extract all the packages 420 | nqecho "=== Installing ===" 421 | nqnecho "* Extracting Quake Shareware..." 422 | (unzip -qqo qsw106.zip ID1/PAK0.PAK 2>/dev/null && nqecho done) || nqecho fail 423 | nqnecho "* Extracting nQuakesv setup files (1 of 2)..." 424 | (unzip -qqo sv-gpl.zip 2>/dev/null && nqecho done) || nqecho fail 425 | nqnecho "* Extracting nQuakesv setup files (2 of 2)..." 426 | (unzip -qqo sv-non-gpl.zip 2>/dev/null && nqecho done) || nqecho fail 427 | nqnecho "* Extracting nQuakesv binaries..." 428 | (unzip -qqo sv-bin-x64.zip 2>/dev/null && nqecho done) || nqecho fail 429 | nqnecho "* Extracting nQuakesv configuration files..." 430 | (unzip -qqo sv-configs.zip 2>/dev/null && nqecho done) || nqecho fail 431 | nqnecho "* Extracting nQuakesv maps..." 432 | (unzip -qqo sv-maps.zip 2>/dev/null && nqecho done) || nqecho fail 433 | [ -n "$pak" ] && { 434 | nqecho "* Copying pak1.pak..." 435 | (cp ${pak} ${directory}/id1/pak1.pak 2>/dev/null && nqecho done) || nqecho fail 436 | } 437 | nqnecho "* Downloading shell scripts..." 438 | (githubdl ${directory}/start_servers.sh scripts/start_servers.sh && \ 439 | githubdl ${directory}/stop_servers.sh scripts/stop_servers.sh && \ 440 | githubdl ${directory}/update_scripts.sh scripts/update_scripts.sh && \ 441 | githubdl ${directory}/update_binaries.sh scripts/update_binaries.sh && \ 442 | githubdl ${directory}/update_configs.sh scripts/update_configs.sh && \ 443 | githubdl ${directory}/update_maps.sh scripts/update_maps.sh && \ 444 | githubd2 ${directory}/nquakesv-build-mvdsv.sh quake-scripts/build/nquakesv-build-mvdsv.sh && \ 445 | githubd2 ${directory}/nquakesv-build-ktx.sh quake-scripts/build/nquakesv-build-ktx.sh && echo done) || nqecho fail 446 | nqecho 447 | 448 | # Rename files 449 | nqecho "=== Cleaning up ===" 450 | nqnecho "* Renaming files..." 451 | (mv ${directory}/ID1/PAK0.PAK ${directory}/id1/pak0.pak 2>/dev/null && rm -rf ${directory}/ID1 && nqecho done) || nqecho fail 452 | 453 | # Remove distribution files 454 | nqnecho "* Removing distribution files..." 455 | (rm -rf ${directory}/qsw106.zip ${directory}/sv-gpl.zip ${directory}/sv-non-gpl.zip ${directory}/sv-bin-x64.zip ${directory}/sv-configs.zip ${directory}/sv-maps.zip ${directory}/nquake.ini && nqecho done) || nqecho fail 456 | 457 | # Convert DOS files to UNIX 458 | nqnecho "* Converting DOS files to UNIX..." 459 | for file in $(find ${directory} -iname "*.cfg" -or -iname "*.txt" -or -iname "*.sh" -or -iname "README"); do 460 | [ -f "${file}" ] && sed -i 's/\r$//' ${file} 461 | done 462 | nqecho "done" 463 | 464 | # Set the correct permissions 465 | nqnecho "* Setting permissions..." 466 | find ${directory} -type f -exec chmod -f 644 "{}" \; 467 | find ${directory} -type d -exec chmod -f 755 "{}" \; 468 | chmod -f +x ${directory}/mvdsv 2>/dev/null 469 | chmod -f +x ${directory}/ktx/mvdfinish.qws 2>/dev/null 470 | chmod -f +x ${directory}/qtv/qtv.bin 2>/dev/null 471 | chmod -f +x ${directory}/qwfwd/qwfwd.bin 2>/dev/null 472 | chmod -f +x ${directory}/*.sh 2>/dev/null 473 | chmod -f +x ${directory}/run/*.sh 2>/dev/null 474 | chmod -f +x ${directory}/addons/*.sh 2>/dev/null 475 | nqecho "done" 476 | 477 | # Update configuration files 478 | [ -d "$HOME/.nquakesv" ] && { 479 | [ -z "${noninteractive}" ] && { 480 | nqecho 481 | nqnecho "Update configuration files (overwrites ~/.nquakesv/* of previous installation) (y/n) [${defaultupdateconfig}]: " 482 | read updateconfig 483 | } 484 | } 485 | 486 | # Set default if nothing was entered 487 | [ -z "${updateconfig}" ] && updateconfig=${defaultupdateconfig} 488 | 489 | [ "${updateconfig}" = "y" ] && { 490 | nqnecho "* Updating configuration files..." 491 | mkdir -p ~/.nquakesv 492 | echo ${directory} > ~/.nquakesv/install_dir 493 | echo ${hostdns} > ~/.nquakesv/ip 494 | echo "${admin} <${email}>" > ~/.nquakesv/admin 495 | # Generate config file 496 | echo "SV_HOSTNAME=\"${hostname}\"" > ~/.nquakesv/config 497 | echo "SV_ADMININFO=\"${admin} <${email}>\"" >> ~/.nquakesv/config 498 | echo "SV_RCON=\"${rcon}\"" >> ~/.nquakesv/config 499 | echo "SV_QTVPASS=\"${qtvpass}\"" >> ~/.nquakesv/config 500 | # qtv 501 | [ "${qtv}" = "y" ] && { 502 | echo 28000 > ~/.nquakesv/qtv 503 | ln -s ${directory}/ktx/demos ${directory}/qtv/demos 504 | ln -s ${directory}/qw/maps ${directory}/qtv/maps 505 | } 506 | # qwfwd 507 | [ "${qwfwd}" = "y" ] && { 508 | echo 30000 > ~/.nquakesv/qwfwd 509 | } 510 | nqecho "done" 511 | 512 | # Create port files 513 | nqnecho "* Adjusting amount of ports..." 514 | mkdir -p ~/.nquakesv/ports 515 | i=1 516 | while [ ${i} -le ${ports} ]; do 517 | [ ${i} -gt 9 ] && port=285${i} || port=2850${i} 518 | touch ~/.nquakesv/ports/${port} 519 | i=$((i+1)) 520 | done 521 | nqecho "done" 522 | } 523 | [ "${updateconfig}" = "y" ] || { 524 | nqnecho "* Skipping update of configuration files..." 525 | } 526 | 527 | # Create cron entries 528 | [ -d "/etc/cron.d" ] && { 529 | [ -z "${noninteractive}" ] && { 530 | nqecho 531 | nqnecho "Add nQuake server to crontab (ensures servers are always on) (y/n) [${defaultaddcron}]: " 532 | read addcron 533 | } 534 | 535 | # Set default if nothing was entered 536 | [ -z "${addcron}" ] && addcron=${defaultaddcron} 537 | 538 | [ "${addcron}" = "y" ] && { 539 | echo "*/10 * * * * $USER cd \$(cat ~/.nquakesv/install_dir) && ./start_servers.sh >/dev/null 2>&1" | sudo tee /etc/cron.d/nquakesv >/dev/null 540 | echo "@reboot $USER cd \$(cat ~/.nquakesv/install_dir) && ./start_servers.sh >/dev/null 2>&1" | sudo tee -a /etc/cron.d/nquakesv > /dev/null 541 | echo "# Uncomment the following line if you would like to move demos older than 90 days to the demos_archive folder (more than 4096 demos in mvdsv causes issues)" | sudo tee -a /etc/cron.d/nquakesv > /dev/null 542 | echo "#0 13 * * 1 $USER rsync -a \$(cat ~/.nquakesv/install_dir)/ktx/demos/*.mvd \$(cat ~/.nquakesv/install_dir)/demos_archive/. >/dev/null && find \$(cat ~/.nquakesv/install_dir)/ktx/demos -mtime +90 -print0|xargs -r -0 rm -f >/dev/null" | sudo tee -a /etc/cron.d/nquakesv > /dev/null 543 | } 544 | } 545 | 546 | # Build mvdsv and ktx 547 | [ -z "${noninteractive}" ] && { 548 | nqecho 549 | nqnecho "Build mvdsv and ktx (ensures server is updated) (y/n) [${defaultbuild}]: " 550 | read build 551 | } 552 | 553 | # Set default if nothing was entered 554 | [ -z "${build}" ] && build=${defaultbuild} 555 | 556 | [ "${build}" = "y" ] && { 557 | nqecho 558 | nqecho "Running ./nquakesv-build-mvdsv.sh ..." 559 | nqecho 560 | ./nquakesv-build-mvdsv.sh 561 | nqecho "Running ./nquakesv-build-ktx.sh ..." 562 | nqecho 563 | ./nquakesv-build-ktx.sh 564 | nqecho 565 | 566 | # Check if 'git procps qstat make gcc pkg-config cmake' are installed 567 | which git >/dev/null || nqecho "The package 'git' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again." 568 | which pkill >/dev/null || nqecho "The package 'procps' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again." 569 | which quakestat >/dev/null || nqecho "The package 'qstat' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again." 570 | which make >/dev/null || nqecho "The package 'make' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again." 571 | which gcc >/dev/null || nqecho "The package 'gcc' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again." 572 | which pkg-config >/dev/null || nqecho "The package 'pkg-config' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again." 573 | which cmake >/dev/null || nqecho "The package 'cmake' is not installed. Please install it and run ./nquakesv-build-mvdsv.sh and ./nquakesv-build-ktx.sh again."; 574 | nqecho 575 | nqecho "Optionally, edit the top of nquakesv-build-mvdsv.sh and nquakesv-build-ktx.sh as needed to change repo/branch from which to build, and run them again" 576 | } 577 | 578 | # Start servers 579 | nqecho 580 | nqecho STARTING SERVER 581 | ./start_servers.sh 582 | 583 | nqecho 584 | nqecho "Installation complete. Please read the README in ${directory}." 585 | nqecho 586 | nqecho "Please make sure to accept UDP ports 28501-$((28500+${ports})) (mvdsv), UDP port 30000 (qwfwd) and TCP/UDP port 28000 (qtv/hub)." 587 | nqecho "For example on debian:" 588 | nqecho "sudo apt install ufw && sudo ufw allow ssh && sudo ufw allow 28000/tcp && sudo ufw allow 28000/udp && sudo ufw allow 28501:28505/udp && sudo ufw allow 30000/udp && sudo ufw enable" 589 | nqecho 590 | nqecho "Optionally, edit ktx/configs/usermodes/default.cfg and change 'set k_teamoverlay' to 1." 591 | nqecho "Optionally, edit ktx/ktx.cfg and uncomment the k_admincode line and set your own admincode." 592 | nqecho 593 | nqecho "Run './stop_servers.sh && ./start_servers.sh' after any configuration changes or new builds." 594 | nqecho "Run './update_scripts.sh' or './update_maps.sh' occasionally to update scripts/maps." 595 | nqecho 596 | 597 | exit 0 598 | --------------------------------------------------------------------------------