info_messages.sh 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. #!/bin/bash
  2. # LinuxGSM info_messages.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: Defines server info messages for details, alerts.
  6. # Standard Details
  7. # This applies to all engines
  8. fn_info_message_head(){
  9. echo -e ""
  10. echo -e "${lightyellow}Summary${default}"
  11. fn_messages_separator
  12. echo -e "Message"
  13. echo -e "${alertbody}"
  14. echo -e ""
  15. echo -e "Game"
  16. echo -e "${gamename}"
  17. echo -e ""
  18. echo -e "Server name"
  19. echo -e "${servername}"
  20. echo -e ""
  21. echo -e "Hostname"
  22. echo -e "${HOSTNAME}"
  23. echo -e ""
  24. echo -e "Server IP"
  25. echo -e "${ip}:${port}"
  26. }
  27. fn_info_message_distro(){
  28. #
  29. # Distro Details
  30. # =====================================
  31. # Distro: Ubuntu 14.04.4 LTS
  32. # Arch: x86_64
  33. # Kernel: 3.13.0-79-generic
  34. # Hostname: hostname
  35. # tmux: tmux 1.8
  36. # GLIBC: 2.19
  37. echo -e ""
  38. echo -e "${lightyellow}Distro Details${default}"
  39. fn_messages_separator
  40. {
  41. echo -e "${blue}Distro:\t${default}${distroname}"
  42. echo -e "${blue}Arch:\t${default}${arch}"
  43. echo -e "${blue}Kernel:\t${default}${kernel}"
  44. echo -e "${blue}Hostname:\t${default}${HOSTNAME}"
  45. echo -e "${blue}tmux:\t${default}${tmuxv}"
  46. echo -e "${blue}GLIBC:\t${default}${glibcversion}"
  47. } | column -s $'\t' -t
  48. }
  49. fn_info_message_performance(){
  50. #
  51. # Performance
  52. # =====================================
  53. # Uptime: 55d, 3h, 38m
  54. # Avg Load: 1.00, 1.01, 0.78
  55. #
  56. # Mem: total used free cached
  57. # Physical: 741M 656M 85M 256M
  58. # Swap: 0B 0B 0B
  59. echo -e ""
  60. echo -e "${lightyellow}Performance${default}"
  61. {
  62. echo -e "${blue}Uptime:\t${default}${days}d, ${hours}h, ${minutes}m"
  63. echo -e "${blue}Avg Load:\t${default}${load}"
  64. } | column -s $'\t' -t
  65. echo -e ""
  66. {
  67. echo -e "${blue}Mem:\t${blue}total\t used\t free\t cached${default}"
  68. echo -e "${blue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}\t${physmemcached}${default}"
  69. echo -e "${blue}Swap:\t${default}${swaptotal}\t${swapused}\t${swapfree}${default}"
  70. } | column -s $'\t' -t
  71. }
  72. fn_info_message_disk(){
  73. #
  74. # Storage
  75. # =====================================
  76. # Filesystem: /dev/disk/by-uuid/320c8edd-a2ce-4a23-8c9d-e00a7af2d6ff
  77. # Total: 15G
  78. # Used: 8.4G
  79. # Available: 5.7G
  80. # LinuxGSM Total: 1G
  81. # Serverfiles: 961M
  82. # Backups: 2G
  83. echo -e ""
  84. echo -e "${lightyellow}Storage${default}"
  85. fn_messages_separator
  86. {
  87. echo -e "${blue}Filesystem:\t${default}${filesystem}"
  88. echo -e "${blue}Total:\t${default}${totalspace}"
  89. echo -e "${blue}Used:\t${default}${usedspace}"
  90. echo -e "${blue}Available:\t${default}${availspace}"
  91. echo -e "${blue}LinuxGSM Total:\t${default}${rootdirdu}"
  92. echo -e "${blue}Serverfiles:\t${default}${serverfilesdu}"
  93. if [ -d "${backupdir}" ]; then
  94. echo -e "${blue}Backups:\t${default}${backupdirdu}"
  95. fi
  96. } | column -s $'\t' -t
  97. }
  98. fn_info_message_gameserver(){
  99. #
  100. # Quake Live Server Details
  101. # =====================================
  102. # Server name: ql-server
  103. # Server IP: 1.2.3.4:27960
  104. # RCON password: CHANGE_ME
  105. # Server password: NOT SET
  106. # Maxplayers: 16
  107. # Status: OFFLINE
  108. echo -e ""
  109. echo -e "${lightgreen}${gamename} Server Details${default}"
  110. fn_info_message_password_strip
  111. fn_messages_separator
  112. {
  113. # Server name
  114. if [ -n "${servername}" ]; then
  115. echo -e "${blue}Server name:\t${default}${servername}"
  116. fi
  117. # Branch
  118. if [ -n "${branch}" ]; then
  119. echo -e "${blue}Branch:\t${default}${branch}"
  120. fi
  121. # Server ip
  122. echo -e "${blue}Server IP:\t${default}${ip}:${port}"
  123. # External server ip
  124. if [ -n "${extip}" ]; then
  125. if [ "${ip}" != "${extip}" ]; then
  126. echo -e "${blue}Internet IP:\t${default}${extip}:${port}"
  127. fi
  128. fi
  129. # Server password
  130. if [ -n "${serverpassword}" ]; then
  131. echo -e "${blue}Server password:\t${default}${serverpassword}"
  132. fi
  133. # RCON password
  134. if [ -n "${rconpassword}" ]; then
  135. echo -e "${blue}RCON password:\t${default}${rconpassword}"
  136. fi
  137. # RCON web (Rust)
  138. if [ -n "${rconweb}" ]; then
  139. echo -e "${blue}RCON web:\t${default}${rconweb}"
  140. fi
  141. # Admin password
  142. if [ -n "${adminpassword}" ]; then
  143. echo -e "${blue}Admin password:\t${default}${adminpassword}"
  144. fi
  145. # Stats password (Quake Live)
  146. if [ -n "${statspassword}" ]; then
  147. echo -e "${blue}Stats password:\t${default}${statspassword}"
  148. fi
  149. # Maxplayers
  150. if [ -n "${maxplayers}" ]; then
  151. echo -e "${blue}Maxplayers:\t${default}${maxplayers}"
  152. fi
  153. # Game mode
  154. if [ -n "${gamemode}" ]; then
  155. echo -e "${blue}Game mode:\t${default}${gamemode}"
  156. fi
  157. # Game world
  158. if [ -n "${gameworld}" ]; then
  159. echo -e "${blue}Game world:\t${default}${gameworld}"
  160. fi
  161. # Tick rate
  162. if [ -n "${tickrate}" ]; then
  163. echo -e "${blue}Tick rate:\t${default}${tickrate}"
  164. fi
  165. # Sharding (Don't Starve Together)
  166. if [ -n "${sharding}" ]; then
  167. echo -e "${blue}Sharding:\t${default}${sharding}"
  168. fi
  169. # Master (Don't Starve Together)
  170. if [ -n "${master}" ]; then
  171. echo -e "${blue}Master:\t${default}${master}"
  172. fi
  173. # Shard (Don't Starve Together)
  174. if [ -n "${shard}" ]; then
  175. echo -e "${blue}Shard:\t${default}${shard}"
  176. fi
  177. # Cluster (Don't Starve Together)
  178. if [ -n "${cluster}" ]; then
  179. echo -e "${blue}Cluster:\t${default}${cluster}"
  180. fi
  181. # Cave (Don't Starve Together)
  182. if [ -n "${cave}" ]; then
  183. echo -e "${blue}Cave:\t${default}${cave}"
  184. fi
  185. # Creativemode (Hurtworld)
  186. if [ -n "${creativemode}" ]; then
  187. echo -e "${blue}Creativemode:\t${default}${creativemode}"
  188. fi
  189. # TeamSpeak dbplugin
  190. if [ -n "${dbplugin}" ]; then
  191. echo -e "${blue}dbplugin:\t${default}${dbplugin}"
  192. fi
  193. # ASE (Multi Theft Auto)
  194. if [ -n "${ase}" ]; then
  195. echo -e "${blue}ASE:\t${default}${ase}"
  196. fi
  197. # Save interval (Rust)
  198. if [ -n "${saveinterval}" ]; then
  199. echo -e "${blue}ASE:\t${default}${saveinterval} s"
  200. fi
  201. # Random map rotation mode (Squad)
  202. if [ -n "${randommap}" ]; then
  203. echo -e "${blue}Map rotation:\t${default}${randommap}"
  204. fi
  205. # Online status
  206. if [ "${status}" == "0" ]; then
  207. echo -e "${blue}Status:\t${red}OFFLINE${default}"
  208. else
  209. echo -e "${blue}Status:\t${green}ONLINE${default}"
  210. fi
  211. } | column -s $'\t' -t
  212. echo -e ""
  213. }
  214. fn_info_message_script(){
  215. #
  216. # qlserver Script Details
  217. # =====================================
  218. # Service name: ql-server
  219. # qlserver version: 150316
  220. # User: lgsm
  221. # Email alert: off
  222. # Update on start: off
  223. # Location: /home/lgsm/qlserver
  224. # Config file: /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
  225. echo -e "${lightgreen}${selfname} Script Details${default}"
  226. fn_messages_separator
  227. {
  228. # Service name
  229. echo -e "${blue}Service name:\t${default}${servicename}"
  230. # Script version
  231. if [ -n "${version}" ]; then
  232. echo -e "${blue}${selfname} version:\t${default}${version}"
  233. fi
  234. # User
  235. echo -e "${blue}User:\t${default}$(whoami)"
  236. # GLIBC required
  237. if [ -n "${glibcrequired}" ]; then
  238. if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
  239. :
  240. elif [ "${glibcrequired}" == "UNKNOWN" ]; then
  241. echo -e "${blue}GLIBC required:\t${red}${glibcrequired}"
  242. elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
  243. if [ "${glibcfix}" == "yes" ]; then
  244. echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${green}Using GLIBC fix${default})"
  245. else
  246. echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${red}GLIBC version too old${default})"
  247. fi
  248. else
  249. echo -e "${blue}GLIBC required:\t${green}${glibcrequired}${default}"
  250. fi
  251. fi
  252. # Email alert
  253. echo -e "${blue}Email alert:\t${default}${emailalert}"
  254. # Pushbullet alert
  255. echo -e "${blue}Pushbullet alert:\t${default}${pushbulletalert}"
  256. # Update on start
  257. if [ -n "${updateonstart}" ]; then
  258. echo -e "${blue}Update on start:\t${default}${updateonstart}"
  259. fi
  260. # Script location
  261. echo -e "${blue}Location:\t${default}${rootdir}"
  262. # Config file location
  263. if [ -n "${servercfgfullpath}" ]; then
  264. if [ -f "${servercfgfullpath}" ]; then
  265. echo -e "${blue}Config file:\t${default}${servercfgfullpath}"
  266. elif [ -d "${servercfgfullpath}" ]; then
  267. echo -e "${blue}Config dir:\t${default}${servercfgfullpath}"
  268. else
  269. echo -e "${blue}Config file:\t${default}${red}${servercfgfullpath}${default} (${red}FILE MISSING${default})"
  270. fi
  271. fi
  272. # Network config file location (ARMA 3)
  273. if [ -n "${networkcfgfullpath}" ]; then
  274. echo -e "${blue}Network config file:\t${default}${networkcfgfullpath}"
  275. fi
  276. } | column -s $'\t' -t
  277. }
  278. fn_info_message_backup(){
  279. #
  280. # Backups
  281. # =====================================
  282. # No. of backups: 1
  283. # Latest backup:
  284. # date: Fri May 6 18:34:19 UTC 2016
  285. # file: /home/lgsm/qlserver/backups/ql-server-2016-05-06-183239.tar.gz
  286. # size: 945M
  287. echo -e ""
  288. echo -e "${lightgreen}Backups${default}"
  289. fn_messages_separator
  290. if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
  291. echo -e "No Backups created"
  292. else
  293. {
  294. echo -e "${blue}No. of backups:\t${default}${backupcount}"
  295. echo -e "${blue}Latest backup:${default}"
  296. if [ "${lastbackupdaysago}" == "0" ]; then
  297. echo -e "${blue} date:\t${default}${lastbackupdate} (less than 1 day ago)"
  298. elif [ "${lastbackupdaysago}" == "1" ]; then
  299. echo -e "${blue} date:\t${default}${lastbackupdate} (1 day ago)"
  300. else
  301. echo -e "${blue} date:\t${default}${lastbackupdate} (${lastbackupdaysago} days ago)"
  302. fi
  303. echo -e "${blue} file:\t${default}${lastbackup}"
  304. echo -e "${blue} size:\t${default}${lastbackupsize}"
  305. } | column -s $'\t' -t
  306. fi
  307. }
  308. fn_info_message_commandlineparms(){
  309. #
  310. # Command-line Parameters
  311. # =====================================
  312. # ./run_server_x86.sh +set net_strict 1
  313. echo -e ""
  314. echo -e "${lightgreen}Command-line Parameters${default}"
  315. fn_info_message_password_strip
  316. fn_messages_separator
  317. echo -e "${executable} ${parms}"
  318. }
  319. fn_info_message_ports(){
  320. # Ports
  321. # =====================================
  322. # Change ports by editing the parameters in:
  323. # /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
  324. echo -e ""
  325. echo -e "${lightgreen}Ports${default}"
  326. fn_messages_separator
  327. echo -e "Change ports by editing the parameters in:"
  328. parmslocation="${red}UNKNOWN${default}"
  329. # engines/games that require editing in the config file
  330. local ports_edit_array=( "avalanche" "Ballistic Overkill" "dontstarve" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "Project Cars" "projectzomboid" "quake" "refractor" "realvirtuality" "renderware" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" )
  331. for port_edit in "${ports_edit_array[@]}"
  332. do
  333. if [ "${engine}" == "${port_edit}" ]||[ "${gamename}" == "${port_edit}" ]; then
  334. parmslocation="${servercfgfullpath}"
  335. fi
  336. done
  337. # engines/games that require editing in the script file
  338. local ports_edit_array=( "goldsource" "Factorio" "Hurtworld" "iw3.0" "Rust" "spark" "source" "starbound" "unreal4" "realvirtuality")
  339. for port_edit in "${ports_edit_array[@]}"
  340. do
  341. if [ "${engine}" == "${port_edit}" ]||[ "${gamename}" == "${port_edit}" ]; then
  342. parmslocation="${selfname}"
  343. fi
  344. done
  345. echo -e "${parmslocation}"
  346. echo -e ""
  347. echo -e "Useful port diagnostic command:"
  348. }
  349. fn_info_message_statusbottom(){
  350. echo -e ""
  351. if [ "${status}" == "0" ]; then
  352. echo -e "${blue}Status:\t${red}OFFLINE${default}"
  353. else
  354. echo -e "${blue}Status:\t${green}ONLINE${default}"
  355. fi
  356. echo -e ""
  357. }
  358. fn_info_logs(){
  359. echo -e ""
  360. echo -e "${servicename} Logs"
  361. echo -e "================================="
  362. if [ -n "${lgsmlog}" ]; then
  363. echo -e "\nScript log\n==================="
  364. if [ ! "$(ls -A ${lgsmlogdir})" ]; then
  365. echo "${lgsmlogdir} (NO LOG FILES)"
  366. elif [ ! -s "${lgsmlog}" ]; then
  367. echo "${lgsmlog} (LOG FILE IS EMPTY)"
  368. else
  369. echo "${lgsmlog}"
  370. tail -25 "${lgsmlog}"
  371. fi
  372. echo ""
  373. fi
  374. if [ -n "${consolelog}" ]; then
  375. echo -e "\nConsole log\n===================="
  376. if [ ! "$(ls -A ${consolelogdir})" ]; then
  377. echo "${consolelogdir} (NO LOG FILES)"
  378. elif [ ! -s "${consolelog}" ]; then
  379. echo "${consolelog} (LOG FILE IS EMPTY)"
  380. else
  381. echo "${consolelog}"
  382. tail -25 "${consolelog}" | awk '{ sub("\r$", ""); print }'
  383. fi
  384. echo ""
  385. fi
  386. if [ -n "${gamelogdir}" ]; then
  387. echo -e "\nServer log\n==================="
  388. if [ ! "$(ls -A ${gamelogdir})" ]; then
  389. echo "${gamelogdir} (NO LOG FILES)"
  390. else
  391. echo "${gamelogdir}"
  392. # dos2unix sed 's/\r//'
  393. tail "${gamelogdir}"/* 2>/dev/null | grep -v "==>" | sed '/^$/d' | sed 's/\r//'| tail -25
  394. fi
  395. echo ""
  396. fi
  397. }
  398. # Engine/Game Specific details
  399. fn_info_message_ark(){
  400. echo -e "netstat -atunp | grep ShooterGame"
  401. echo -e ""
  402. {
  403. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  404. echo -e "> Game\tINBOUND\t${port}\tudp"
  405. # Don't do arithmetics if ever the port wasn't a numeric value
  406. if [ "${port}" -eq "${port}" ]; then
  407. echo -e "> RAW\tINBOUND\t$((port+1))\tudp"
  408. fi
  409. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  410. echo -e "> RCON\tINBOUND\t${rconport}\ttcp"
  411. } | column -s $'\t' -t
  412. }
  413. fn_info_message_ballisticoverkill(){
  414. echo -e "netstat -atunp | grep BODS.x86"
  415. echo -e ""
  416. {
  417. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  418. echo -e "> Game/RCON\tINBOUND\t${port}\tudp"
  419. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  420. } | column -s $'\t' -t
  421. }
  422. fn_info_message_avalanche(){
  423. echo -e "netstat -atunp | grep Jcmp-Server"
  424. echo -e ""
  425. {
  426. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  427. echo -e "> Game\tINBOUND\t${port}\tudp"
  428. } | column -s $'\t' -t
  429. }
  430. fn_info_message_cod(){
  431. echo -e "netstat -atunp | grep cod_lnxded"
  432. echo -e ""
  433. {
  434. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  435. echo -e "> Game\tINBOUND\t${port}\tudp"
  436. } | column -s $'\t' -t
  437. }
  438. fn_info_message_coduo(){
  439. echo -e "netstat -atunp | grep coduo_lnxded"
  440. echo -e ""
  441. {
  442. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  443. echo -e "> Game\tINBOUND\t${port}\tudp"
  444. } | column -s $'\t' -t
  445. }
  446. fn_info_message_cod2(){
  447. echo -e "netstat -atunp | grep cod2_lnxded"
  448. echo -e ""
  449. {
  450. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  451. echo -e "> Game\tINBOUND\t${port}\tudp"
  452. } | column -s $'\t' -t
  453. }
  454. fn_info_message_cod4(){
  455. echo -e "netstat -atunp"
  456. echo -e ""
  457. {
  458. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  459. echo -e "> Game\tINBOUND\t${port}\tudp"
  460. } | column -s $'\t' -t
  461. }
  462. fn_info_message_codwaw(){
  463. echo -e "netstat -atunp | grep codwaw_lnxded"
  464. echo -e ""
  465. {
  466. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  467. echo -e "> Game\tINBOUND\t${port}\tudp"
  468. } | column -s $'\t' -t
  469. }
  470. fn_info_message_dontstarve(){
  471. echo -e "netstat -atunp | grep dontstarve"
  472. echo -e ""
  473. {
  474. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  475. echo -e "> Game: Server\tINBOUND\t${port}\tudp"
  476. echo -e "> Game: Master\tINBOUND\t${masterport}\tudp"
  477. echo -e "> Steam: Auth\tINBOUND\t${steamauthenticationport}\tudp"
  478. echo -e "> Steam: Master\tINBOUND\t${steammasterserverport}\tudp"
  479. } | column -s $'\t' -t
  480. }
  481. fn_info_message_factorio(){
  482. echo -e "netstat -atunp | grep factorio"
  483. echo -e ""
  484. {
  485. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  486. echo -e "> Game\tINBOUND\t${port}\ttcp"
  487. } | column -s $'\t' -t
  488. }
  489. fn_info_message_goldsource(){
  490. echo -e "netstat -atunp | grep hlds_linux"
  491. echo -e ""
  492. {
  493. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  494. echo -e "> Game/RCON\tINBOUND\t${port}\ttcp/udp"
  495. echo -e "< Client\tOUTBOUND\t${clientport}\tudp"
  496. } | column -s $'\t' -t
  497. }
  498. fn_info_message_hurtworld(){
  499. echo -e "netstat -atunp | grep Hurtworld"
  500. echo -e ""
  501. {
  502. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  503. echo -e "> Game/RCON\tINBOUND\t${port}\tudp"
  504. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  505. } | column -s $'\t' -t
  506. }
  507. fn_info_message_minecraft(){
  508. echo -e "netstat -atunp | grep java"
  509. echo -e ""
  510. {
  511. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  512. echo -e "> Game\tINBOUND\t${port}\tudp"
  513. } | column -s $'\t' -t
  514. }
  515. fn_info_message_mumble(){
  516. echo -e "netstat -atunp | grep murmur"
  517. echo -e ""
  518. {
  519. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  520. echo -e "> Voice\tINBOUND\t${port}\tudp"
  521. echo -e "> ServerQuery\tINBOUND\t${port}\ttcp"
  522. } | column -s $'\t' -t
  523. }
  524. fn_info_message_projectcars(){
  525. echo -e "netstat -atunp | grep DedicatedS"
  526. echo -e ""
  527. {
  528. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  529. echo -e "> Game\tINBOUND\t${port}\tudp"
  530. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  531. echo -e "> Steam\tINBOUND\t${steamport}\tudp"
  532. } | column -s $'\t' -t
  533. }
  534. fn_info_message_projectzomboid(){
  535. echo -e "netstat -atunp | grep java"
  536. echo -e ""
  537. {
  538. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  539. echo -e "> Game\tINBOUND\t${port}\tudp"
  540. } | column -s $'\t' -t
  541. }
  542. fn_info_message_quake(){
  543. echo -e "netstat -atunp | grep mvdsv"
  544. echo -e ""
  545. {
  546. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  547. echo -e "> Game\tINBOUND\t${port}\tudp"
  548. } | column -s $'\t' -t
  549. }
  550. fn_info_message_quake2(){
  551. echo -e "netstat -atunp | grep quake2"
  552. echo -e ""
  553. {
  554. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  555. echo -e "> Game\tINBOUND\t${port}\tudp"
  556. } | column -s $'\t' -t
  557. }
  558. fn_info_message_quake3(){
  559. echo -e "netstat -atunp | grep q3ded"
  560. echo -e ""
  561. {
  562. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  563. echo -e "> Game\tINBOUND\t${port}\tudp"
  564. } | column -s $'\t' -t
  565. }
  566. fn_info_message_quakelive(){
  567. echo -e "netstat -atunp | grep qzeroded"
  568. echo -e ""
  569. if [ -z "${port}" ]||[ -z "${rconport}" ]||[ -z "${statsport}" ]; then
  570. echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}."
  571. echo -e ""
  572. fi
  573. {
  574. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  575. echo -e "> Game\tINBOUND\t${port}\tudp"
  576. echo -e "> Rcon\tINBOUND\t${rconport}\tudp"
  577. echo -e "> Stats\tINBOUND\t${statsport}\tudp"
  578. } | column -s $'\t' -t
  579. }
  580. fn_info_message_realvirtuality(){
  581. echo -e "netstat -atunp | grep arma3server"
  582. echo -e ""
  583. # Default port
  584. if [ -z "${port}" ]; then
  585. port="2302"
  586. fi
  587. {
  588. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  589. echo -e "> Game\tINBOUND\t${port}\tudp"
  590. # Don't do arithmetics if ever the port wasn't a numeric value
  591. if [ "${port}" -eq "${port}" ]; then
  592. echo -e "> Steam: Query\tINBOUND\t$((port+1))\tudp"
  593. echo -e "> Steam: Master traffic\tINBOUND\t$((port+2))\tudp"
  594. echo -e "> Undocumented Port\tINBOUND\t$((port+3))\tudp"
  595. fi
  596. } | column -s $'\t' -t
  597. }
  598. fn_info_message_refractor(){
  599. echo -e "netstat -atunp | grep bf1942_lnxd"
  600. echo -e ""
  601. {
  602. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  603. echo -e "> Game/Query\tINBOUND\t${port}\tudp"
  604. echo -e "> Steam: Query\tINBOUND\t${queryport}\tudp"
  605. } | column -s $'\t' -t
  606. }
  607. fn_info_message_rust(){
  608. echo -e "netstat -atunp | grep Rust"
  609. echo -e ""
  610. {
  611. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  612. echo -e "> Game/Query\tINBOUND\t${port}\ttcp/udp"
  613. echo -e "> RCON\tINBOUND\t${rconport}\ttcp"
  614. } | column -s $'\t' -t
  615. }
  616. fn_info_message_seriousengine35(){
  617. echo -e "netstat -atunp | grep Sam3_Dedicate"
  618. echo -e ""
  619. {
  620. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  621. echo -e "> Game/RCON\tINBOUND\t${port}\ttcp"
  622. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  623. } | column -s $'\t' -t
  624. }
  625. fn_info_message_sdtd(){
  626. fn_info_message_password_strip
  627. echo -e "netstat -atunp | grep 7DaysToDie"
  628. echo -e ""
  629. {
  630. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  631. echo -e "> Game/RCON\tINBOUND\t${port}\tudp"
  632. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  633. echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp"
  634. echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp"
  635. } | column -s $'\t' -t
  636. echo -e ""
  637. echo -e "${lightgreen}${servername} WebAdmin${default}"
  638. fn_messages_separator
  639. {
  640. echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
  641. echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
  642. echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
  643. } | column -s $'\t' -t
  644. echo -e ""
  645. echo -e "${lightgreen}${servername} Telnet${default}"
  646. fn_messages_separator
  647. {
  648. echo -e "${blue}Telnet enabled:\t${default}${telnetenabled}"
  649. echo -e "${blue}Telnet address:\t${default}${ip} ${telnetport}"
  650. echo -e "${blue}Telnet password:\t${default}${telnetpass}"
  651. } | column -s $'\t' -t
  652. }
  653. fn_info_message_source(){
  654. echo -e "netstat -atunp | grep srcds_linux"
  655. echo -e ""
  656. {
  657. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  658. echo -e "> Game/RCON\tINBOUND\t${port}\ttcp/udp"
  659. echo -e "> SourceTV\tINBOUND\t${sourcetvport}\tudp"
  660. echo -e "< Client\tOUTBOUND\t${clientport}\tudp"
  661. } | column -s $'\t' -t
  662. }
  663. fn_info_message_spark(){
  664. fn_info_message_password_strip
  665. echo -e "netstat -atunp | grep server_linux3"
  666. echo -e ""
  667. {
  668. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  669. echo -e "> Game/RCON\tINBOUND\t${port}\tudp"
  670. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  671. echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp"
  672. } | column -s $'\t' -t
  673. echo -e ""
  674. echo -e "${lightgreen}${servername} WebAdmin${default}"
  675. fn_messages_separator
  676. {
  677. echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}/index.html"
  678. echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
  679. echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
  680. } | column -s $'\t' -t
  681. }
  682. fn_info_message_squad(){
  683. echo -e "netstat -atunp | grep SquadServer"
  684. echo -e ""
  685. {
  686. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  687. echo -e "> Game\tINBOUND\t${port}\tudp"
  688. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  689. echo -e "> RCON\tINBOUND\t${rconport}\ttcp"
  690. } | column -s $'\t' -t
  691. }
  692. fn_info_message_starbound(){
  693. echo -e "netstat -atunp | grep starbound"
  694. echo -e ""
  695. {
  696. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  697. echo -e "> Game\tINBOUND\t${port}\ttcp"
  698. echo -e "> Query\tINBOUND\t${queryport}\ttcp"
  699. echo -e "> Rcon\tINBOUND\t${rconport}\ttcp"
  700. } | column -s $'\t' -t
  701. }
  702. fn_info_message_teamspeak3(){
  703. echo -e "netstat -atunp | grep ts3server"
  704. echo -e ""
  705. {
  706. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  707. echo -e "> Voice\tINBOUND\t${port}\tudp"
  708. echo -e "> ServerQuery\tINBOUND\t${queryport}\ttcp"
  709. echo -e "> File transfer\tINBOUND\t${fileport}\ttcp"
  710. } | column -s $'\t' -t
  711. }
  712. fn_info_message_teeworlds(){
  713. echo -e "netstat -atunp | grep teeworlds_srv"
  714. echo -e ""
  715. {
  716. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  717. echo -e "> Game\tINBOUND\t${port}\ttcp"
  718. } | column -s $'\t' -t
  719. }
  720. fn_info_message_terraria(){
  721. echo -e "netstat -atunp | grep TerrariaServer"
  722. echo -e ""
  723. {
  724. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  725. echo -e "> Game\tINBOUND\t${port}\ttcp"
  726. } | column -s $'\t' -t
  727. }
  728. fn_info_message_towerunite(){
  729. echo -e "netstat -atunp | grep TowerServer"
  730. echo -e ""
  731. {
  732. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  733. echo -e "> Game\tINBOUND\t${port}\ttcp"
  734. # Don't do arithmetics if ever the port wasn't a numeric value
  735. if [ "${port}" -eq "${port}" ]; then
  736. echo -e "> Steam\tINBOUND\t$((port+1))\tudp"
  737. fi
  738. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  739. } | column -s $'\t' -t
  740. }
  741. fn_info_message_unreal(){
  742. fn_info_message_password_strip
  743. echo -e "netstat -atunp | grep ucc-bin"
  744. echo -e ""
  745. {
  746. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL\tINI VARIABLE"
  747. echo -e "> Game\tINBOUND\t${port}\tudp\tPort=${port}"
  748. echo -e "> Query\tINBOUND\t${queryport}\tudp"
  749. if [ "${engine}" == "unreal" ]; then
  750. echo -e "< UdpLink Port (random)\tOUTBOUND\t${udplinkport}+\tudp"
  751. fi
  752. if [ "${engine}" != "unreal" ] && [ "${appid}" != "223250" ]; then
  753. echo -e "> GameSpy query\tINBOUND\t${gsqueryport}\tudp\tOldQueryPortNumber=${gsqueryport}"
  754. fi
  755. if [ "${appid}" == "215360" ]; then
  756. echo -e "< Master server\tOUTBOUND\t28852\ttcp/udp"
  757. else
  758. echo -e "< Master server\tOUTBOUND\t28900/28902\ttcp/udp"
  759. fi
  760. if [ "${appid}" ]; then
  761. if [ "${appid}" == "223250" ]; then
  762. echo -e "< Steam\tOUTBOUND\t20610\tudp"
  763. else
  764. echo -e "< Steam\tOUTBOUND\t20660\tudp"
  765. fi
  766. fi
  767. echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}"
  768. } | column -s $'\t' -t
  769. echo -e ""
  770. echo -e "${lightgreen}${servername} WebAdmin${default}"
  771. fn_messages_separator
  772. {
  773. echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
  774. echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
  775. echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
  776. echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
  777. } | column -s $'\t' -t
  778. }
  779. fn_info_message_unreal3(){
  780. echo -e "netstat -atunp | grep ut3-bin"
  781. echo -e ""
  782. {
  783. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  784. echo -e "> Game/Query\tINBOUND\t${port}\ttcp/udp"
  785. echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}"
  786. } | column -s $'\t' -t
  787. echo -e ""
  788. echo -e "${lightgreen}${servername} WebAdmin${default}"
  789. fn_messages_separator
  790. {
  791. echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
  792. echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
  793. echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
  794. echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
  795. } | column -s $'\t' -t
  796. }
  797. fn_info_message_kf2(){
  798. echo -e "netstat -atunp | grep KFGame"
  799. echo -e ""
  800. {
  801. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  802. echo -e "> Game/Query\tINBOUND\t${port}\ttcp/udp"
  803. echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}"
  804. } | column -s $'\t' -t
  805. echo -e ""
  806. echo -e "${lightgreen}${servername} WebAdmin${default}"
  807. fn_messages_separator
  808. {
  809. echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
  810. echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
  811. echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
  812. echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
  813. } | column -s $'\t' -t
  814. }
  815. fn_info_message_wolfensteinenemyterritory(){
  816. echo -e "netstat -atunp | grep etded"
  817. echo -e ""
  818. {
  819. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  820. echo -e "> Game/Query\tINBOUND\t${port}\tudp"
  821. } | column -s $'\t' -t
  822. }
  823. fn_info_message_mta(){
  824. echo -e "netstat -atunp | grep mta-server64"
  825. echo -e ""
  826. {
  827. echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
  828. echo -e "> Game\tOUTBOUND\t${port}\tudp"
  829. echo -e "> HTTP Server\tINBOUND\t${httpport}\ttcp"
  830. if [ "${ase}" == "Enabled" ]; then
  831. echo -e "> ASE Game_Monitor\tOUTBOUND\t$((${port} + 123))\tudp"
  832. fi
  833. } | column -s $'\t' -t
  834. }
  835. fn_info_message_select_engine(){
  836. # Display details depending on game or engine.
  837. if [ "${gamename}" == "7 Days To Die" ]; then
  838. fn_info_message_sdtd
  839. elif [ "${gamename}" == "ARK: Survival Evolved" ]; then
  840. fn_info_message_ark
  841. elif [ "${gamename}" == "Ballistic Overkill" ]; then
  842. fn_info_message_ballisticoverkill
  843. elif [ "${gamename}" == "Call of Duty" ]; then
  844. fn_info_message_cod
  845. elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
  846. fn_info_message_coduo
  847. elif [ "${gamename}" == "Call of Duty 2" ]; then
  848. fn_info_message_cod2
  849. elif [ "${gamename}" == "Call of Duty 4" ]; then
  850. fn_info_message_cod4
  851. elif [ "${gamename}" == "Call of Duty: World at War" ]; then
  852. fn_info_message_codwaw
  853. elif [ "${gamename}" == "Factorio" ]; then
  854. fn_info_message_factorio
  855. elif [ "${gamename}" == "Hurtworld" ]; then
  856. fn_info_message_hurtworld
  857. elif [ "${shortname}" == "kf2" ]; then
  858. fn_info_message_kf2
  859. elif [ "${gamename}" == "Project Cars" ]; then
  860. fn_info_message_projectcars
  861. elif [ "${gamename}" == "QuakeWorld" ]; then
  862. fn_info_message_quake
  863. elif [ "${gamename}" == "Quake 2" ]; then
  864. fn_info_message_quake2
  865. elif [ "${gamename}" == "Quake 3: Arena" ]; then
  866. fn_info_message_quake3
  867. elif [ "${gamename}" == "Quake Live" ]; then
  868. fn_info_message_quakelive
  869. elif [ "${gamename}" == "Squad" ]; then
  870. fn_info_message_squad
  871. elif [ "${gamename}" == "TeamSpeak 3" ]; then
  872. fn_info_message_teamspeak3
  873. elif [ "${gamename}" == "Tower Unite" ]; then
  874. fn_info_message_towerunite
  875. elif [ "${gamename}" == "Multi Theft Auto" ]; then
  876. fn_info_message_mta
  877. elif [ "${gamename}" == "Mumble" ]; then
  878. fn_info_message_mumble
  879. elif [ "${gamename}" == "Rust" ]; then
  880. fn_info_message_rust
  881. elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
  882. fn_info_message_wolfensteinenemyterritory
  883. elif [ "${engine}" == "avalanche" ]; then
  884. fn_info_message_avalanche
  885. elif [ "${engine}" == "refractor" ]; then
  886. fn_info_message_refractor
  887. elif [ "${engine}" == "dontstarve" ]; then
  888. fn_info_message_dontstarve
  889. elif [ "${engine}" == "goldsource" ]; then
  890. fn_info_message_goldsource
  891. elif [ "${engine}" == "lwjgl2" ]; then
  892. fn_info_message_minecraft
  893. elif [ "${engine}" == "projectzomboid" ]; then
  894. fn_info_message_projectzomboid
  895. elif [ "${engine}" == "realvirtuality" ]; then
  896. fn_info_message_realvirtuality
  897. elif [ "${engine}" == "seriousengine35" ]; then
  898. fn_info_message_seriousengine35
  899. elif [ "${engine}" == "source" ]; then
  900. fn_info_message_source
  901. elif [ "${engine}" == "spark" ]; then
  902. fn_info_message_spark
  903. elif [ "${engine}" == "starbound" ]; then
  904. fn_info_message_starbound
  905. elif [ "${engine}" == "teeworlds" ]; then
  906. fn_info_message_teeworlds
  907. elif [ "${engine}" == "terraria" ]; then
  908. fn_info_message_terraria
  909. elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
  910. fn_info_message_unreal
  911. elif [ "${engine}" == "unreal3" ]; then
  912. fn_info_message_unreal3
  913. else
  914. fn_print_error_nl "Unable to detect server engine."
  915. fi
  916. }
  917. # Separator is different for details
  918. fn_messages_separator(){
  919. if [ "${function_selfname}" == "command_details.sh" ]; then
  920. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  921. else
  922. echo -e "================================="
  923. fi
  924. }
  925. # Removes the passwords form all but details
  926. fn_info_message_password_strip(){
  927. if [ "${function_selfname}" != "command_details.sh" ]; then
  928. if [ -n "${serverpassword}" ]; then
  929. serverpassword="********"
  930. fi
  931. if [ -n "${rconpassword}" ]; then
  932. rconpassword="********"
  933. fi
  934. if [ -n "${adminpassword}" ]; then
  935. adminpassword="********"
  936. fi
  937. if [ -n "${statspassword}" ]; then
  938. statspassword="********"
  939. fi
  940. if [ -n "${webadminpass}" ]; then
  941. webadminpass="********"
  942. fi
  943. if [ -n "${telnetpass}" ]; then
  944. telnetpass="********"
  945. fi
  946. fi
  947. }