info_messages.sh 28 KB

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