tests_jc2server.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2017 Daniel Gibbs
  5. # Purpose: TravisCI 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://gameservermanagers.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://gameservermanagers.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 "TravisCI Tests"
  425. echo "Linux Game Server Manager"
  426. echo "by Daniel Gibbs"
  427. echo "https://gameservermanagers.com"
  428. echo "================================="
  429. echo ""
  430. echo "================================="
  431. echo "Server Tests"
  432. echo "Using: ${gamename}"
  433. echo "Testing Branch: $TRAVIS_BRANCH"
  434. echo "================================="
  435. echo ""
  436. echo "0.1 - Create log dir's"
  437. echo "================================="
  438. echo "Description:"
  439. echo "Create log dir's"
  440. echo ""
  441. (install_logs.sh)
  442. echo "0.2 - Enable dev-debug"
  443. echo "================================="
  444. echo "Description:"
  445. echo "Enable dev-debug"
  446. echo ""
  447. (command_dev_debug.sh)
  448. fn_test_result_pass
  449. echo "1.0 - start - no files"
  450. echo "================================="
  451. echo "Description:"
  452. echo "test script reaction to missing server files."
  453. echo "Command: ./jc2server start"
  454. echo ""
  455. (command_start.sh)
  456. fn_test_result_fail
  457. echo ""
  458. echo "1.1 - getopt"
  459. echo "================================="
  460. echo "Description:"
  461. echo "displaying options messages."
  462. echo "Command: ./jc2server"
  463. echo ""
  464. (core_getopt.sh)
  465. fn_test_result_pass
  466. echo ""
  467. echo "1.2 - getopt with incorrect args"
  468. echo "================================="
  469. echo "Description:"
  470. echo "displaying options messages."
  471. echo "Command: ./jc2server abc123"
  472. echo ""
  473. getopt="abc123"
  474. (core_getopt.sh)
  475. fn_test_result_fail
  476. echo ""
  477. echo "2.0 - install"
  478. echo "================================="
  479. echo "Description:"
  480. echo "install ${gamename} server."
  481. echo "Command: ./jc2server auto-install"
  482. (fn_autoinstall)
  483. fn_test_result_pass
  484. echo ""
  485. echo "3.1 - start"
  486. echo "================================="
  487. echo "Description:"
  488. echo "start ${gamename} server."
  489. echo "Command: ./jc2server start"
  490. requiredstatus="OFFLINE"
  491. fn_setstatus
  492. (command_start.sh)
  493. fn_test_result_pass
  494. echo ""
  495. echo "3.2 - start - online"
  496. echo "================================="
  497. echo "Description:"
  498. echo "start ${gamename} server while already running."
  499. echo "Command: ./jc2server start"
  500. requiredstatus="ONLINE"
  501. fn_setstatus
  502. (command_start.sh)
  503. fn_test_result_fail
  504. echo ""
  505. echo "3.3 - start - updateonstart"
  506. echo "================================="
  507. echo "Description:"
  508. echo "will update server on start."
  509. echo "Command: ./jc2server start"
  510. requiredstatus="OFFLINE"
  511. fn_setstatus
  512. (updateonstart="on";command_start.sh)
  513. fn_test_result_pass
  514. echo ""
  515. echo "3.4 - stop"
  516. echo "================================="
  517. echo "Description:"
  518. echo "stop ${gamename} server."
  519. echo "Command: ./jc2server stop"
  520. requiredstatus="ONLINE"
  521. fn_setstatus
  522. (command_stop.sh)
  523. fn_test_result_pass
  524. echo ""
  525. echo "3.5 - stop - offline"
  526. echo "================================="
  527. echo "Description:"
  528. echo "stop ${gamename} server while already stopped."
  529. echo "Command: ./jc2server stop"
  530. requiredstatus="OFFLINE"
  531. fn_setstatus
  532. (command_stop.sh)
  533. fn_test_result_fail
  534. echo ""
  535. echo "3.6 - restart"
  536. echo "================================="
  537. echo "Description:"
  538. echo "restart ${gamename}."
  539. echo "Command: ./jc2server restart"
  540. requiredstatus="ONLINE"
  541. fn_setstatus
  542. (command_restart.sh)
  543. fn_test_result_pass
  544. echo ""
  545. echo "3.7 - restart - offline"
  546. echo "================================="
  547. echo "Description:"
  548. echo "restart ${gamename} while already stopped."
  549. echo "Command: ./jc2server restart"
  550. requiredstatus="OFFLINE"
  551. fn_setstatus
  552. (command_restart.sh)
  553. fn_test_result_pass
  554. echo "4.1 - update"
  555. echo "================================="
  556. echo "Description:"
  557. echo "check for updates."
  558. echo "Command: ./jc2server update"
  559. requiredstatus="OFFLINE"
  560. fn_setstatus
  561. (command_update.sh)
  562. fn_test_result_pass
  563. echo ""
  564. echo "4.2 - update - change buildid"
  565. echo "================================="
  566. echo "Description:"
  567. echo "change the buildid tricking SteamCMD to update."
  568. echo "Command: ./jc2server update"
  569. requiredstatus="OFFLINE"
  570. fn_setstatus
  571. fn_print_info_nl "changed buildid to 0."
  572. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  573. (command_update.sh)
  574. fn_test_result_pass
  575. echo ""
  576. echo "4.3 - update - change buildid - online"
  577. echo "================================="
  578. echo "Description:"
  579. echo "change the buildid tricking SteamCMD to update server while already running."
  580. echo "Command: ./jc2server update"
  581. requiredstatus="ONLINE"
  582. fn_setstatus
  583. fn_print_info_nl "changed buildid to 0."
  584. sed -i 's/[0-9]\+/0/' "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  585. (command_update.sh)
  586. fn_test_result_pass
  587. echo ""
  588. echo "4.4 - update - remove appmanifest file"
  589. echo "================================="
  590. echo "Description:"
  591. echo "removing appmanifest file will cause script to repair."
  592. echo "Command: ./jc2server update"
  593. requiredstatus="OFFLINE"
  594. fn_setstatus
  595. fn_print_info_nl "removed appmanifest_${appid}.acf."
  596. rm --verbose "${serverfiles}/steamapps/appmanifest_${appid}.acf"
  597. (command_update.sh)
  598. fn_test_result_pass
  599. echo ""
  600. echo "4.5 - force-update"
  601. echo "================================="
  602. echo "Description:"
  603. echo "force-update bypassing update check."
  604. echo "Command: ./jc2server force-update"
  605. requiredstatus="OFFLINE"
  606. fn_setstatus
  607. (forceupdate=1;command_update.sh)
  608. fn_test_result_pass
  609. echo ""
  610. echo "4.6 - force-update - online"
  611. echo "================================="
  612. echo "Description:"
  613. echo "force-update bypassing update check server while already running."
  614. echo "Command: ./jc2server force-update"
  615. requiredstatus="ONLINE"
  616. fn_setstatus
  617. (forceupdate=1;command_update.sh)
  618. fn_test_result_pass
  619. echo ""
  620. echo "4.7 - validate"
  621. echo "================================="
  622. echo "Description:"
  623. echo "validate server files."
  624. echo "Command: ./jc2server validate"
  625. requiredstatus="OFFLINE"
  626. fn_setstatus
  627. (command_validate.sh)
  628. fn_test_result_pass
  629. echo ""
  630. echo "4.8 - validate - online"
  631. echo "================================="
  632. echo "Description:"
  633. echo "validate server files while server already running."
  634. echo ""
  635. echo "Command: ./jc2server validate"
  636. requiredstatus="ONLINE"
  637. fn_setstatus
  638. (command_validate.sh)
  639. fn_test_result_pass
  640. echo ""
  641. echo "Inserting IP address"
  642. echo "================================="
  643. echo "Description:"
  644. echo "Inserting Travis IP in to config."
  645. echo "Allows monitor to work"
  646. travisip=$(ip -o -4 addr|grep eth0|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
  647. sed -i "/BindIP/c\BindIP = \"${travisip}\"," "${serverfiles}/config.lua"
  648. echo "IP: ${travisip}"
  649. echo ""
  650. echo "5.1 - monitor - online"
  651. echo "================================="
  652. echo "Description:"
  653. echo "run monitor server while already running."
  654. echo "Command: ./jc2server monitor"
  655. requiredstatus="ONLINE"
  656. fn_setstatus
  657. (command_monitor.sh)
  658. fn_test_result_pass
  659. echo ""
  660. echo "5.2 - monitor - offline - with lockfile"
  661. echo "================================="
  662. echo "Description:"
  663. echo "run monitor while server is offline with lockfile."
  664. echo "Command: ./jc2server monitor"
  665. requiredstatus="OFFLINE"
  666. fn_setstatus
  667. fn_print_info_nl "creating lockfile."
  668. date > "${rootdir}/${lockselfname}"
  669. (command_monitor.sh)
  670. fn_test_result_pass
  671. echo ""
  672. echo "5.3 - monitor - offline - no lockfile"
  673. echo "================================="
  674. echo "Description:"
  675. echo "run monitor while server is offline with no lockfile."
  676. echo "Command: ./jc2server monitor"
  677. requiredstatus="OFFLINE"
  678. fn_setstatus
  679. (command_monitor.sh)
  680. fn_test_result_fail
  681. echo ""
  682. echo "5.4 - monitor - gsquery.py failure"
  683. echo "================================="
  684. echo "Description:"
  685. echo "gsquery.py will fail to query port."
  686. echo "Command: ./jc2server monitor"
  687. requiredstatus="ONLINE"
  688. fn_setstatus
  689. cp "${servercfgfullpath}" "config.lua"
  690. sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
  691. (command_monitor.sh)
  692. fn_test_result_fail
  693. echo ""
  694. fn_print_info_nl "Re-generating ${servercfg}."
  695. cp -v "config.lua" "${servercfgfullpath}"
  696. echo "================================="
  697. echo ""
  698. echo "6.0 - details"
  699. echo "================================="
  700. echo "Description:"
  701. echo "display details."
  702. echo "Command: ./jc2server details"
  703. requiredstatus="ONLINE"
  704. fn_setstatus
  705. (command_details.sh)
  706. fn_test_result_pass
  707. echo ""
  708. echo "6.1 - post details"
  709. echo "================================="
  710. echo "Description:"
  711. echo "post details."
  712. echo "Command: ./jc2server postdetails"
  713. requiredstatus="ONLINE"
  714. fn_setstatus
  715. (command_postdetails.sh)
  716. fn_test_result_pass
  717. echo ""
  718. echo "7.0 - backup"
  719. echo "================================="
  720. echo "Description:"
  721. echo "run a backup."
  722. echo "Command: ./jc2server backup"
  723. requiredstatus="ONLINE"
  724. fn_setstatus
  725. (command_backup.sh)
  726. fn_test_result_pass
  727. echo ""
  728. echo "8.0 - dev - detect glibc"
  729. echo "================================="
  730. echo "Description:"
  731. echo "detect glibc."
  732. echo "Command: ./jc2server detect-glibc"
  733. requiredstatus="ONLINE"
  734. fn_setstatus
  735. (command_dev_detect_glibc.sh)
  736. fn_test_result_pass
  737. echo ""
  738. echo "8.1 - dev - detect ldd"
  739. echo "================================="
  740. echo "Description:"
  741. echo "detect ldd."
  742. echo "Command: ./jc2server detect-ldd"
  743. requiredstatus="ONLINE"
  744. fn_setstatus
  745. (command_dev_detect_ldd.sh)
  746. fn_test_result_pass
  747. echo ""
  748. echo "8.2 - dev - detect deps"
  749. echo "================================="
  750. echo "Description:"
  751. echo "detect dependencies."
  752. echo "Command: ./jc2server detect-deps"
  753. requiredstatus="ONLINE"
  754. fn_setstatus
  755. (command_dev_detect_deps.sh)
  756. fn_test_result_pass
  757. echo ""
  758. echo "================================="
  759. echo "Server Tests - Complete!"
  760. echo "Using: ${gamename}"
  761. echo "================================="
  762. requiredstatus="OFFLINE"
  763. fn_setstatus
  764. fn_print_info "Tidying up directories."
  765. rm -rfv "${serverfiles}"
  766. core_exit.sh