tests_jc2server.sh 22 KB

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