info_messages.sh 28 KB

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