tests_jc2server.sh 23 KB

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