tests_jc2server.sh 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2020 Daniel Gibbs
  5. # Purpose: Travis CI Tests: Just Cause 2 | Linux Game Server Management Script
  6. # Contributors: https://linuxgsm.com/contrib
  7. # Documentation: https://docs.linuxgsm.com
  8. # Website: https://linuxgsm.com
  9. # DO NOT EDIT THIS FILE
  10. # LinuxGSM configuration is no longer edited here
  11. # To update your LinuxGSM config go to:
  12. # lgsm/config-lgsm
  13. # https://docs.linuxgsm.com/configuration/linuxgsm-config
  14. # Debugging
  15. if [ -f ".dev-debug" ]; then
  16. exec 5> dev-debug.log
  17. BASH_XTRACEFD="5"
  18. set -x
  19. fi
  20. version="v23.4.0"
  21. shortname="jc2"
  22. gameservername="jc2server"
  23. commandname="CORE"
  24. rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
  25. selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
  26. sessionname=$(echo "${selfname}" | cut -f1 -d".")
  27. lgsmdir="${rootdir}/lgsm"
  28. logdir="${rootdir}/log"
  29. lgsmlogdir="${logdir}/lgsm"
  30. steamcmddir="${HOME}/.steam/steamcmd"
  31. serverfiles="${rootdir}/serverfiles"
  32. modulesdir="${lgsmdir}/modules"
  33. tmpdir="${lgsmdir}/tmp"
  34. datadir="${lgsmdir}/data"
  35. lockdir="${lgsmdir}/lock"
  36. serverlist="${datadir}/serverlist.csv"
  37. serverlistmenu="${datadir}/serverlistmenu.csv"
  38. configdir="${lgsmdir}/config-lgsm"
  39. configdirserver="${configdir}/${gameservername}"
  40. configdirdefault="${lgsmdir}/config-default"
  41. userinput="${1}"
  42. # Allows for testing not on Travis CI.
  43. # if using travis for tests
  44. if [ -z "${TRAVIS}" ]; then
  45. TRAVIS_BRANCH="develop"
  46. TRAVIS_BUILD_DIR="${rootdir}"
  47. fi
  48. travistest="1"
  49. ## GitHub Branch Select
  50. # Allows for the use of different module files
  51. # from a different repo and/or branch.
  52. githubuser="GameServerManagers"
  53. githubrepo="LinuxGSM"
  54. githubbranch="${TRAVIS_BRANCH}"
  55. # Core module that is required first.
  56. core_modules.sh() {
  57. modulefile="${FUNCNAME[0]}"
  58. fn_bootstrap_fetch_file_github "lgsm/modules" "core_modules.sh" "${modulesdir}" "chmodx" "run" "noforcedl" "nohash"
  59. }
  60. # Bootstrap
  61. # Fetches the core modules required before passed off to core_dl.sh.
  62. fn_bootstrap_fetch_file() {
  63. remote_fileurl="${1}"
  64. remote_fileurl_backup="${2}"
  65. remote_fileurl_name="${3}"
  66. remote_fileurl_backup_name="${4}"
  67. local_filedir="${5}"
  68. local_filename="${6}"
  69. chmodx="${7:-0}"
  70. run="${8:-0}"
  71. forcedl="${9:-0}"
  72. md5="${10:-0}"
  73. # Download file if missing or download forced.
  74. if [ ! -f "${local_filedir}/${local_filename}" ] || [ "${forcedl}" == "forcedl" ]; then
  75. # If backup fileurl exists include it.
  76. if [ -n "${remote_fileurl_backup}" ]; then
  77. # counter set to 0 to allow second try
  78. counter=0
  79. remote_fileurls_array=(remote_fileurl remote_fileurl_backup)
  80. else
  81. # counter set to 1 to not allow second try
  82. counter=1
  83. remote_fileurls_array=(remote_fileurl)
  84. fi
  85. for remote_fileurl_array in "${remote_fileurls_array[@]}"; do
  86. if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then
  87. fileurl="${remote_fileurl}"
  88. fileurl_name="${remote_fileurl_name}"
  89. elif [ "${remote_fileurl_array}" == "remote_fileurl_backup" ]; then
  90. fileurl="${remote_fileurl_backup}"
  91. fileurl_name="${remote_fileurl_backup_name}"
  92. fi
  93. counter=$((counter + 1))
  94. if [ ! -d "${local_filedir}" ]; then
  95. mkdir -p "${local_filedir}"
  96. fi
  97. # Trap will remove part downloaded files if canceled.
  98. trap fn_fetch_trap INT
  99. # Larger files show a progress bar.
  100. echo -en "fetching ${fileurl_name} ${local_filename}...\c"
  101. curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}" 2>&1)
  102. local exitcode=$?
  103. # Download will fail if downloads a html file.
  104. if [ -f "${local_filedir}/${local_filename}" ]; then
  105. if [ -n "$(head "${local_filedir}/${local_filename}" | grep "DOCTYPE")" ]; then
  106. rm -f "${local_filedir:?}/${local_filename:?}"
  107. local exitcode=2
  108. fi
  109. fi
  110. # On first try will error. On second try will fail.
  111. if [ "${exitcode}" != 0 ]; then
  112. if [ ${counter} -ge 2 ]; then
  113. echo -e "FAIL"
  114. if [ -f "${lgsmlog}" ]; then
  115. fn_script_log_fatal "Downloading ${local_filename}"
  116. fn_script_log_fatal "${fileurl}"
  117. fi
  118. core_exit.sh
  119. else
  120. echo -e "ERROR"
  121. if [ -f "${lgsmlog}" ]; then
  122. fn_script_log_error "Downloading ${local_filename}"
  123. fn_script_log_error "${fileurl}"
  124. fi
  125. fi
  126. else
  127. echo -en "OK"
  128. sleep 0.3
  129. echo -en "\033[2K\\r"
  130. if [ -f "${lgsmlog}" ]; then
  131. fn_script_log_pass "Downloading ${local_filename}"
  132. fi
  133. # Make file executable if chmodx is set.
  134. if [ "${chmodx}" == "chmodx" ]; then
  135. chmod +x "${local_filedir}/${local_filename}"
  136. fi
  137. # Remove trap.
  138. trap - INT
  139. break
  140. fi
  141. done
  142. fi
  143. if [ -f "${local_filedir}/${local_filename}" ]; then
  144. # Execute file if run is set.
  145. if [ "${run}" == "run" ]; then
  146. # shellcheck source=/dev/null
  147. source "${local_filedir}/${local_filename}"
  148. fi
  149. fi
  150. }
  151. fn_bootstrap_fetch_file_github() {
  152. github_file_url_dir="${1}"
  153. github_file_url_name="${2}"
  154. # If master branch will currently running LinuxGSM version to prevent "version mixing". This is ignored if a fork.
  155. if [ "${githubbranch}" == "master" ] && [ "${githubuser}" == "GameServerManagers" ] && [ "${commandname}" != "UPDATE-LGSM" ]; then
  156. remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${version}/${github_file_url_dir}/${github_file_url_name}"
  157. remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${version}/${github_file_url_dir}/${github_file_url_name}"
  158. else
  159. remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  160. remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  161. fi
  162. remote_fileurl_name="GitHub"
  163. remote_fileurl_backup_name="Bitbucket"
  164. local_filedir="${3}"
  165. local_filename="${github_file_url_name}"
  166. chmodx="${4:-0}"
  167. run="${5:-0}"
  168. forcedl="${6:-0}"
  169. md5="${7:-0}"
  170. # Passes vars to the file download module.
  171. fn_bootstrap_fetch_file "${remote_fileurl}" "${remote_fileurl_backup}" "${remote_fileurl_name}" "${remote_fileurl_backup_name}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
  172. }
  173. # Installer menu.
  174. fn_print_center() {
  175. columns=$(tput cols)
  176. line="$*"
  177. printf "%*s\n" $(((${#line} + columns) / 2)) "${line}"
  178. }
  179. fn_print_horizontal() {
  180. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
  181. }
  182. # Bash menu.
  183. fn_install_menu_bash() {
  184. local resultvar=$1
  185. title=$2
  186. caption=$3
  187. options=$4
  188. fn_print_horizontal
  189. fn_print_center "${title}"
  190. fn_print_center "${caption}"
  191. fn_print_horizontal
  192. menu_options=()
  193. while read -r line || [[ -n "${line}" ]]; do
  194. var=$(echo -e "${line}" | awk -F "," '{print $2 " - " $3}')
  195. menu_options+=("${var}")
  196. done < "${options}"
  197. menu_options+=("Cancel")
  198. select option in "${menu_options[@]}"; do
  199. if [ "${option}" ] && [ "${option}" != "Cancel" ]; then
  200. eval "$resultvar=\"${option/%\ */}\""
  201. fi
  202. break
  203. done
  204. }
  205. # Whiptail/Dialog menu.
  206. fn_install_menu_whiptail() {
  207. local menucmd=$1
  208. local resultvar=$2
  209. title=$3
  210. caption=$4
  211. options=$5
  212. height=${6:-40}
  213. width=${7:-80}
  214. menuheight=${8:-30}
  215. IFS=","
  216. menu_options=()
  217. while read -r line; do
  218. key=$(echo -e "${line}" | awk -F "," '{print $3}')
  219. val=$(echo -e "${line}" | awk -F "," '{print $2}')
  220. menu_options+=("${val//\"/}" "${key//\"/}")
  221. done < "${options}"
  222. OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
  223. if [ $? == 0 ]; then
  224. eval "$resultvar=\"${OPTION}\""
  225. else
  226. eval "$resultvar="
  227. fi
  228. }
  229. # Menu selector.
  230. fn_install_menu() {
  231. local resultvar=$1
  232. local selection=""
  233. title=$2
  234. caption=$3
  235. options=$4
  236. # Get menu command.
  237. for menucmd in whiptail dialog bash; do
  238. if [ "$(command -v "${menucmd}")" ]; then
  239. menucmd=$(command -v "${menucmd}")
  240. break
  241. fi
  242. done
  243. case "$(basename "${menucmd}")" in
  244. whiptail | dialog)
  245. fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30
  246. ;;
  247. *)
  248. fn_install_menu_bash selection "${title}" "${caption}" "${options}"
  249. ;;
  250. esac
  251. eval "$resultvar=\"${selection}\""
  252. }
  253. # Gets server info from serverlist.csv and puts in to array.
  254. fn_server_info() {
  255. IFS=","
  256. server_info_array=($(grep -aw "${userinput}" "${serverlist}"))
  257. shortname="${server_info_array[0]}" # csgo
  258. gameservername="${server_info_array[1]}" # csgoserver
  259. gamename="${server_info_array[2]}" # Counter Strike: Global Offensive
  260. }
  261. fn_install_getopt() {
  262. userinput="empty"
  263. echo -e "Usage: $0 [option]"
  264. echo -e ""
  265. echo -e "Installer - Linux Game Server Managers - Version ${version}"
  266. echo -e "https://linuxgsm.com"
  267. echo -e ""
  268. echo -e "Commands"
  269. echo -e "install\t\t| Select server to install."
  270. echo -e "servername\t| Enter name of game server to install. e.g $0 csgoserver."
  271. echo -e "list\t\t| List all servers available for install."
  272. exit
  273. }
  274. fn_install_file() {
  275. local_filename="${gameservername}"
  276. if [ -e "${local_filename}" ]; then
  277. i=2
  278. while [ -e "${local_filename}-${i}" ]; do
  279. ((i++))
  280. done
  281. local_filename="${local_filename}-${i}"
  282. fi
  283. cp -R "${selfname}" "${local_filename}"
  284. sed -i -e "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${local_filename}"
  285. sed -i -e "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${local_filename}"
  286. echo -e "Installed ${gamename} server as ${local_filename}"
  287. echo -e ""
  288. if [ ! -d "${serverfiles}" ]; then
  289. echo -e "./${local_filename} install"
  290. else
  291. echo -e "Remember to check server ports"
  292. echo -e "./${local_filename} details"
  293. fi
  294. echo -e ""
  295. exit
  296. }
  297. # Prevent LinuxGSM from running as root. Except if doing a dependency install.
  298. if [ "$(whoami)" == "root" ]; then
  299. if [ "${userinput}" == "install" ] || [ "${userinput}" == "auto-install" ] || [ "${userinput}" == "i" ] || [ "${userinput}" == "ai" ]; then
  300. if [ "${shortname}" == "core" ]; then
  301. echo -e "[ FAIL ] Do NOT run this script as root!"
  302. exit 1
  303. fi
  304. elif [ ! -f "${modulesdir}/core_modules.sh" ] || [ ! -f "${modulesdir}/check_root.sh" ] || [ ! -f "${modulesdir}/core_messages.sh" ]; then
  305. echo -e "[ FAIL ] Do NOT run this script as root!"
  306. exit 1
  307. else
  308. core_modules.sh
  309. check_root.sh
  310. fi
  311. fi
  312. # LinuxGSM installer mode.
  313. if [ "${shortname}" == "core" ]; then
  314. # Download the latest serverlist. This is the complete list of all supported servers.
  315. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "nochmodx" "norun" "forcedl" "nohash"
  316. if [ ! -f "${serverlist}" ]; then
  317. echo -e "[ FAIL ] serverlist.csv could not be loaded."
  318. exit 1
  319. fi
  320. if [ "${userinput}" == "list" ] || [ "${userinput}" == "l" ]; then
  321. {
  322. tail -n +2 "${serverlist}" | awk -F "," '{print $2 "\t" $3}'
  323. } | column -s $'\t' -t | more
  324. exit
  325. elif [ "${userinput}" == "install" ] || [ "${userinput}" == "i" ]; then
  326. tail -n +2 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
  327. fn_install_menu result "LinuxGSM" "Select game server to install." "${serverlistmenu}"
  328. userinput="${result}"
  329. fn_server_info
  330. if [ "${result}" == "${gameservername}" ]; then
  331. fn_install_file
  332. elif [ "${result}" == "" ]; then
  333. echo -e "Install canceled"
  334. else
  335. echo -e "[ FAIL ] menu result does not match gameservername"
  336. echo -e "result: ${result}"
  337. echo -e "gameservername: ${gameservername}"
  338. fi
  339. elif [ "${userinput}" ]; then
  340. fn_server_info
  341. if [ "${userinput}" == "${gameservername}" ] || [ "${userinput}" == "${gamename}" ] || [ "${userinput}" == "${shortname}" ]; then
  342. fn_install_file
  343. else
  344. echo -e "[ FAIL ] Unknown game server"
  345. fi
  346. else
  347. fn_install_getopt
  348. fi
  349. # LinuxGSM server mode.
  350. else
  351. core_modules.sh
  352. if [ "${shortname}" != "core-dep" ]; then
  353. # Load LinuxGSM configs.
  354. # These are required to get all the default variables for the specific server.
  355. # Load the default config. If missing download it. If changed reload it.
  356. if [ ! -f "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" ]; then
  357. mkdir -p "${configdirdefault}/config-lgsm/${gameservername}"
  358. fn_fetch_config "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "_default.cfg" "nochmodx" "norun" "noforcedl" "nohash"
  359. fi
  360. if [ ! -f "${configdirserver}/_default.cfg" ]; then
  361. mkdir -p "${configdirserver}"
  362. echo -en "copying _default.cfg...\c"
  363. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  364. exitcode=$?
  365. if [ "${exitcode}" != 0 ]; then
  366. echo -e "FAIL"
  367. exit 1
  368. else
  369. echo -e "OK"
  370. fi
  371. else
  372. module_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg")
  373. if [ "${module_file_diff}" != "" ]; then
  374. fn_print_warn_nl "_default.cfg has been altered. reloading config."
  375. echo -en "copying _default.cfg...\c"
  376. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  377. exitcode=$?
  378. if [ "${exitcode}" != 0 ]; then
  379. echo -e "FAIL"
  380. exit 1
  381. else
  382. echo -e "OK"
  383. fi
  384. fi
  385. fi
  386. # shellcheck source=/dev/null
  387. source "${configdirserver}/_default.cfg"
  388. # Load the common.cfg config. If missing download it.
  389. if [ ! -f "${configdirserver}/common.cfg" ]; then
  390. fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nohash"
  391. # shellcheck source=/dev/null
  392. source "${configdirserver}/common.cfg"
  393. else
  394. # shellcheck source=/dev/null
  395. source "${configdirserver}/common.cfg"
  396. fi
  397. # Load the secrets-common.cfg config. If missing download it.
  398. if [ ! -f "${configdirserver}/secrets-common.cfg" ]; then
  399. fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-common-template.cfg" "${configdirserver}" "secrets-common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nohash"
  400. # shellcheck source=/dev/null
  401. source "${configdirserver}/secrets-common.cfg"
  402. else
  403. # shellcheck source=/dev/null
  404. source "${configdirserver}/secrets-common.cfg"
  405. fi
  406. # Load the instance.cfg config. If missing download it.
  407. if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
  408. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nohash"
  409. # shellcheck source=/dev/null
  410. source "${configdirserver}/${selfname}.cfg"
  411. else
  412. # shellcheck source=/dev/null
  413. source "${configdirserver}/${selfname}.cfg"
  414. fi
  415. # Load the secrets-instance.cfg config. If missing download it.
  416. if [ ! -f "${configdirserver}/secrets-${selfname}.cfg" ]; then
  417. fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-instance-template.cfg" "${configdirserver}" "secrets-${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nohash"
  418. # shellcheck source=/dev/null
  419. source "${configdirserver}/secrets-${selfname}.cfg"
  420. else
  421. # shellcheck source=/dev/null
  422. source "${configdirserver}/secrets-${selfname}.cfg"
  423. fi
  424. # Load the linuxgsm.sh in to tmpdir. If missing download it.
  425. if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then
  426. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nohash"
  427. fi
  428. fi
  429. # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off.
  430. fn_ansi_loader
  431. # Prevents running of core_exit.sh for Travis-CI.
  432. if [ "${travistest}" != "1" ]; then
  433. getopt=$1
  434. core_getopt.sh
  435. fi
  436. fi
  437. fn_currentstatus_tmux() {
  438. check_status.sh
  439. if [ "${status}" != "0" ]; then
  440. currentstatus="STARTED"
  441. else
  442. currentstatus="STOPPED"
  443. fi
  444. }
  445. fn_setstatus() {
  446. fn_currentstatus_tmux
  447. echo""
  448. echo -e "Required status: ${requiredstatus}"
  449. counter=0
  450. echo -e "Current status: ${currentstatus}"
  451. while [ "${requiredstatus}" != "${currentstatus}" ]; do
  452. counter=$((counter + 1))
  453. fn_currentstatus_tmux
  454. echo -en "New status: ${currentstatus}\\r"
  455. if [ "${requiredstatus}" == "STARTED" ]; then
  456. (command_start.sh > /dev/null 2>&1)
  457. else
  458. (command_stop.sh > /dev/null 2>&1)
  459. fi
  460. if [ "${counter}" -gt "5" ]; then
  461. currentstatus="FAIL"
  462. echo -e "Current status: ${currentstatus}"
  463. echo -e ""
  464. echo -e "Unable to start or stop server."
  465. exit 1
  466. fi
  467. done
  468. echo -en "New status: ${currentstatus}\\r"
  469. echo -e "\n"
  470. echo -e "Test starting:"
  471. echo -e ""
  472. }
  473. # End of every test will expect the result to either pass or fail
  474. # If the script does not do as intended the whole test will fail
  475. # if expecting a pass
  476. fn_test_result_pass() {
  477. if [ $? != 0 ]; then
  478. echo -e "================================="
  479. echo -e "Expected result: PASS"
  480. echo -e "Actual result: FAIL"
  481. fn_print_fail_nl "TEST FAILED"
  482. exitcode=1
  483. core_exit.sh
  484. else
  485. echo -e "================================="
  486. echo -e "Expected result: PASS"
  487. echo -e "Actual result: PASS"
  488. fn_print_ok_nl "TEST PASSED"
  489. echo -e ""
  490. fi
  491. }
  492. # if expecting a fail
  493. fn_test_result_fail() {
  494. if [ $? == 0 ]; then
  495. echo -e "================================="
  496. echo -e "Expected result: FAIL"
  497. echo -e "Actual result: PASS"
  498. fn_print_fail_nl "TEST FAILED"
  499. exitcode=1
  500. core_exit.sh
  501. else
  502. echo -e "================================="
  503. echo -e "Expected result: FAIL"
  504. echo -e "Actual result: FAIL"
  505. fn_print_ok_nl "TEST PASSED"
  506. echo -e ""
  507. fi
  508. }
  509. # test result n/a
  510. fn_test_result_na() {
  511. echo -e "================================="
  512. echo -e "Expected result: N/A"
  513. echo -e "Actual result: N/A"
  514. fn_print_fail_nl "TEST N/A"
  515. }
  516. sleeptime="0"
  517. echo -e "================================="
  518. echo -e "Travis CI Tests"
  519. echo -e "Linux Game Server Manager"
  520. echo -e "by Daniel Gibbs"
  521. echo -e "Contributors: http://goo.gl/qLmitD"
  522. echo -e "https://linuxgsm.com"
  523. echo -e "================================="
  524. echo -e ""
  525. echo -e "================================="
  526. echo -e "Server Tests"
  527. echo -e "Using: ${gamename}"
  528. echo -e "Testing Branch: ${TRAVIS_BRANCH}"
  529. echo -e "================================="
  530. echo -e ""
  531. echo -e "Tests Summary"
  532. echo -e "================================="
  533. echo -e "0.0 - Pre-test Tasks"
  534. echo -e "0.1 - Create log dir's"
  535. echo -e "0.2 - Enable dev-debug"
  536. echo -e ""
  537. echo -e "1.0 - Pre-install tests"
  538. echo -e "1.1 - start - no files"
  539. echo -e "1.2 - getopt"
  540. echo -e "1.3 - getopt with incorrect args"
  541. echo -e ""
  542. echo -e "2.0 - Installation"
  543. echo -e "2.1 - install"
  544. echo -e ""
  545. echo -e "3.0 - Start/Stop/Restart Tests"
  546. echo -e "3.1 - start"
  547. echo -e "3.2 - start - online"
  548. echo -e "3.3 - start - updateonstart"
  549. echo -e "3.4 - stop"
  550. echo -e "3.5 - stop - offline"
  551. echo -e "3.6 - restart"
  552. echo -e "3.7 - restart - offline"
  553. echo -e ""
  554. echo -e "4.0 - Update Tests"
  555. echo -e "4.1 - update"
  556. echo -e "4.2 - update - change buildid"
  557. echo -e "4.3 - update - change buildid - online"
  558. echo -e "4.4 - update - remove appmanifest file"
  559. echo -e "4.5 - force-update"
  560. echo -e "4.6 - force-update - online"
  561. echo -e "4.7 - validate"
  562. echo -e "4.8 - validate - online"
  563. echo -e "4.9 - update-lgsm"
  564. echo -e ""
  565. echo -e "5.0 - Monitor Tests"
  566. echo -e "5.1 - monitor - online"
  567. echo -e "5.2 - monitor - offline - with lockfile"
  568. echo -e "5.3 - monitor - offline - no lockfile"
  569. echo -e "5.4 - test-alert"
  570. echo -e ""
  571. echo -e "6.0 - Details Tests"
  572. echo -e "6.1 - details"
  573. echo -e "6.2 - postdetails"
  574. echo -e ""
  575. echo -e "7.0 - Backup Tests"
  576. echo -e "7.1 - backup"
  577. echo -e ""
  578. echo -e "8.0 - Development Tools Tests"
  579. echo -e "8.1 - dev - detect glibc"
  580. echo -e "8.2 - dev - detect ldd"
  581. echo -e "8.3 - dev - detect deps"
  582. echo -e "8.4 - dev - query-raw"
  583. echo -e ""
  584. echo -e "9.0 - Sponsor"
  585. echo -e "9.1 - sponsor"
  586. echo -e ""
  587. echo -e "0.0 - Pre-test Tasks"
  588. echo -e "=================================================================="
  589. echo -e "Description:"
  590. echo -e "Create log dir's"
  591. echo -e ""
  592. echo -e ""
  593. echo -e "0.1 - Create log dir's"
  594. echo -e "================================="
  595. echo -e ""
  596. (
  597. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  598. BASH_XTRACEFD="5"
  599. set -x
  600. install_logs.sh
  601. )
  602. echo -e "run order"
  603. echo -e "================="
  604. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  605. echo -e ""
  606. echo -e "0.2 - Enable dev-debug"
  607. echo -e "================================="
  608. echo -e "Description:"
  609. echo -e "Enable dev-debug"
  610. echo -e ""
  611. (
  612. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  613. BASH_XTRACEFD="5"
  614. set -x
  615. command_dev_debug.sh
  616. )
  617. fn_test_result_pass
  618. echo -e "run order"
  619. echo -e "================="
  620. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  621. echo -e ""
  622. echo -e "1.0 - Pre-install tests"
  623. echo -e "=================================================================="
  624. echo -e ""
  625. echo -e "1.1 - start - no files"
  626. echo -e "================================="
  627. echo -e "Description:"
  628. echo -e "test script reaction to missing server files."
  629. echo -e "Command: ./${gameservername} start"
  630. echo -e ""
  631. # Allows for testing not on Travis CI
  632. if [ -z "${TRAVIS}" ]; then
  633. (
  634. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  635. BASH_XTRACEFD="5"
  636. set -x
  637. command_start.sh
  638. )
  639. fn_test_result_fail
  640. else
  641. echo -e "Test bypassed"
  642. fi
  643. echo -e "run order"
  644. echo -e "================="
  645. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  646. echo -e ""
  647. echo -e "1.2 - getopt"
  648. echo -e "================================="
  649. echo -e "Description:"
  650. echo -e "displaying options messages."
  651. echo -e "Command: ./${gameservername}"
  652. echo -e ""
  653. (
  654. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  655. BASH_XTRACEFD="5"
  656. set -x
  657. core_getopt.sh
  658. )
  659. fn_test_result_pass
  660. echo -e "run order"
  661. echo -e "================="
  662. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  663. echo -e ""
  664. echo -e "1.3 - getopt with incorrect args"
  665. echo -e "================================="
  666. echo -e "Description:"
  667. echo -e "displaying options messages."
  668. echo -e "Command: ./${gameservername} abc123"
  669. echo -e ""
  670. getopt="abc123"
  671. (
  672. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  673. BASH_XTRACEFD="5"
  674. set -x
  675. core_getopt.sh
  676. )
  677. fn_test_result_pass
  678. echo -e "run order"
  679. echo -e "================="
  680. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  681. echo -e ""
  682. echo -e "2.0 - Installation"
  683. echo -e "=================================================================="
  684. echo -e ""
  685. echo -e "2.1 - install"
  686. echo -e "================================="
  687. echo -e "Description:"
  688. echo -e "install ${gamename} server."
  689. echo -e "Command: ./${gameservername} auto-install"
  690. (
  691. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  692. BASH_XTRACEFD="5"
  693. set -x
  694. fn_autoinstall
  695. )
  696. fn_test_result_pass
  697. echo -e "run order"
  698. echo -e "================="
  699. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  700. echo -e ""
  701. echo -e "3.0 - Start/Stop/Restart Tests"
  702. echo -e "=================================================================="
  703. echo -e ""
  704. echo -e "3.1 - start"
  705. echo -e "================================="
  706. echo -e "Description:"
  707. echo -e "start ${gamename} server."
  708. echo -e "Command: ./${gameservername} start"
  709. requiredstatus="STOPPED"
  710. fn_setstatus
  711. (
  712. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  713. BASH_XTRACEFD="5"
  714. set -x
  715. command_start.sh
  716. )
  717. fn_test_result_pass
  718. echo -e "run order"
  719. echo -e "================="
  720. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  721. echo -e ""
  722. echo -e "3.2 - start - online"
  723. echo -e "================================="
  724. echo -e "Description:"
  725. echo -e "start ${gamename} server while already running."
  726. echo -e "Command: ./${gameservername} start"
  727. requiredstatus="STARTED"
  728. fn_setstatus
  729. (
  730. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  731. BASH_XTRACEFD="5"
  732. set -x
  733. command_start.sh
  734. )
  735. fn_test_result_fail
  736. echo -e "run order"
  737. echo -e "================="
  738. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  739. echo -e ""
  740. echo -e "3.3 - start - updateonstart"
  741. echo -e "================================="
  742. echo -e "Description:"
  743. echo -e "will update server on start."
  744. echo -e "Command: ./${gameservername} start"
  745. requiredstatus="STOPPED"
  746. fn_setstatus
  747. (
  748. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  749. BASH_XTRACEFD="5"
  750. set -x
  751. updateonstart="on"
  752. command_start.sh
  753. )
  754. fn_test_result_pass
  755. echo -e "run order"
  756. echo -e "================="
  757. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  758. echo -e ""
  759. echo -e "3.4 - stop"
  760. echo -e "================================="
  761. echo -e "Description:"
  762. echo -e "stop ${gamename} server."
  763. echo -e "Command: ./${gameservername} stop"
  764. requiredstatus="STARTED"
  765. fn_setstatus
  766. (
  767. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  768. BASH_XTRACEFD="5"
  769. set -x
  770. command_stop.sh
  771. )
  772. fn_test_result_pass
  773. echo -e "run order"
  774. echo -e "================="
  775. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  776. echo -e ""
  777. echo -e "3.5 - stop - offline"
  778. echo -e "================================="
  779. echo -e "Description:"
  780. echo -e "stop ${gamename} server while already stopped."
  781. echo -e "Command: ./${gameservername} stop"
  782. requiredstatus="STOPPED"
  783. fn_setstatus
  784. (
  785. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  786. BASH_XTRACEFD="5"
  787. set -x
  788. command_stop.sh
  789. )
  790. fn_test_result_fail
  791. echo -e "run order"
  792. echo -e "================="
  793. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  794. echo -e ""
  795. echo -e "3.6 - restart"
  796. echo -e "================================="
  797. echo -e "Description:"
  798. echo -e "restart ${gamename}."
  799. echo -e "Command: ./${gameservername} restart"
  800. requiredstatus="STARTED"
  801. fn_setstatus
  802. (
  803. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  804. BASH_XTRACEFD="5"
  805. set -x
  806. command_restart.sh
  807. )
  808. fn_test_result_pass
  809. echo -e "run order"
  810. echo -e "================="
  811. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  812. echo -e ""
  813. echo -e "3.7 - restart - offline"
  814. echo -e "================================="
  815. echo -e "Description:"
  816. echo -e "restart ${gamename} while already stopped."
  817. echo -e "Command: ./${gameservername} restart"
  818. requiredstatus="STOPPED"
  819. fn_setstatus
  820. (
  821. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  822. BASH_XTRACEFD="5"
  823. set -x
  824. command_restart.sh
  825. )
  826. fn_test_result_pass
  827. echo -e "run order"
  828. echo -e "================="
  829. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  830. echo -e ""
  831. echo -e "4.0 - Update Tests"
  832. echo -e "=================================================================="
  833. echo -e ""
  834. echo -e "4.1 - update"
  835. echo -e "================================="
  836. echo -e "Description:"
  837. echo -e "check for updates."
  838. echo -e "Command: ./${gameservername} update"
  839. requiredstatus="STOPPED"
  840. fn_setstatus
  841. (
  842. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  843. BASH_XTRACEFD="5"
  844. set -x
  845. command_update.sh
  846. )
  847. fn_test_result_pass
  848. echo -e "run order"
  849. echo -e "================="
  850. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  851. echo -e ""
  852. echo -e "4.2 - update - change buildid"
  853. echo -e "================================="
  854. echo -e "Description:"
  855. echo -e "change the buildid tricking SteamCMD to update."
  856. echo -e "Command: ./jc2server update"
  857. requiredstatus="STOPPED"
  858. fn_setstatus
  859. fn_print_info_nl "changed buildid to 0."
  860. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  861. (
  862. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  863. BASH_XTRACEFD="5"
  864. set -x
  865. command_update.sh
  866. )
  867. fn_test_result_pass
  868. echo -e "run order"
  869. echo -e "================="
  870. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  871. echo -e ""
  872. echo -e "4.3 - update - change buildid - online"
  873. echo -e "================================="
  874. echo -e "Description:"
  875. echo -e "change the buildid tricking SteamCMD to update server while already running."
  876. echo -e "Command: ./jc2server update"
  877. requiredstatus="STARTED"
  878. fn_setstatus
  879. fn_print_info_nl "changed buildid to 0."
  880. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  881. (
  882. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  883. BASH_XTRACEFD="5"
  884. set -x
  885. command_update.sh
  886. )
  887. fn_test_result_pass
  888. echo -e "run order"
  889. echo -e "================="
  890. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  891. echo -e ""
  892. echo -e "4.4 - update - remove appmanifest file"
  893. echo -e "================================="
  894. echo -e "Description:"
  895. echo -e "removing appmanifest file will cause script to repair."
  896. echo -e "Command: ./jc2server update"
  897. requiredstatus="STOPPED"
  898. fn_setstatus
  899. fn_print_info_nl "removed appmanifest_${appid}.acf."
  900. rm --verbose "${serverfiles:?}/steamapps/appmanifest_${appid}.acf"
  901. (
  902. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  903. BASH_XTRACEFD="5"
  904. set -x
  905. command_update.sh
  906. )
  907. fn_test_result_pass
  908. echo -e "run order"
  909. echo -e "================="
  910. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  911. echo -e ""
  912. echo -e "4.5 - force-update"
  913. echo -e "================================="
  914. echo -e "Description:"
  915. echo -e "force-update bypassing update check."
  916. echo -e "Command: ./jc2server force-update"
  917. requiredstatus="STOPPED"
  918. fn_setstatus
  919. (
  920. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  921. BASH_XTRACEFD="5"
  922. set -x
  923. forceupdate=1
  924. command_update.sh
  925. )
  926. fn_test_result_pass
  927. echo -e "run order"
  928. echo -e "================="
  929. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  930. echo -e ""
  931. echo -e "4.6 - force-update - online"
  932. echo -e "================================="
  933. echo -e "Description:"
  934. echo -e "force-update bypassing update check server while already running."
  935. echo -e "Command: ./jc2server force-update"
  936. requiredstatus="STARTED"
  937. fn_setstatus
  938. (
  939. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  940. BASH_XTRACEFD="5"
  941. set -x
  942. forceupdate=1
  943. command_update.sh
  944. )
  945. fn_test_result_pass
  946. echo -e "run order"
  947. echo -e "================="
  948. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  949. echo -e ""
  950. echo -e "4.7 - validate"
  951. echo -e "================================="
  952. echo -e "Description:"
  953. echo -e "validate server files."
  954. echo -e "Command: ./jc2server validate"
  955. requiredstatus="STOPPED"
  956. fn_setstatus
  957. (
  958. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  959. BASH_XTRACEFD="5"
  960. set -x
  961. command_validate.sh
  962. )
  963. fn_test_result_pass
  964. echo -e "run order"
  965. echo -e "================="
  966. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  967. echo -e ""
  968. echo -e "4.8 - validate - online"
  969. echo -e "================================="
  970. echo -e "Description:"
  971. echo -e "validate server files while server already running."
  972. echo -e ""
  973. echo -e "Command: ./jc2server validate"
  974. requiredstatus="STARTED"
  975. fn_setstatus
  976. (
  977. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  978. BASH_XTRACEFD="5"
  979. set -x
  980. command_validate.sh
  981. )
  982. fn_test_result_pass
  983. echo -e "run order"
  984. echo -e "================="
  985. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  986. echo -e ""
  987. echo -e "4.9 - update-lgsm"
  988. echo -e "================================="
  989. echo -e "Description:"
  990. echo -e "update LinuxGSM."
  991. echo -e ""
  992. echo -e "Command: ./jc2server update-lgam"
  993. requiredstatus="STARTED"
  994. fn_setstatus
  995. (
  996. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  997. BASH_XTRACEFD="5"
  998. set -x
  999. command_update_linuxgsm.sh
  1000. )
  1001. fn_test_result_pass
  1002. echo -e "run order"
  1003. echo -e "================="
  1004. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1005. echo -e ""
  1006. echo -e "Inserting IP address"
  1007. echo -e "================================="
  1008. echo -e "Description:"
  1009. echo -e "Inserting Travis IP in to config."
  1010. echo -e "Allows monitor to work"
  1011. if [ "$(${ipcommand}-o -4 addr | grep eth0)" ]; then
  1012. travisip=$(${ipcommand}-o -4 addr | grep eth0 | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | grep -v 127.0.0)
  1013. else
  1014. travisip=$(${ipcommand}-o -4 addr | grep ens | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0)
  1015. fi
  1016. sed -i "/BindIP/c\BindIP = \"${travisip}\"," "${serverfiles}/config.lua"
  1017. echo -e "IP: ${travisip}"
  1018. echo -e ""
  1019. echo -e "5.0 - Monitor Tests"
  1020. echo -e "=================================================================="
  1021. echo -e ""
  1022. info_game.sh
  1023. echo -e "Server IP - Port: ${ip}:${port}"
  1024. echo -e "Server IP - Query Port: ${ip}:${queryport}"
  1025. echo -e ""
  1026. echo -e "5.1 - monitor - online"
  1027. echo -e "================================="
  1028. echo -e "Description:"
  1029. echo -e "run monitor server while already running."
  1030. echo -e "Command: ./${gameservername} monitor"
  1031. requiredstatus="STARTED"
  1032. fn_setstatus
  1033. (
  1034. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1035. BASH_XTRACEFD="5"
  1036. set -x
  1037. command_monitor.sh
  1038. )
  1039. fn_test_result_pass
  1040. echo -e "run order"
  1041. echo -e "================="
  1042. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1043. echo -e ""
  1044. echo -e "5.2 - monitor - offline - with lockfile"
  1045. echo -e "================================="
  1046. echo -e "Description:"
  1047. echo -e "run monitor while server is offline with lockfile."
  1048. echo -e "Command: ./${gameservername} monitor"
  1049. requiredstatus="STOPPED"
  1050. fn_setstatus
  1051. fn_print_info_nl "creating lockfile."
  1052. date '+%s' > "${lockdir}/${selfname}.lock"
  1053. echo "${version}" >> "${lockdir}/${selfname}.lock"
  1054. echo "${port}" >> "${lockdir}/${selfname}.lock"
  1055. (
  1056. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1057. BASH_XTRACEFD="5"
  1058. set -x
  1059. command_monitor.sh
  1060. )
  1061. fn_test_result_pass
  1062. echo -e "run order"
  1063. echo -e "================="
  1064. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1065. echo -e ""
  1066. echo -e "5.3 - monitor - offline - no lockfile"
  1067. echo -e "================================="
  1068. echo -e "Description:"
  1069. echo -e "run monitor while server is offline with no lockfile."
  1070. echo -e "Command: ./${gameservername} monitor"
  1071. requiredstatus="STOPPED"
  1072. fn_setstatus
  1073. (
  1074. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1075. BASH_XTRACEFD="5"
  1076. set -x
  1077. command_monitor.sh
  1078. )
  1079. fn_test_result_fail
  1080. echo -e "run order"
  1081. echo -e "================="
  1082. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1083. echo -e ""
  1084. echo -e "5.4 - test-alert"
  1085. echo -e "================================="
  1086. echo -e "Description:"
  1087. echo -e "run monitor while server is offline with no lockfile."
  1088. echo -e "Command: ./${gameservername} test-alert"
  1089. requiredstatus="STOPPED"
  1090. fn_setstatus
  1091. cp "${servercfgfullpath}" "config.lua"
  1092. sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
  1093. (
  1094. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1095. BASH_XTRACEFD="5"
  1096. set -x
  1097. command_test_alert.sh
  1098. )
  1099. fn_test_result_fail
  1100. echo -e "run order"
  1101. echo -e "================="
  1102. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1103. echo -e ""
  1104. fn_print_info_nl "Re-generating ${servercfg}."
  1105. cp -v "config.lua" "${servercfgfullpath}"
  1106. echo -e "================================="
  1107. echo -e ""
  1108. echo -e "6.0 - Details Tests"
  1109. echo -e "=================================================================="
  1110. echo -e ""
  1111. echo -e "6.1 - details"
  1112. echo -e "================================="
  1113. echo -e "Description:"
  1114. echo -e "display details."
  1115. echo -e "Command: ./${gameservername} details"
  1116. requiredstatus="STARTED"
  1117. fn_setstatus
  1118. (
  1119. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1120. BASH_XTRACEFD="5"
  1121. set -x
  1122. command_details.sh
  1123. )
  1124. fn_test_result_pass
  1125. echo -e "run order"
  1126. echo -e "================="
  1127. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1128. echo -e ""
  1129. echo -e "6.2 - postdetails"
  1130. echo -e "================================="
  1131. echo -e "Description:"
  1132. echo -e "post details."
  1133. echo -e "Command: ./${gameservername} postdetails"
  1134. requiredstatus="STARTED"
  1135. fn_setstatus
  1136. (
  1137. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1138. BASH_XTRACEFD="5"
  1139. set -x
  1140. command_postdetails.sh
  1141. )
  1142. fn_test_result_pass
  1143. echo -e "run order"
  1144. echo -e "================="
  1145. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1146. echo -e ""
  1147. echo -e "7.0 - Backup Tests"
  1148. echo -e "=================================================================="
  1149. echo -e ""
  1150. echo -e "7.1 - backup"
  1151. echo -e "================================="
  1152. echo -e "Description:"
  1153. echo -e "run a backup."
  1154. echo -e "Command: ./${gameservername} backup"
  1155. requiredstatus="STARTED"
  1156. fn_setstatus
  1157. echo -e "test de-activated until issue #1839 fixed"
  1158. #(command_backup.sh)
  1159. fn_test_result_pass
  1160. echo -e "run order"
  1161. echo -e "================="
  1162. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1163. echo -e ""
  1164. echo -e "8.0 - Development Tools Tests"
  1165. echo -e "=================================================================="
  1166. echo -e ""
  1167. echo -e "8.1 - dev - detect glibc"
  1168. echo -e "================================="
  1169. echo -e "Description:"
  1170. echo -e "detect glibc."
  1171. echo -e "Command: ./${gameservername} detect-glibc"
  1172. requiredstatus="STARTED"
  1173. fn_setstatus
  1174. (
  1175. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1176. BASH_XTRACEFD="5"
  1177. set -x
  1178. command_dev_detect_glibc.sh
  1179. )
  1180. fn_test_result_pass
  1181. echo -e "run order"
  1182. echo -e "================="
  1183. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1184. echo -e ""
  1185. echo -e "8.2 - dev - detect ldd"
  1186. echo -e "================================="
  1187. echo -e "Description:"
  1188. echo -e "detect ldd."
  1189. echo -e "Command: ./${gameservername} detect-ldd"
  1190. requiredstatus="STARTED"
  1191. fn_setstatus
  1192. (
  1193. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1194. BASH_XTRACEFD="5"
  1195. set -x
  1196. command_dev_detect_ldd.sh
  1197. )
  1198. fn_test_result_pass
  1199. echo -e "run order"
  1200. echo -e "================="
  1201. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1202. echo -e ""
  1203. echo -e "8.3 - dev - detect deps"
  1204. echo -e "================================="
  1205. echo -e "Description:"
  1206. echo -e "detect dependencies."
  1207. echo -e "Command: ./${gameservername} detect-deps"
  1208. requiredstatus="STARTED"
  1209. fn_setstatus
  1210. (
  1211. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1212. BASH_XTRACEFD="5"
  1213. set -x
  1214. command_dev_detect_deps.sh
  1215. )
  1216. fn_test_result_pass
  1217. echo -e "run order"
  1218. echo -e "================="
  1219. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1220. echo -e ""
  1221. echo -e "8.4 - dev - query-raw"
  1222. echo -e "================================="
  1223. echo -e "Description:"
  1224. echo -e "raw query output."
  1225. echo -e "Command: ./${gameservername} query-raw"
  1226. requiredstatus="STARTED"
  1227. fn_setstatus
  1228. (
  1229. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1230. BASH_XTRACEFD="5"
  1231. set -x
  1232. command_dev_query_raw.sh
  1233. )
  1234. fn_test_result_na
  1235. echo -e "run order"
  1236. echo -e "================="
  1237. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1238. echo -e ""
  1239. echo -e "9.0 - Sponsor"
  1240. echo -e "=================================================================="
  1241. echo -e ""
  1242. echo -e "9.1 - sponsor"
  1243. echo -e "================================="
  1244. echo -e "Description:"
  1245. echo -e "sponsor."
  1246. echo -e "Command: ./${gameservername} sponsor"
  1247. requiredstatus="STARTED"
  1248. fn_setstatus
  1249. (
  1250. exec 5> "${TRAVIS_BUILD_DIR}/dev-debug.log"
  1251. BASH_XTRACEFD="5"
  1252. set -x
  1253. command_sponsor.sh
  1254. )
  1255. fn_test_result_pass
  1256. echo -e "run order"
  1257. echo -e "================="
  1258. grep modulefile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/modulefile=//g'
  1259. echo -e ""
  1260. echo -e "================================="
  1261. echo -e "Server Tests - Complete!"
  1262. echo -e "Using: ${gamename}"
  1263. echo -e "================================="
  1264. requiredstatus="STOPPED"
  1265. fn_setstatus
  1266. core_exit.sh