tests_jc2server.sh 38 KB

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