info_messages.sh 31 KB

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