fn_details 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. #!/bin/bash
  2. # LGSM fn_details function
  3. # Author: Daniel Gibbs
  4. # Website: http://danielgibbs.co.uk
  5. # Version: 080214
  6. # Description: Displays server infomation.
  7. # Standard Details
  8. # This applies to all engines
  9. fn_details_os(){
  10. echo -e ""
  11. echo -e "\e[93mDistro Details\e[0m"
  12. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  13. echo -e "\e[34mDistro:£\e[0m${os}" >> .fn_details_distro
  14. echo -e "\e[34mArch:£\e[0m${arch}" >> .fn_details_distro
  15. echo -e "\e[34mKernel:£\e[0m${kernel}" >> .fn_details_distro
  16. echo -e "\e[34mHostname:£\e[0m$HOSTNAME" >> .fn_details_distro
  17. echo -e "\e[34mtmux:£\e[0m${tmuxv}" >> .fn_details_distro
  18. echo -e "\e[34mGLIBC:£\e[0m${glibcv}" >> .fn_details_distro
  19. column -s '£' -t .fn_details_distro
  20. rm -f .fn_details_distro
  21. }
  22. fn_details_performance(){
  23. echo -e ""
  24. echo -e "\e[93mPerformance\e[0m"
  25. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  26. echo -e "\e[34mUptime:£\e[0m${days}d, ${hours}h, ${minutes}m" >> .fn_details_performance
  27. echo -e "\e[34mAvg Load:£\e[0m${load}" >> .fn_details_performance
  28. column -s '£' -t .fn_details_performance
  29. rm -f .fn_details_performance
  30. echo -e ""
  31. echo -e "\e[34mMem:£\e[34mtotal£ used£ free\e[0m" >> .fn_details_performance
  32. echo -e "\e[34mPhysical:£\e[0m${physmemtotal}£${physmemused}£${physmemfree}\e[0m" >> .fn_details_performance
  33. echo -e "\e[34mSwap:£\e[0m${swaptotal}£${swapused}£${swapfree}\e[0m" >> .fn_details_performance
  34. column -s '£' -t .fn_details_performance
  35. rm -f .fn_details_performance
  36. }
  37. fn_details_disk(){
  38. echo -e ""
  39. echo -e "\e[93mDisk Usage\e[0m"
  40. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  41. echo -e "\e[34mDisk available:£\e[0m${availspace}" >> .fn_details_disk
  42. echo -e "\e[34mServerfiles:£\e[0m${serverfilesdu}" >> .fn_details_disk
  43. if [ -d "${backupdir}" ]; then
  44. echo -e "\e[34mBackups:£\e[0m${backupdirdu}" >> .fn_details_disk
  45. fi
  46. column -s '£' -t .fn_details_disk
  47. rm -f .fn_details_disk
  48. }
  49. fn_details_gameserver(){
  50. if [ ! -e ${servercfgfullpath} ]; then
  51. servername="\e[0;31mCONFIG FILE MISSING!\e[0m"
  52. rcon="\e[0;31mCONFIG FILE MISSING!\e[0m"
  53. servercfgfullpath="${servercfgfullpath} \e[0;31mCONFIG FILE MISSING!!\e[0m"
  54. fi
  55. echo -e ""
  56. echo -e "\e[92m${gamename} Server Details\e[0m"
  57. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  58. echo -e "\e[34mServer name:£\e[0m${servername}" >> .fn_details_gameserver
  59. echo -e "\e[34mServer IP:£\e[0m${ip}:${port}" >> .fn_details_gameserver
  60. if [ ! -z "${rcon}" ]; then
  61. echo -e "\e[34mRCON password:£\e[0m${rcon}" >> .fn_details_gameserver
  62. fi
  63. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  64. if [ "${pid}" == "0" ]; then
  65. echo -e "\e[34mStatus:£\e[0;31mOFFLINE\e[0m" >> .fn_details_gameserver
  66. else
  67. echo -e "\e[34mStatus:£\e[0;32mONLINE\e[0m" >> .fn_details_gameserver
  68. fi
  69. column -s '£' -t .fn_details_gameserver
  70. rm -f .fn_details_gameserver
  71. echo -e ""
  72. echo -e "\e[34mService name:£\e[0m${servicename}" >> .fn_details_gameserver
  73. echo -e "\e[34mUser:£\e[0m$(whoami)" >> .fn_details_gameserver
  74. echo -e "\e[34mLocation:£\e[0m${rootdir}" >> .fn_details_gameserver
  75. if [ ! -z "${servercfgfullpath}" ]; then
  76. echo -e "\e[34mConfig file:£\e[0m${servercfgfullpath}" >> .fn_details_gameserver
  77. fi
  78. if [ "${gamename}" == "Teamspeak 3" ]; then
  79. echo -e "\e[34mdbplugin:£\e[0m${dbplugin}" >> .fn_details_gameserver
  80. fi
  81. column -s '£' -t .fn_details_gameserver
  82. rm -f .fn_details_gameserver
  83. }
  84. fn_details_backup(){
  85. echo -e ""
  86. echo -e "\e[92mBackups\e[0m"
  87. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  88. if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
  89. echo -e "No Backups created"
  90. else
  91. echo -e "\e[34mNo. of backups:£\e[0m${backupcount}" >> .fn_details_backup
  92. echo -e "\e[34mLatest backup:\e[0m" >> .fn_details_backup
  93. echo -e "\e[34m date:£\e[0m${lastbackupdate}" >> .fn_details_backup
  94. echo -e "\e[34m file:£\e[0m${lastbackup}" >> .fn_details_backup
  95. echo -e "\e[34m size:£\e[0m${lastbackupsize}" >> .fn_details_backup
  96. column -s '£' -t .fn_details_backup
  97. rm -f .fn_details_backup
  98. fi
  99. }
  100. fn_details_commandlineparms(){
  101. echo -e ""
  102. echo -e "\e[92mCommand-line Parameters\e[0m"
  103. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  104. echo -e "${executable} ${parms}"
  105. }
  106. fn_details_statusbottom(){
  107. echo -e ""
  108. if [ "${pid}" == "0" ]; then
  109. echo -e "\e[34mStatus: \e[0;31mOFFLINE\e[0m"
  110. else
  111. echo -e "\e[34mStatus: \e[0;32mONLINE\e[0m"
  112. fi
  113. echo -e ""
  114. }
  115. # Engine Specific details
  116. fn_details_avalanche(){
  117. fn_check_ip
  118. fn_details_config
  119. fn_details_distro
  120. fn_details_os
  121. fn_details_performance
  122. fn_details_disk
  123. fn_details_gameserver
  124. fn_details_backup
  125. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  126. echo -e ""
  127. echo -e "\e[92mPorts\e[0m"
  128. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  129. echo -e "Change ports by editing the command-line"
  130. echo -e "parameters in ${selfname}."
  131. echo -e ""
  132. echo -e "Useful port diagnostic command:"
  133. echo -e "netstat -atunp | grep Jcmp-Server"
  134. echo -e ""
  135. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  136. echo -e "> Game/RCON£INBOUND£${port}£udp" >> .fn_details_ports
  137. column -s '£' -t .fn_details_ports
  138. rm -f .fn_details_ports
  139. fn_details_statusbottom
  140. }
  141. fn_details_realvirtuality(){
  142. fn_check_ip
  143. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  144. fn_parms
  145. fn_details_config
  146. fn_details_distro
  147. fn_details_os
  148. fn_details_performance
  149. fn_details_disk
  150. fn_details_gameserver
  151. fn_details_backup
  152. fn_details_commandlineparms
  153. echo -e ""
  154. echo -e "\e[92mPorts\e[0m"
  155. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  156. echo -e "Change ports by editing the parameters in"
  157. echo -e "${servercfgfullpath}."
  158. echo -e ""
  159. echo -e "Useful port diagnostic command:"
  160. echo -e "netstat -atunp | grep arma3server"
  161. echo -e ""
  162. if [ -z ${port} ] || [ -z ${queryport} ] || [ -z ${masterport} ] ; then
  163. echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}."
  164. echo -e ""
  165. fi
  166. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  167. echo -e "> Game£INBOUND£${port}£udp" >> .fn_details_ports
  168. echo -e "> Steam: Query£INBOUND£${queryport}£udp" >> .fn_details_ports
  169. echo -e "> Steam: Master traffic£INBOUND£${masterport}£udp" >> .fn_details_ports
  170. column -s '£' -t .fn_details_ports
  171. rm -f .fn_details_ports
  172. fn_details_statusbottom
  173. }
  174. fn_details_seriousengine35(){
  175. fn_check_ip
  176. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  177. fn_parms
  178. fn_details_config
  179. fn_details_distro
  180. fn_details_os
  181. fn_details_performance
  182. fn_details_disk
  183. fn_details_gameserver
  184. fn_details_backup
  185. fn_details_commandlineparms
  186. echo -e ""
  187. echo -e "\e[92mPorts\e[0m"
  188. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  189. echo -e "Change ports by editing the parameters in"
  190. echo -e "${servercfgfullpath}."
  191. echo -e ""
  192. echo -e "Useful port diagnostic command:"
  193. echo -e "netstat -atunp | grep Sam3_Dedicate"
  194. echo -e ""
  195. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  196. echo -e "> Game/RCON£INBOUND£${port}£tcp" >> .fn_details_ports
  197. echo -e "> Query£INBOUND£${queryport}£udp" >> .fn_details_ports
  198. column -s '£' -t .fn_details_ports
  199. rm -f .fn_details_ports
  200. fn_details_statusbottom
  201. }
  202. fn_details_source(){
  203. fn_check_ip
  204. fn_parms
  205. fn_details_config
  206. fn_details_distro
  207. fn_details_os
  208. fn_details_performance
  209. fn_details_disk
  210. fn_details_gameserver
  211. fn_details_backup
  212. fn_details_commandlineparms
  213. echo -e ""
  214. echo -e "\e[92mPorts\e[0m"
  215. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  216. echo -e "Change ports by editing the command-line"
  217. echo -e "parameters in ${selfname}."
  218. echo -e ""
  219. echo -e "Useful port diagnostic command:"
  220. echo -e "netstat -atunp | grep srcds_linux"
  221. echo -e ""
  222. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  223. echo -e "> Game/RCON£INBOUND£${port}£tcp/udp" >> .fn_details_ports
  224. if [ ! -z "${sourcetvport}" ]; then
  225. echo -e "> SourceTV£INBOUND£${sourcetvport}£udp" >> .fn_details_ports
  226. fi
  227. echo -e "< Client£OUTBOUND£${clientport}£udp" >> .fn_details_ports
  228. column -s '£' -t .fn_details_ports
  229. rm -f .fn_details_ports
  230. fn_details_statusbottom
  231. }
  232. fn_details_spark(){
  233. fn_check_ip
  234. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  235. fn_parms
  236. fn_details_config
  237. fn_details_distro
  238. fn_details_os
  239. fn_details_performance
  240. fn_details_disk
  241. fn_details_gameserver
  242. fn_details_backup
  243. fn_details_commandlineparms
  244. echo -e ""
  245. echo -e "\e[92mPorts\e[0m"
  246. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  247. echo -e "Change ports by editing the command-line"
  248. echo -e "parameters in ${selfname}."
  249. echo -e ""
  250. echo -e "Useful port diagnostic command:"
  251. echo -e "netstat -atunp | grep server_linux3"
  252. echo -e ""
  253. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  254. echo -e "> Game/RCON£INBOUND£${port}£udp" >> .fn_details_ports
  255. echo -e "> Query£INBOUND£${queryport}£udp" >> .fn_details_ports
  256. echo -e "> WebAdmin£INBOUND£${webadminport}£tcp" >> .fn_details_ports
  257. column -s '£' -t .fn_details_ports
  258. rm -f .fn_details_ports
  259. echo -e ""
  260. echo -e "\e[92m${servername} WebAdmin\e[0m"
  261. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  262. echo -e "\e[34mWebAdmin url:£\e[0mhttp://${ip}:${webadminport}/index.html" >> .fn_details_ports
  263. echo -e "\e[34mWebAdmin username:£\e[0m${webadminuser}" >> .fn_details_ports
  264. echo -e "\e[34mWebAdmin password:£\e[0m${webadminpass}" >> .fn_details_ports
  265. column -s '£' -t .fn_details_ports
  266. rm -f .fn_details_ports
  267. fn_details_statusbottom
  268. }
  269. fn_details_teamspeak3(){
  270. fn_details_config
  271. fn_details_distro
  272. fn_details_os
  273. fn_details_performance
  274. fn_details_disk
  275. fn_details_gameserver
  276. fn_details_backup
  277. fn_details_commandlineparms
  278. echo -e ""
  279. echo -e "\e[92mPorts\e[0m"
  280. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  281. echo -e "Change ports by editing the command-line"
  282. echo -e "parameters in ${selfname}."
  283. echo -e ""
  284. echo -e "Useful port diagnostic command:"
  285. echo -e "netstat -atunp | grep ts3server"
  286. echo -e ""
  287. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  288. echo -e "> Voice£INBOUND£${port}£udp" >> .fn_details_ports
  289. echo -e "> ServerQuery£INBOUND£${queryport}£tcp" >> .fn_details_ports
  290. echo -e "> File transfer£INBOUND£${fileport}£tcp" >> .fn_details_ports
  291. column -s '£' -t .fn_details_ports
  292. rm -f .fn_details_ports
  293. fn_details_statusbottom
  294. }
  295. fn_details_unity3d(){
  296. fn_check_ip
  297. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  298. fn_parms
  299. fn_details_config
  300. fn_details_distro
  301. fn_details_os
  302. fn_details_performance
  303. fn_details_disk
  304. fn_details_gameserver
  305. fn_details_backup
  306. fn_details_commandlineparms
  307. echo -e ""
  308. echo -e "\e[92mPorts\e[0m"
  309. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  310. echo -e "Change ports by editing the parameters in"
  311. echo -e "${servercfgfullpath}."
  312. echo -e ""
  313. echo -e "Useful port diagnostic command:"
  314. echo -e "netstat -atunp | grep 7DaysToDie"
  315. echo -e ""
  316. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL" >> .fn_details_ports
  317. echo -e "> Game/RCON£INBOUND£${port}£udp" >> .fn_details_ports
  318. echo -e "> Query£INBOUND£${queryport}£udp" >> .fn_details_ports
  319. echo -e "> WebAdmin£INBOUND£${webadminport}£tcp" >> .fn_details_ports
  320. echo -e "> Telnet£INBOUND£${telnetport}£tcp" >> .fn_details_ports
  321. column -s '£' -t .fn_details_ports
  322. rm -f .fn_details_ports
  323. echo -e ""
  324. echo -e "\e[92m${servername} WebAdmin\e[0m"
  325. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  326. echo -e "\e[34mWebAdmin enabled:£\e[0m${webadminenabled}" >> .fn_details_ports
  327. echo -e "\e[34mWebAdmin url:£\e[0mhttp://${ip}:${webadminport}" >> .fn_details_ports
  328. echo -e "\e[34mWebAdmin password:£\e[0m${webadminpass}" >> .fn_details_ports
  329. column -s '£' -t .fn_details_ports
  330. rm -f .fn_details_ports
  331. echo -e ""
  332. echo -e "\e[92m${servername} Telnet\e[0m"
  333. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  334. echo -e "\e[34mTelnet enabled:£\e[0m${telnetenabled}" >> .fn_details_ports
  335. echo -e "\e[34mTelnet address:£\e[0m${ip}:${telnetport}" >> .fn_details_ports
  336. echo -e "\e[34mTelnet password:£\e[0m${telnetpass}" >> .fn_details_ports
  337. column -s '£' -t .fn_details_ports
  338. rm -f .fn_details_ports
  339. fn_details_statusbottom
  340. }
  341. fn_details_unreal(){
  342. fn_check_ip
  343. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
  344. fn_parms
  345. fn_details_config
  346. fn_details_distro
  347. fn_details_os
  348. fn_details_performance
  349. fn_details_disk
  350. fn_details_gameserver
  351. fn_details_backup
  352. fn_details_commandlineparms
  353. echo -e ""
  354. echo -e "\e[92mPorts\e[0m"
  355. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  356. echo -e "Change ports by editing the parameters in"
  357. echo -e "${servercfgfullpath}."
  358. echo -e ""
  359. echo -e "Useful port diagnostic command:"
  360. echo -e "netstat -atunp | grep ucc-bin"
  361. echo -e ""
  362. echo -e "DESCRIPTION£DIRECTION£PORT£PROTOCOL£INI VARIABLE" >> .fn_details_ports
  363. echo -e "> Game£INBOUND£${port}£udp£Port=${port}" >> .fn_details_ports
  364. echo -e "> Query£INBOUND£${queryport}£udp" >> .fn_details_ports
  365. if [ "${engine}" == "unreal" ]; then
  366. echo -e "< UdpLink Port (random)£OUTBOUND£${udplinkport}+£udp" >> .fn_details_ports
  367. fi
  368. if [ "${engine}" != "unreal" ] && [ "${appid}" != "223250" ]; then
  369. echo -e "> GameSpy query£INBOUND£${gsqueryport}£udp£OldQueryPortNumber=${gsqueryport}" >> .fn_details_ports
  370. fi
  371. if [ "${appid}" == "215360" ]; then
  372. echo -e "< Master server£OUTBOUND£28852£tcp/udp" >> .fn_details_ports
  373. else
  374. echo -e "< Master server£OUTBOUND£28900/28902£tcp/udp" >> .fn_details_ports
  375. fi
  376. if [ "${appid}" ]; then
  377. if [ "${appid}" == "223250" ]; then
  378. echo -e "< Steam£OUTBOUND£20610£udp" >> .fn_details_ports
  379. else
  380. echo -e "< Steam£OUTBOUND£20660£udp" >> .fn_details_ports
  381. fi
  382. fi
  383. echo -e "> WebAdmin£INBOUND£${webadminport}£tcp£ListenPort=${webadminport}" >> .fn_details_ports
  384. column -s '£' -t .fn_details_ports
  385. rm -f .fn_details_ports
  386. echo -e ""
  387. echo -e "\e[92m${servername} WebAdmin\e[0m"
  388. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
  389. echo -e "\e[34mWebAdmin enabled:£\e[0m${webadminenabled}" >> .fn_details_ports
  390. echo -e "\e[34mWebAdmin url:£\e[0mhttp://${ip}:${webadminport}" >> .fn_details_ports
  391. echo -e "\e[34mWebAdmin user:£\e[0m${webadminuser}" >> .fn_details_ports
  392. echo -e "\e[34mWebAdmin password:£\e[0m${webadminpass}" >> .fn_details_ports
  393. column -s '£' -t .fn_details_ports
  394. rm -f .fn_details_ports
  395. fn_details_statusbottom
  396. }
  397. if [ "${engine}" == "avalanche" ]; then
  398. fn_details_avalanche
  399. elif [ "${engine}" == "realvirtuality" ]; then
  400. fn_details_realvirtuality
  401. elif [ "${engine}" == "seriousengine35" ]; then
  402. fn_details_seriousengine35
  403. elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  404. fn_details_source
  405. elif [ "${engine}" == "spark" ]; then
  406. fn_details_spark
  407. elif [ "${engine}" == "unity3d" ]; then
  408. fn_details_unity3d
  409. elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
  410. fn_details_unreal
  411. elif [ "${gamename}" == "Teamspeak 3" ]; then
  412. fn_details_teamspeak3
  413. else
  414. fn_printerrornl "Unable to detect server engine."
  415. fi