tests_jc2server.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2017 Daniel Gibbs
  5. # Purpose: Travis CI Tests: Just Cause 2 | Linux Game Server Management Script
  6. # Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors
  7. # Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki
  8. # Website: https://linuxgsm.com
  9. travistest="1"
  10. # Debugging
  11. if [ -f ".dev-debug" ]; then
  12. exec 5>dev-debug.log
  13. BASH_XTRACEFD="5"
  14. set -x
  15. fi
  16. version="171014"
  17. shortname="jc2"
  18. gameservername="jc2server"
  19. rootdir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
  20. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  21. servicename="${selfname}"
  22. lockselfname=".${servicename}.lock"
  23. lgsmdir="${rootdir}/lgsm"
  24. logdir="${rootdir}/log"
  25. steamcmddir="${rootdir}/steamcmd"
  26. serverfiles="${rootdir}/serverfiles"
  27. functionsdir="${lgsmdir}/functions"
  28. libdir="${lgsmdir}/lib"
  29. tmpdir="${lgsmdir}/tmp"
  30. configdir="${lgsmdir}/config-lgsm"
  31. configdirserver="${configdir}/${gameservername}"
  32. configdirdefault="${lgsmdir}/config-default"
  33. ## GitHub Branch Select
  34. # Allows for the use of different function files
  35. # from a different repo and/or branch.
  36. githubuser="GameServerManagers"
  37. githubrepo="LinuxGSM"
  38. githubbranch="$TRAVIS_BRANCH"
  39. # Core Function that is required first
  40. core_functions.sh(){
  41. functionfile="${FUNCNAME}"
  42. fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
  43. }
  44. # Bootstrap
  45. # Fetches the core functions required before passed off to core_dl.sh
  46. # Fetches core functions
  47. fn_bootstrap_fetch_file(){
  48. remote_fileurl="${1}"
  49. local_filedir="${2}"
  50. local_filename="${3}"
  51. chmodx="${4:-0}"
  52. run="${5:-0}"
  53. forcedl="${6:-0}"
  54. md5="${7:-0}"
  55. # If the file is missing, then download
  56. if [ ! -f "${local_filedir}/${local_filename}" ]; then
  57. if [ ! -d "${local_filedir}" ]; then
  58. mkdir -p "${local_filedir}"
  59. fi
  60. # Defines curl path
  61. curlpath=$(command -v curl 2>/dev/null)
  62. # If curl exists download file
  63. if [ "$(basename ${curlpath})" == "curl" ]; then
  64. # trap to remove part downloaded files
  65. echo -ne " fetching ${local_filename}...\c"
  66. curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
  67. local exitcode=$?
  68. if [ ${exitcode} -ne 0 ]; then
  69. echo -e "\e[0;31mFAIL\e[0m\n"
  70. if [ -f "${lgsmlog}" ]; then
  71. echo -e "${remote_fileurl}" | tee -a "${lgsmlog}"
  72. echo "${curlcmd}" | tee -a "${lgsmlog}"
  73. fi
  74. exit 1
  75. else
  76. echo -e "\e[0;32mOK\e[0m"
  77. fi
  78. else
  79. echo "[ FAIL ] Curl is not installed"
  80. exit 1
  81. fi
  82. # make file chmodx if chmodx is set
  83. if [ "${chmodx}" == "chmodx" ]; then
  84. chmod +x "${local_filedir}/${local_filename}"
  85. fi
  86. fi
  87. if [ -f "${local_filedir}/${local_filename}" ]; then
  88. # run file if run is set
  89. if [ "${run}" == "run" ]; then
  90. source "${local_filedir}/${local_filename}"
  91. fi
  92. fi
  93. }
  94. fn_bootstrap_fetch_file_github(){
  95. github_file_url_dir="${1}"
  96. github_file_url_name="${2}"
  97. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  98. remote_remote_fileurl="${githuburl}"
  99. local_local_filedir="${3}"
  100. local_local_filename="${github_file_url_name}"
  101. chmodx="${4:-0}"
  102. run="${5:-0}"
  103. forcedldl="${6:-0}"
  104. md5="${7:-0}"
  105. # Passes vars to the file download function
  106. fn_bootstrap_fetch_file "${remote_remote_fileurl}" "${local_local_filedir}" "${local_local_filename}" "${chmodx}" "${run}" "${forcedldl}" "${md5}"
  107. }
  108. # Installer menu
  109. fn_print_center() {
  110. columns="$(tput cols)"
  111. line="$@"
  112. printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
  113. }
  114. fn_print_horizontal(){
  115. char="${1:-=}"
  116. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
  117. }
  118. # Bash Menu
  119. fn_install_menu_bash() {
  120. local resultvar=$1
  121. title=$2
  122. caption=$3
  123. options=$4
  124. fn_print_horizontal
  125. fn_print_center $title
  126. fn_print_center $caption
  127. fn_print_horizontal
  128. menu_options=()
  129. while read -r line || [[ -n "${line}" ]]; do
  130. var=$(echo "${line}" | awk -F "," '{print $2 " - " $3}')
  131. menu_options+=( "${var}" )
  132. done < $options
  133. menu_options+=( "Cancel" )
  134. select option in "${menu_options[@]}"; do
  135. if [ -n "${option}" ] && [ "${option}" != "Cancel" ]; then
  136. eval "$resultvar=\"${option/%\ */}\""
  137. fi
  138. break
  139. done
  140. }
  141. # Whiptail/Dialog Menu
  142. fn_install_menu_whiptail() {
  143. local menucmd=$1
  144. local resultvar=$2
  145. title=$3
  146. caption=$4
  147. options=$5
  148. height=${6:-40}
  149. width=${7:-80}
  150. menuheight=${8:-30}
  151. IFS=","
  152. menu_options=()
  153. while read -r line; do
  154. key=$(echo "${line}" | awk -F "," '{print $3}')
  155. val=$(echo "${line}" | awk -F "," '{print $2}')
  156. menu_options+=( ${val//\"} "${key//\"}" )
  157. done < $options
  158. OPTION=$(${menucmd} --title "${title}" --menu "${caption}" ${height} ${width} ${menuheight} "${menu_options[@]}" 3>&1 1>&2 2>&3)
  159. if [ $? == 0 ]; then
  160. eval "$resultvar=\"${OPTION}\""
  161. else
  162. eval "$resultvar="
  163. fi
  164. }
  165. # Menu selector
  166. fn_install_menu() {
  167. local resultvar=$1
  168. local selection=""
  169. title=$2
  170. caption=$3
  171. options=$4
  172. # Get menu command
  173. for menucmd in whiptail dialog bash; do
  174. if [ -x $(command -v ${menucmd}) ]; then
  175. menucmd=$(command -v ${menucmd})
  176. break
  177. fi
  178. done
  179. case "$(basename ${menucmd})" in
  180. whiptail|dialog)
  181. fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30;;
  182. *)
  183. fn_install_menu_bash selection "${title}" "${caption}" "${options}";;
  184. esac
  185. eval "$resultvar=\"${selection}\""
  186. }
  187. # Gets server info from serverlist.csv and puts in to array
  188. fn_server_info(){
  189. IFS=","
  190. server_info_array=($(grep -aw "${userinput}" "${serverlist}"))
  191. shortname="${server_info_array[0]}" # csgo
  192. gameservername="${server_info_array[1]}" # csgoserver
  193. gamename="${server_info_array[2]}" # Counter Strike: Global Offensive
  194. }
  195. fn_install_getopt(){
  196. userinput="empty"
  197. echo "Usage: $0 [option]"
  198. echo -e ""
  199. echo "Installer - Linux Game Server Managers - Version ${version}"
  200. echo "https://linuxgsm.com"
  201. echo -e ""
  202. echo -e "Commands"
  203. echo -e "install |Select server to install."
  204. echo -e "servername |e.g $0 csgoserver. Enter the required servername will install it."
  205. echo -e "list |List all servers available for install."
  206. exit
  207. }
  208. fn_install_file(){
  209. local_filename="${gameservername}"
  210. if [ -e "${local_filename}" ]; then
  211. i=2
  212. while [ -e "${local_filename}-${i}" ] ; do
  213. let i++
  214. done
  215. local_filename="${local_filename}-${i}"
  216. fi
  217. cp -R "${selfname}" "${local_filename}"
  218. sed -i -e "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${local_filename}"
  219. sed -i -e "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${local_filename}"
  220. echo "Installed ${gamename} server as ${local_filename}"
  221. echo ""
  222. if [ ! -d "${serverfiles}" ]; then
  223. echo "./${local_filename} install"
  224. else
  225. echo "Remember to check server ports"
  226. echo "./${local_filename} details"
  227. fi
  228. echo ""
  229. exit
  230. }
  231. # Prevent from running this script as root.
  232. if [ "$(whoami)" == "root" ]; then
  233. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]; then
  234. echo "[ FAIL ] Do NOT run this script as root!"
  235. exit 1
  236. else
  237. core_functions.sh
  238. check_root.sh
  239. fi
  240. fi
  241. # LinuxGSM installer mode
  242. if [ "${shortname}" == "core" ]; then
  243. userinput=$1
  244. datadir="${tmpdir}/data"
  245. serverlist="${datadir}/serverlist.csv"
  246. # Download the serverlist. This is the complete list of all supported servers.
  247. if [ -f "${serverlist}" ]; then
  248. rm "${serverlist}"
  249. fi
  250. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "serverlist.csv" "nochmodx" "norun" "noforcedl" "nomd5"
  251. if [ ! -f "${serverlist}" ]; then
  252. echo "[ FAIL ] serverlist.csv could not be loaded."
  253. exit 1
  254. fi
  255. if [ "${userinput}" == "list" ]; then
  256. {
  257. awk -F "," '{print $2 "\t" $3}' "${serverlist}"
  258. } | column -s $'\t' -t | more
  259. exit
  260. elif [ "${userinput}" == "install" ]||[ "${userinput}" == "i" ]; then
  261. fn_install_menu result "LinuxGSM" "Select game to install" "${serverlist}"
  262. userinput="${result}"
  263. fn_server_info
  264. if [ "${result}" == "${gameservername}" ]; then
  265. fn_install_file
  266. elif [ "${result}" == "" ]; then
  267. echo "Install canceled"
  268. else
  269. echo "[ FAIL ] menu result does not match gameservername"
  270. echo "result: ${result}"
  271. echo "gameservername: ${gameservername}"
  272. fi
  273. elif [ -n "${userinput}" ]; then
  274. fn_server_info
  275. if [ "${userinput}" == "${gameservername}" ]; then
  276. fn_install_file
  277. fi
  278. else
  279. fn_install_getopt
  280. fi
  281. # LinuxGSM Server Mode
  282. else
  283. core_functions.sh
  284. # Load LinuxGSM configs
  285. # These are required to get all the default variables for the specific server.
  286. # Load the default config. If missing download it. If changed reload it.
  287. if [ ! -f "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" ]; then
  288. mkdir -p "${configdirdefault}/config-lgsm/${gameservername}"
  289. fn_fetch_config "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "_default.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  290. fi
  291. if [ ! -f "${configdirserver}/_default.cfg" ]; then
  292. mkdir -p "${configdirserver}"
  293. echo -ne " copying _default.cfg...\c"
  294. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  295. exitcode=$?
  296. if [ ${exitcode} -ne 0 ]; then
  297. echo -e "\e[0;31mFAIL\e[0m\n"
  298. exit 1
  299. else
  300. echo -e "\e[0;32mOK\e[0m"
  301. fi
  302. else
  303. function_file_diff=$(diff -q ${configdirdefault}/config-lgsm/${gameservername}/_default.cfg ${configdirserver}/_default.cfg)
  304. if [ "${function_file_diff}" != "" ]; then
  305. fn_print_warn_nl "_default.cfg has been altered. reloading config."
  306. echo -ne " copying _default.cfg...\c"
  307. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  308. exitcode=$?
  309. if [ ${exitcode} -ne 0 ]; then
  310. echo -e "\e[0;31mFAIL\e[0m\n"
  311. exit 1
  312. else
  313. echo -e "\e[0;32mOK\e[0m"
  314. fi
  315. fi
  316. fi
  317. source "${configdirserver}/_default.cfg"
  318. # Load the common.cfg config. If missing download it
  319. if [ ! -f "${configdirserver}/common.cfg" ]; then
  320. fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
  321. source "${configdirserver}/common.cfg"
  322. else
  323. source "${configdirserver}/common.cfg"
  324. fi
  325. # Load the instance.cfg config. If missing download it
  326. if [ ! -f "${configdirserver}/${servicename}.cfg" ]; then
  327. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${servicename}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  328. source "${configdirserver}/${servicename}.cfg"
  329. else
  330. source "${configdirserver}/${servicename}.cfg"
  331. fi
  332. # Load the linuxgsm.sh in to tmpdir. If missing download it
  333. if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then
  334. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5"
  335. fi
  336. # Prevents running of core_exit.sh for Travis.
  337. if [ "${travistest}" != "1" ]; then
  338. getopt=$1
  339. core_getopt.sh
  340. fi
  341. fi
  342. fn_currentstatus_tmux(){
  343. check_status.sh
  344. if [ "${status}" != "0" ]; then
  345. currentstatus="ONLINE"
  346. else
  347. currentstatus="OFFLINE"
  348. fi
  349. }
  350. fn_currentstatus_ts3(){
  351. check_status.sh
  352. if [ "${status}" != "0" ]; then
  353. currentstatus="ONLINE"
  354. else
  355. currentstatus="OFFLINE"
  356. fi
  357. }
  358. fn_setstatus(){
  359. fn_currentstatus_tmux
  360. echo""
  361. echo "Required status: ${requiredstatus}"
  362. counter=0
  363. echo "Current status: ${currentstatus}"
  364. while [ "${requiredstatus}" != "${currentstatus}" ]; do
  365. counter=$((counter+1))
  366. fn_currentstatus_tmux
  367. echo -ne "New status: ${currentstatus}\\r"
  368. if [ "${requiredstatus}" == "ONLINE" ]; then
  369. (command_start.sh > /dev/null 2>&1)
  370. else
  371. (command_stop.sh > /dev/null 2>&1)
  372. fi
  373. if [ "${counter}" -gt "5" ]; then
  374. currentstatus="FAIL"
  375. echo "Current status: ${currentstatus}"
  376. echo ""
  377. echo "Unable to start or stop server."
  378. exit 1
  379. fi
  380. done
  381. echo -ne "New status: ${currentstatus}\\r"
  382. echo -e "\n"
  383. echo "Test starting:"
  384. echo ""
  385. sleep 0.5
  386. }
  387. # End of every test will expect the result to either pass or fail
  388. # If the script does not do as intended the whole test will fail
  389. # if expecting a pass
  390. fn_test_result_pass(){
  391. if [ $? != 0 ]; then
  392. echo "================================="
  393. echo "Expected result: PASS"
  394. echo "Actual result: FAIL"
  395. fn_print_fail_nl "TEST FAILED"
  396. exitcode=1
  397. core_exit.sh
  398. else
  399. echo "================================="
  400. echo "Expected result: PASS"
  401. echo "Actual result: PASS"
  402. fn_print_ok_nl "TEST PASSED"
  403. echo ""
  404. fi
  405. }
  406. # if expecting a fail
  407. fn_test_result_fail(){
  408. if [ $? == 0 ]; then
  409. echo "================================="
  410. echo "Expected result: FAIL"
  411. echo "Actual result: PASS"
  412. fn_print_fail_nl "TEST FAILED"
  413. exitcode=1
  414. core_exit.sh
  415. else
  416. echo "================================="
  417. echo "Expected result: FAIL"
  418. echo "Actual result: FAIL"
  419. fn_print_ok_nl "TEST PASSED"
  420. echo ""
  421. fi
  422. }
  423. echo "================================="
  424. echo "Travis CI Tests"
  425. echo "Linux Game Server Manager"
  426. echo "by Daniel Gibbs"
  427. echo "Contributors: http://goo.gl/qLmitD"
  428. echo "https://linuxgsm.com"
  429. echo "================================="
  430. echo ""
  431. echo "================================="
  432. echo "Server Tests"
  433. echo "Using: ${gamename}"
  434. echo "Testing Branch: $TRAVIS_BRANCH"
  435. echo "================================="
  436. echo ""
  437. echo "0.1 - Create log dir's"
  438. echo "================================="
  439. echo "Description:"
  440. echo "Create log dir's"
  441. echo ""
  442. (install_logs.sh)
  443. echo "0.2 - Enable dev-debug"
  444. echo "================================="
  445. echo "Description:"
  446. echo "Enable dev-debug"
  447. echo ""
  448. (command_dev_debug.sh)
  449. fn_test_result_pass
  450. grep "functionfile=" .dev-debug
  451. echo "1.0 - start - no files"
  452. echo "================================="
  453. echo "Description:"
  454. echo "test script reaction to missing server files."
  455. echo "Command: ./jc2server start"
  456. echo ""
  457. (command_start.sh)
  458. fn_test_result_fail
  459. grep "functionfile=" .dev-debug
  460. echo ""
  461. echo "1.1 - getopt"
  462. echo "================================="
  463. echo "Description:"
  464. echo "displaying options messages."
  465. echo "Command: ./jc2server"
  466. echo ""
  467. (core_getopt.sh)
  468. fn_test_result_pass
  469. grep "functionfile=" .dev-debug
  470. echo ""
  471. echo "1.2 - getopt with incorrect args"
  472. echo "================================="
  473. echo "Description:"
  474. echo "displaying options messages."
  475. echo "Command: ./jc2server abc123"
  476. echo ""
  477. getopt="abc123"
  478. (core_getopt.sh)
  479. fn_test_result_fail
  480. grep "functionfile=" .dev-debug
  481. echo ""
  482. echo "2.0 - install"
  483. echo "================================="
  484. echo "Description:"
  485. echo "install ${gamename} server."
  486. echo "Command: ./jc2server auto-install"
  487. (fn_autoinstall)
  488. fn_test_result_pass
  489. grep "functionfile=" .dev-debug
  490. echo ""
  491. echo "3.1 - start"
  492. echo "================================="
  493. echo "Description:"
  494. echo "start ${gamename} server."
  495. echo "Command: ./jc2server start"
  496. requiredstatus="OFFLINE"
  497. fn_setstatus
  498. (command_start.sh)
  499. fn_test_result_pass
  500. grep "functionfile=" .dev-debug
  501. echo ""
  502. echo "3.2 - start - online"
  503. echo "================================="
  504. echo "Description:"
  505. echo "start ${gamename} server while already running."
  506. echo "Command: ./jc2server start"
  507. requiredstatus="ONLINE"
  508. fn_setstatus
  509. (command_start.sh)
  510. fn_test_result_fail
  511. echo ""
  512. echo "3.3 - start - updateonstart"
  513. echo "================================="
  514. echo "Description:"
  515. echo "will update server on start."
  516. echo "Command: ./jc2server start"
  517. requiredstatus="OFFLINE"
  518. fn_setstatus
  519. (updateonstart="on";command_start.sh)
  520. fn_test_result_pass
  521. echo ""
  522. echo "3.4 - stop"
  523. echo "================================="
  524. echo "Description:"
  525. echo "stop ${gamename} server."
  526. echo "Command: ./jc2server stop"
  527. requiredstatus="ONLINE"
  528. fn_setstatus
  529. (command_stop.sh)
  530. fn_test_result_pass
  531. echo ""
  532. echo "3.5 - stop - offline"
  533. echo "================================="
  534. echo "Description:"
  535. echo "stop ${gamename} server while already stopped."
  536. echo "Command: ./jc2server stop"
  537. requiredstatus="OFFLINE"
  538. fn_setstatus
  539. (command_stop.sh)
  540. fn_test_result_fail
  541. echo ""
  542. echo "3.6 - restart"
  543. echo "================================="
  544. echo "Description:"
  545. echo "restart ${gamename}."
  546. echo "Command: ./jc2server restart"
  547. requiredstatus="ONLINE"
  548. fn_setstatus
  549. (command_restart.sh)
  550. fn_test_result_pass
  551. echo ""
  552. echo "3.7 - restart - offline"
  553. echo "================================="
  554. echo "Description:"
  555. echo "restart ${gamename} while already stopped."
  556. echo "Command: ./jc2server restart"
  557. requiredstatus="OFFLINE"
  558. fn_setstatus
  559. (command_restart.sh)
  560. fn_test_result_pass
  561. echo "4.1 - update"
  562. echo "================================="
  563. echo "Description:"
  564. echo "check for updates."
  565. echo "Command: ./jc2server update"
  566. requiredstatus="OFFLINE"
  567. fn_setstatus
  568. (command_update.sh)
  569. fn_test_result_pass
  570. echo ""
  571. echo "4.2 - update - change buildid"
  572. echo "================================="
  573. echo "Description:"
  574. echo "change the buildid tricking SteamCMD to update."
  575. echo "Command: ./jc2server update"
  576. requiredstatus="OFFLINE"
  577. fn_setstatus
  578. fn_print_info_nl "changed buildid to 0."
  579. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  580. (command_update.sh)
  581. fn_test_result_pass
  582. echo ""
  583. echo "4.3 - update - change buildid - online"
  584. echo "================================="
  585. echo "Description:"
  586. echo "change the buildid tricking SteamCMD to update server while already running."
  587. echo "Command: ./jc2server update"
  588. requiredstatus="ONLINE"
  589. fn_setstatus
  590. fn_print_info_nl "changed buildid to 0."
  591. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  592. (command_update.sh)
  593. fn_test_result_pass
  594. echo ""
  595. echo "4.4 - update - remove appmanifest file"
  596. echo "================================="
  597. echo "Description:"
  598. echo "removing appmanifest file will cause script to repair."
  599. echo "Command: ./jc2server update"
  600. requiredstatus="OFFLINE"
  601. fn_setstatus
  602. fn_print_info_nl "removed appmanifest_${appid}.acf."
  603. rm --verbose "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  604. (command_update.sh)
  605. fn_test_result_pass
  606. echo ""
  607. echo "4.5 - force-update"
  608. echo "================================="
  609. echo "Description:"
  610. echo "force-update bypassing update check."
  611. echo "Command: ./jc2server force-update"
  612. requiredstatus="OFFLINE"
  613. fn_setstatus
  614. (forceupdate=1;command_update.sh)
  615. fn_test_result_pass
  616. echo ""
  617. echo "4.6 - force-update - online"
  618. echo "================================="
  619. echo "Description:"
  620. echo "force-update bypassing update check server while already running."
  621. echo "Command: ./jc2server force-update"
  622. requiredstatus="ONLINE"
  623. fn_setstatus
  624. (forceupdate=1;command_update.sh)
  625. fn_test_result_pass
  626. echo ""
  627. echo "4.7 - validate"
  628. echo "================================="
  629. echo "Description:"
  630. echo "validate server files."
  631. echo "Command: ./jc2server validate"
  632. requiredstatus="OFFLINE"
  633. fn_setstatus
  634. (command_validate.sh)
  635. fn_test_result_pass
  636. echo ""
  637. echo "4.8 - validate - online"
  638. echo "================================="
  639. echo "Description:"
  640. echo "validate server files while server already running."
  641. echo ""
  642. echo "Command: ./jc2server validate"
  643. requiredstatus="ONLINE"
  644. fn_setstatus
  645. (command_validate.sh)
  646. fn_test_result_pass
  647. echo ""
  648. echo "Inserting IP address"
  649. echo "================================="
  650. echo "Description:"
  651. echo "Inserting Travis IP in to config."
  652. echo "Allows monitor to work"
  653. travisip=$(ip -o -4 addr|grep eth0|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
  654. sed -i "/BindIP/c\BindIP = \"${travisip}\"," "${serverfiles}/config.lua"
  655. echo "IP: ${travisip}"
  656. echo ""
  657. echo "5.1 - monitor - online"
  658. echo "================================="
  659. echo "Description:"
  660. echo "run monitor server while already running."
  661. echo "Command: ./jc2server monitor"
  662. requiredstatus="ONLINE"
  663. fn_setstatus
  664. (command_monitor.sh)
  665. fn_test_result_pass
  666. echo ""
  667. echo "5.2 - monitor - offline - with lockfile"
  668. echo "================================="
  669. echo "Description:"
  670. echo "run monitor while server is offline with lockfile."
  671. echo "Command: ./jc2server monitor"
  672. requiredstatus="OFFLINE"
  673. fn_setstatus
  674. fn_print_info_nl "creating lockfile."
  675. date > "${rootdir}/${lockselfname}"
  676. (command_monitor.sh)
  677. fn_test_result_pass
  678. echo ""
  679. echo "5.3 - monitor - offline - no lockfile"
  680. echo "================================="
  681. echo "Description:"
  682. echo "run monitor while server is offline with no lockfile."
  683. echo "Command: ./jc2server monitor"
  684. requiredstatus="OFFLINE"
  685. fn_setstatus
  686. (command_monitor.sh)
  687. fn_test_result_fail
  688. echo ""
  689. echo "5.4 - monitor - gsquery.py failure"
  690. echo "================================="
  691. echo "Description:"
  692. echo "gsquery.py will fail to query port."
  693. echo "Command: ./jc2server monitor"
  694. requiredstatus="ONLINE"
  695. fn_setstatus
  696. cp "${servercfgfullpath}" "config.lua"
  697. sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
  698. (command_monitor.sh)
  699. fn_test_result_fail
  700. echo ""
  701. fn_print_info_nl "Re-generating ${servercfg}."
  702. cp -v "config.lua" "${servercfgfullpath}"
  703. echo "================================="
  704. echo ""
  705. echo "6.0 - details"
  706. echo "================================="
  707. echo "Description:"
  708. echo "display details."
  709. echo "Command: ./jc2server details"
  710. requiredstatus="ONLINE"
  711. fn_setstatus
  712. (command_details.sh)
  713. fn_test_result_pass
  714. echo ""
  715. echo "6.1 - post details"
  716. echo "================================="
  717. echo "Description:"
  718. echo "post details."
  719. echo "Command: ./jc2server postdetails"
  720. requiredstatus="ONLINE"
  721. fn_setstatus
  722. (command_postdetails.sh)
  723. fn_test_result_pass
  724. echo ""
  725. echo "7.0 - backup"
  726. echo "================================="
  727. echo "Description:"
  728. echo "run a backup."
  729. echo "Command: ./jc2server backup"
  730. requiredstatus="ONLINE"
  731. fn_setstatus
  732. echo "test de-activated until issue #1839 fixed"
  733. #(command_backup.sh)
  734. fn_test_result_pass
  735. echo ""
  736. echo "8.0 - dev - detect glibc"
  737. echo "================================="
  738. echo "Description:"
  739. echo "detect glibc."
  740. echo "Command: ./jc2server detect-glibc"
  741. requiredstatus="ONLINE"
  742. fn_setstatus
  743. (command_dev_detect_glibc.sh)
  744. fn_test_result_pass
  745. echo ""
  746. echo "8.1 - dev - detect ldd"
  747. echo "================================="
  748. echo "Description:"
  749. echo "detect ldd."
  750. echo "Command: ./jc2server detect-ldd"
  751. requiredstatus="ONLINE"
  752. fn_setstatus
  753. (command_dev_detect_ldd.sh)
  754. fn_test_result_pass
  755. echo ""
  756. echo "8.2 - dev - detect deps"
  757. echo "================================="
  758. echo "Description:"
  759. echo "detect dependencies."
  760. echo "Command: ./jc2server detect-deps"
  761. requiredstatus="ONLINE"
  762. fn_setstatus
  763. (command_dev_detect_deps.sh)
  764. fn_test_result_pass
  765. echo ""
  766. echo "================================="
  767. echo "Server Tests - Complete!"
  768. echo "Using: ${gamename}"
  769. echo "================================="
  770. requiredstatus="OFFLINE"
  771. fn_setstatus
  772. fn_print_info "Tidying up directories."
  773. rm -rfv "${serverfiles}"
  774. core_exit.sh