info_messages.sh 30 KB

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