Quellcode durchsuchen

Merge remote-tracking branch 'dgibbs64/master'

Alexander Hurd vor 9 Jahren
Ursprung
Commit
95473c1472
90 geänderte Dateien mit 2421 neuen und 1974 gelöschten Zeilen
  1. 1 1
      CounterStrikeGlobalOffensive/csgoserver
  2. 7 2
      NoMoreRoomInHell/nmrihserver
  3. 14 8
      README.md
  4. 2 2
      Rust/rustserver
  5. 0 141
      StarBound/cfg/sbboot.config
  6. 49 0
      Starbound/cfg/lgsm-default.config
  7. 6 5
      Starbound/sbserver
  8. 4 4
      functions/command_update_functions.sh
  9. 3 3
      functions/core_functions.sh
  10. 15 14
      lgsm/functions/alert.sh
  11. 10 10
      lgsm/functions/alert_email.sh
  12. 6 6
      lgsm/functions/alert_pushbullet.sh
  13. 14 5
      lgsm/functions/check.sh
  14. 28 6
      lgsm/functions/check_config.sh
  15. 26 21
      lgsm/functions/check_deps.sh
  16. 14 8
      lgsm/functions/check_glibc.sh
  17. 11 5
      lgsm/functions/check_ip.sh
  18. 5 4
      lgsm/functions/check_logs.sh
  19. 31 71
      lgsm/functions/check_permissions.sh
  20. 5 3
      lgsm/functions/check_root.sh
  21. 4 3
      lgsm/functions/check_status.sh
  22. 10 10
      lgsm/functions/check_steamcmd.sh
  23. 5 3
      lgsm/functions/check_system_dir.sh
  24. 28 0
      lgsm/functions/check_system_requirements.sh
  25. 5 4
      lgsm/functions/check_tmux.sh
  26. 19 11
      lgsm/functions/command_backup.sh
  27. 14 11
      lgsm/functions/command_console.sh
  28. 30 9
      lgsm/functions/command_debug.sh
  29. 90 83
      lgsm/functions/command_details.sh
  30. 12 8
      lgsm/functions/command_dev_debug.sh
  31. 4 5
      lgsm/functions/command_dev_detect_deps.sh
  32. 33 34
      lgsm/functions/command_fastdl.sh
  33. 8 8
      lgsm/functions/command_install.sh
  34. 27 28
      lgsm/functions/command_monitor.sh
  35. 14 0
      lgsm/functions/command_restart.sh
  36. 31 33
      lgsm/functions/command_start.sh
  37. 75 78
      lgsm/functions/command_stop.sh
  38. 7 5
      lgsm/functions/command_test_alert.sh
  39. 9 9
      lgsm/functions/command_ts3_server_pass.sh
  40. 22 0
      lgsm/functions/command_update.sh
  41. 36 13
      lgsm/functions/command_update_functions.sh
  42. 25 16
      lgsm/functions/command_validate.sh
  43. 4 2
      lgsm/functions/compress_unreal2_maps.sh
  44. 4 2
      lgsm/functions/compress_ut99_maps.sh
  45. 39 20
      lgsm/functions/core_dl.sh
  46. 38 0
      lgsm/functions/core_exit.sh
  47. 29 19
      lgsm/functions/core_functions.sh
  48. 152 130
      lgsm/functions/core_getopt.sh
  49. 211 84
      lgsm/functions/core_messages.sh
  50. 13 0
      lgsm/functions/core_trap.sh
  51. 8 6
      lgsm/functions/fix.sh
  52. 5 1
      lgsm/functions/fix_arma3.sh
  53. 4 2
      lgsm/functions/fix_csgo.sh
  54. 4 2
      lgsm/functions/fix_dst.sh
  55. 4 2
      lgsm/functions/fix_glibc.sh
  56. 7 6
      lgsm/functions/fix_ins.sh
  57. 5 1
      lgsm/functions/fix_kf.sh
  58. 4 2
      lgsm/functions/fix_ro.sh
  59. 4 2
      lgsm/functions/fix_steamcmd.sh
  60. 4 2
      lgsm/functions/fix_ut2k4.sh
  61. 6 1
      lgsm/functions/fix_ut99.sh
  62. 1 1
      lgsm/functions/fn_functions
  63. 1 1
      lgsm/functions/fn_getopt
  64. 3 4
      lgsm/functions/fn_update_functions
  65. 2 2
      lgsm/functions/gsquery.py
  66. 85 5
      lgsm/functions/info_config.sh
  67. 54 33
      lgsm/functions/info_distro.sh
  68. 2 2
      lgsm/functions/info_glibc.sh
  69. 4 30
      lgsm/functions/info_parms.sh
  70. 5 3
      lgsm/functions/install_complete.sh
  71. 30 2
      lgsm/functions/install_config.sh
  72. 8 8
      lgsm/functions/install_gslt.sh
  73. 0 30
      lgsm/functions/install_gsquery.sh
  74. 3 2
      lgsm/functions/install_header.sh
  75. 4 3
      lgsm/functions/install_logs.sh
  76. 3 2
      lgsm/functions/install_retry.sh
  77. 4 3
      lgsm/functions/install_server_dir.sh
  78. 13 11
      lgsm/functions/install_server_files.sh
  79. 2 3
      lgsm/functions/install_steamcmd.sh
  80. 0 81
      lgsm/functions/install_ts3.sh
  81. 4 3
      lgsm/functions/install_ts3db.sh
  82. 4 3
      lgsm/functions/install_ut2k4_key.sh
  83. 5 7
      lgsm/functions/logs.sh
  84. 14 13
      lgsm/functions/monitor_gsquery.sh
  85. 0 342
      lgsm/functions/update_check.sh
  86. 0 85
      lgsm/functions/update_dl.sh
  87. 238 0
      lgsm/functions/update_steamcmd.sh
  88. 196 0
      lgsm/functions/update_ts3.sh
  89. 232 166
      tests/tests_jc2server.sh
  90. 200 155
      tests/tests_ts3server.sh

+ 1 - 1
CounterStrikeGlobalOffensive/csgoserver

@@ -37,8 +37,8 @@ steampass=""
 # Classic Competitive        0            1
 # Demolition                 1            1
 # Deathmatch                 1            2
-gamemode="0"
 gametype="0"
+gamemode="0"
 defaultmap="de_dust2"
 mapgroup="random_classic"
 maxplayers="16"

+ 7 - 2
NoMoreRoomInHell/nmrihserver

@@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then
 	set -x
 fi
 
-version="210516"
+version="130716"
 
 #### Variables ####
 
@@ -38,9 +38,14 @@ clientport="27005"
 ip="0.0.0.0"
 updateonstart="off"
 
+# Optional: Game Server Login Token
+# GSLT can be used for running a public server.
+# More info: https://gameservermanagers.com/gslt
+gslt=""
+
 # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
 fn_parms(){
-parms="-game nmrih -insecure -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+parms="-game nmrih -insecure -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +sv_setsteamaccount ${gslt} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
 }
 
 #### Advanced Variables ####

+ 14 - 8
README.md

@@ -43,12 +43,18 @@ If you want to donate to the project you can via PayPal, Flattr or Gratipay. I h
 </ul>
 <h2>Useful Links</h2>
 <ul>
-	<li><a href="https://gameservermanagers.com">Homepage</li>
-	<li><a href="https://github.com/dgibbs64/linuxgsm/wiki">Wiki</li>
-	<li><a href="https://github.com/dgibbs64/linuxgsm">GitHub Code</li>
-	<li><a href="https://github.com/dgibbs64/linuxgsm/issues">GitHub Issues</li>
-	<li><a href="http://steamcommunity.com/groups/linuxgsm">Steam Group</li>
-	<li><a href="https://twitter.com/dangibbsuk">Twitter</li>
-	<li><a href="https://www.facebook.com/linuxgsm">Facebook</li>
-	<li><a href="https://plus.google.com/+Gameservermanagers1">Google+</li>
+	<li><a href="https://gameservermanagers.com">Homepage</a></li>
+	<li><a href="https://github.com/dgibbs64/linuxgsm/wiki">Wiki</a></li>
+	<li><a href="https://github.com/dgibbs64/linuxgsm">GitHub Code</a></li>
+	<li><a href="https://github.com/dgibbs64/linuxgsm/issues">GitHub Issues</a></li>
+	<li><a href="https://waffle.io/dgibbs64/linuxgsm">Waffle (Github Dashboard)</a></li>
+	<li><a href="http://alternativeto.net/software/linux-game-server-managers/">alternativeTo.net</a></li>
 </ul>
+<h2>Social</h2>
+<ul>
+	<li><a href="http://steamcommunity.com/groups/linuxgsm">Steam Group</a></li>
+	<li><a href="https://discord.gg/0i9cmXVacvXicNl7">Discord</a></li>
+	<li><a href="https://twitter.com/dangibbsuk">Twitter</a></li>
+	<li><a href="https://www.facebook.com/linuxgsm">Facebook</a></li>
+	<li><a href="https://plus.google.com/+Gameservermanagers1">Google+</a></li>
+<ul>

+ 2 - 2
Rust/rustserver

@@ -41,8 +41,8 @@ rconpassword="CHANGE_ME"
 maxplayers="50"
 
 # Advanced
-seed="" #  default random; range : -2147483647 to 2147483647 ; used to change or reproduce a procedural map
-worldsize="4000" # default 4000; range : 2000 to 8000 ; map size in meters
+seed="" #  default random; range : 1 to 2147483647 ; used to change or reproduce a procedural map
+worldsize="3000" # default 3000; range : 1000 to 6000 ; map size in meters
 saveinterval="300" # Auto-save in seconds
 tickrate="30" # default 30; range : 15 to 100
 

+ 0 - 141
StarBound/cfg/sbboot.config

@@ -1,141 +0,0 @@
-{
-  "handleFatalSignals" : true,
-  "handleInterruptSignal" : true,
-  "rootMaintenanceSleep" : 5000,
-  "logFileBackups" : 5,
-  "assetSources" : [
-    "../assets/packed.pak",
-    "../assets/user"
-  ],
-  "modSource" : "../giraffe_storage/mods/",
-  "storageDirectory" : "../giraffe_storage/",
-  "defaultConfiguration" : {
-    "gameServerPort" : 21025,
-    "gameServerBind" : "*",
-
-    "serverUsers" : {},
-    "allowAnonymousConnections" : true,
-
-    "bannedUuids" : [],
-    "bannedIPs" : [],
-
-    "serverName" : "A Starbound Server",
-    "maxPlayers" : 8,
-    "upnpPortForwarding" : true,
-
-    "checkAssetsDigest" : false,
-
-    "allowAdminCommands" : true,
-    "allowAdminCommandsFromAnyone" : false,
-    "anonymousConnectionsAreAdmin" : false,
-
-    "runQueryServer" : false,
-    "queryServerPort" : 21025,
-    "queryServerBind" : "*",
-
-    "runRconServer" : false,
-    "rconServerPort" : 21026,
-    "rconServerBind" : "*",
-    "rconServerPassword" : "",
-    "rconServerTimeout" : 1000,
-
-    "windowTitle" : "Starbound - Beta",
-    "vsync" : true,
-    "renderSleep" : true,
-    "maxFrameSkip" : 10,
-    "sampleRate" : 44100,
-    "audioChannels" : 2,
-    "audioChannelSeparation" : [-25, 25],
-
-    "clearUniverseFiles" : false,
-    "clearPlayerFiles" : false,
-    "playerBackupFileCount" : 3,
-
-    "sfxVol" : 100,
-    "musicVol" : 100,
-    "windowedResolution" : [1000, 600],
-    "maximizedResolution" : [1000, 600],
-    "fullscreenResolution" : [1920, 1080],
-    "fullscreen" : false,
-    "maximized" : true,
-    "zoomLevel" : 3.0,
-    "speechBubbles" : true,
-
-    "crafting.filterHaveMaterials" : false,
-    "title.connectionString" : "",
-
-    "bindings" : {
-      "PlayerUp" :  [ { "type" : "key", "value" : "W", "mods" : [] } ],
-      "PlayerDown" :  [ { "type" : "key", "value" : "S", "mods" : [] } ],
-      "PlayerLeft" :  [ { "type" : "key", "value" : "A", "mods" : [] } ],
-      "PlayerRight" :  [ { "type" : "key", "value" : "D", "mods" : [] } ],
-      "PlayerJump" :  [ { "type" : "key", "value" : "Space", "mods" : [] } ],
-      "PlayerDropItem" :  [ { "type" : "key", "value" : "Q", "mods" : [] } ],
-      "PlayerInteract" :  [ { "type" : "key", "value" : "E", "mods" : [] } ],
-      "PlayerShifting" :  [ { "type" : "key", "value" : "RShift", "mods" : [] },                                                                                                                           { "type" : "key", "value" : "LShift", "mods" : [] } ],
-      "PlayerTechAction1" :  [ { "type" : "key", "value" : "F", "mods" : [] } ],
-      "PlayerTechAction2" :  [ { "type" : "key", "value" : "G", "mods" : [] } ],
-      "PlayerTechAction3" :  [ { "type" : "key", "value" : "H", "mods" : [] } ],
-      "EmoteBlabbering" :  [ { "type" : "key", "value" : "Right", "mods" : ["LCt                                                                                                                          rl", "LShift"] } ],
-      "EmoteShouting" :  [ { "type" : "key", "value" : "Up", "mods" : ["LCtrl",                                                                                                                           "LAlt"] } ],
-      "EmoteHappy" :  [ { "type" : "key", "value" : "Up", "mods" : [] } ],
-      "EmoteSad" :  [ { "type" : "key", "value" : "Down", "mods" : [] } ],
-      "EmoteNeutral" :  [ { "type" : "key", "value" : "Left", "mods" : [] } ],
-      "EmoteLaugh" :  [ { "type" : "key", "value" : "Left", "mods" : [ "LCtrl" ]                                                                                                                           } ],
-      "EmoteAnnoyed" :  [ { "type" : "key", "value" : "Right", "mods" : [] } ],
-      "EmoteOh" :  [ { "type" : "key", "value" : "Right", "mods" : [ "LCtrl" ] }                                                                                                                           ],
-      "EmoteOooh" :  [ { "type" : "key", "value" : "Down", "mods" : [ "LCtrl" ]                                                                                                                           } ],
-      "EmoteBlink" :  [ { "type" : "key", "value" : "Up", "mods" : [ "LCtrl" ] }                                                                                                                           ],
-      "EmoteWink" :  [ { "type" : "key", "value" : "Up", "mods" : ["LCtrl", "LSh                                                                                                                          ift"] } ],
-      "EmoteEat" :  [ { "type" : "key", "value" : "Down", "mods" : ["LCtrl", "LS                                                                                                                          hift"] } ],
-      "EmoteSleep" :  [ { "type" : "key", "value" : "Left", "mods" : ["LCtrl", "                                                                                                                          LShift"] } ],
-      "ShowLabels" :  [ { "type" : "key", "value" : "RAlt", "mods" : [] }, { "ty                                                                                                                          pe" : "key", "value" : "LAlt", "mods" : [] } ],
-      "CameraShift" :  [ { "type" : "key", "value" : "RCtrl", "mods" : [] }, { "                                                                                                                          type" : "key", "value" : "LCtrl", "mods" : [] } ],
-      "CockpitUp" :  [ { "type" : "key", "value" : "W", "mods" : [] }, { "type"                                                                                                                           : "key", "value" : "Up", "mods" : [] } ],
-      "CockpitDown" :  [ { "type" : "key", "value" : "S", "mods" : [] }, { "type                                                                                                                          " : "key", "value" : "Down", "mods" : [] } ],
-      "CockpitLeft" :  [ { "type" : "key", "value" : "Left", "mods" : [] }, { "t                                                                                                                          ype" : "key", "value" : "A", "mods" : [] } ],
-      "CockpitRight" :  [ { "type" : "key", "value" : "Right", "mods" : [] }, {                                                                                                                           "type" : "key", "value" : "D", "mods" : [] } ],
-      "TitleBack" :  [ { "type" : "key", "value" : "Esc", "mods" : [] } ],
-      "CinematicSkip" :  [ { "type" : "key", "value" : "Esc", "mods" : [] } ],
-      "CinematicNext" :  [ { "type" : "key", "value" : "Right", "mods" : [] }, {                                                                                                                           "type" : "key", "value" : "Return", "mods" : [] } ],
-      "GuiClose" :  [ { "type" : "key", "value" : "Esc", "mods" : [] } ],
-      "GuiShifting" :  [ { "type" : "key", "value" : "RShift", "mods" : [] }, {                                                                                                                           "type" : "key", "value" : "LShift", "mods" : [] } ],
-      "KeybindingCancel" :  [ { "type" : "key", "value" : "Esc", "mods" : [] } ]                                                                                                                          ,
-      "KeybindingClear" :  [ { "type" : "key", "value" : "Del", "mods" : [] }, {                                                                                                                           "type" : "key", "value" : "Backspace", "mods" : [] } ],
-      "ChatPageUp" :  [ { "type" : "key", "value" : "PageUp", "mods" : [] } ],
-      "ChatPageDown" :  [ { "type" : "key", "value" : "PageDown", "mods" : [] }                                                                                                                           ],
-      "ChatPreviousLine" :  [ { "type" : "key", "value" : "Up", "mods" : [] } ],
-      "ChatNextLine" :  [ { "type" : "key", "value" : "Down", "mods" : [] } ],
-      "ChatSendLine" :  [ { "type" : "key", "value" : "Return", "mods" : [] } ],
-      "ChatBegin" :  [ { "type" : "key", "value" : "Return", "mods" : [] } ],
-      "ChatBeginCommand" :  [ { "type" : "key", "value" : "/", "mods" : [] } ],
-      "ChatStop" :  [ { "type" : "key", "value" : "Esc", "mods" : [] } ],
-      "InterfaceShowHelp" :  [ { "type" : "key", "value" : "F1", "mods" : [] } ]                                                                                                                          ,
-      "InterfaceHideHud" :  [ { "type" : "key", "value" : "Z", "mods" : [ "LAlt"                                                                                                                           ] } ],
-      "InterfaceSwapHands" :  [ { "type" : "key", "value" : "Z", "mods" : [] } ]                                                                                                                          ,
-      "InterfaceDeselectHands" :  [ { "type" : "key", "value" : "X", "mods" : []                                                                                                                           } ],
-      "InterfaceBar1" :  [ { "type" : "key", "value" : "1", "mods" : [] } ],
-      "InterfaceBar2" :  [ { "type" : "key", "value" : "2", "mods" : [] } ],
-      "InterfaceBar3" :  [ { "type" : "key", "value" : "3", "mods" : [] } ],
-      "InterfaceBar4" :  [ { "type" : "key", "value" : "4", "mods" : [] } ],
-      "InterfaceBar5" :  [ { "type" : "key", "value" : "5", "mods" : [] } ],
-      "InterfaceBar6" :  [ { "type" : "key", "value" : "6", "mods" : [] } ],
-      "InterfaceBar7" :  [ { "type" : "key", "value" : "7", "mods" : [] } ],
-      "InterfaceBar8" :  [ { "type" : "key", "value" : "8", "mods" : [] } ],
-      "InterfaceBar9" :  [ { "type" : "key", "value" : "9", "mods" : [] } ],
-      "InterfaceBar10" :  [ { "type" : "key", "value" : "0", "mods" : [] } ],
-      "EssentialBar1" :  [ { "type" : "key", "value" : "R", "mods" : [] } ],
-      "EssentialBar2" :  [ { "type" : "key", "value" : "T", "mods" : [] } ],
-      "EssentialBar3" :  [ { "type" : "key", "value" : "Y", "mods" : [] } ],
-      "InterfaceBarNPos" :  [ { "type" : "key", "value" : "-", "mods" : [] }, {                                                                                                                           "type" : "key", "value" : "`", "mods" : [] } ],
-      "InterfaceRepeatCommand" :  [ { "type" : "key", "value" : "P", "mods" : []                                                                                                                           } ],
-      "InterfaceToggleFullscreen" :  [ { "type" : "key", "value" : "F11", "mods"                                                                                                                           : [] } ],
-      "InterfaceEscapeMenu" :  [ { "type" : "key", "value" : "Esc", "mods" : []                                                                                                                           } ],
-      "InterfaceInventory" :  [ { "type" : "key", "value" : "I", "mods" : [] } ]                                                                                                                          ,
-      "InterfaceCodex" :  [ { "type" : "key", "value" : "L", "mods" : [] } ],
-      "InterfaceQuest" :  [ { "type" : "key", "value" : "J", "mods" : [] } ],
-      "InterfaceCrafting" :  [ { "type" : "key", "value" : "C", "mods" : [] } ],
-      "InterfaceInspectCursor" :  [ { "type" : "key", "value" : "N", "mods" : []                                                                                                                           } ]
-    }
-  }
-}

+ 49 - 0
Starbound/cfg/lgsm-default.config

@@ -0,0 +1,49 @@
+{
+  "allowAdminCommands" : true,
+  "allowAdminCommandsFromAnyone" : false,
+  "allowAnonymousConnections" : true,
+  "allowAssetsMismatch" : true,
+  "anonymousConnectionsAreAdmin" : false,
+  "bannedIPs" : [],
+  "bannedUuids" : [],
+  "checkAssetsDigest" : false,
+  "clearPlayerFiles" : false,
+  "clearUniverseFiles" : false,
+  "clientIPJoinable" : false,
+  "clientP2PJoinable" : true,
+  "configurationVersion" : {
+    "basic" : 1,
+    "server" : 4
+  },
+  "crafting" : {
+    "filterHaveMaterials" : false
+  },
+  "gameServerBind" : "::",
+  "gameServerPort" : 21025,
+  "interactiveHighlight" : true,
+  "inventory" : {
+    "pickupToActionBar" : true
+  },
+  "maxPlayers" : 8,
+  "maxTeamSize" : 4,
+  "playerBackupFileCount" : 3,
+  "queryServerBind" : "::",
+  "queryServerPort" : 21025,
+  "rconServerBind" : "::",
+  "rconServerPassword" : "<rconpassword>",
+  "rconServerPort" : 21026,
+  "rconServerTimeout" : 1000,
+  "runQueryServer" : false,
+  "runRconServer" : false,
+  "safeScripts" : true,
+  "scriptInstructionLimit" : 10000000,
+  "scriptInstructionMeasureInterval" : 10000,
+  "scriptProfilingEnabled" : false,
+  "scriptRecursionLimit" : 100,
+  "serverFidelity" : "automatic",
+  "serverName" : "<hostname>",
+  "serverOverrideAssetsDigest" : null,
+  "serverUsers" : {
+  },
+  "tutorialMessages" : true
+}

+ 6 - 5
StarBound/sbserver → Starbound/sbserver

@@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then
 	set -x
 fi
 
-version="210516"
+version="230716"
 
 #### Variables ####
 
@@ -62,16 +62,17 @@ lgsmdir="${rootdir}/lgsm"
 functionsdir="${lgsmdir}/functions"
 filesdir="${rootdir}/serverfiles"
 systemdir="${filesdir}"
-executabledir="${filesdir}/linux64"
+executabledir="${filesdir}/linux"
 executable="./starbound_server"
-servercfg="sbboot.config"
-servercfgdir="${executabledir}"
+servercfg="starbound_server.config"
+servercfgdir="${filesdir}/storage"
 servercfgfullpath="${servercfgdir}/${servercfg}"
+servercfgdefault="${servercfgdir}/lgsm-default.config"
 backupdir="${rootdir}/backups"
 
 # Logging
 logdays="7"
-gamelogdir="${filesdir}/giraffe_storage"
+gamelogdir="${filesdir}/storage"
 scriptlogdir="${rootdir}/log/script"
 consolelogdir="${rootdir}/log/console"
 consolelogging="on"

+ 4 - 4
functions/command_update_functions.sh

@@ -6,10 +6,10 @@ lgsm_version="210516"
 
 # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
 
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 check.sh
 fn_print_dots "Updating functions"
-fn_scriptlog "Updating functions"
+fn_script_log "Updating functions"
 sleep 1
 echo -ne "\n"
 
@@ -30,9 +30,9 @@ fi
 
 if [ "${exitcode}" == "0" ]; then
 	fn_print_ok "Updating functions"
-	fn_scriptlog "Success! Updating functions"
+	fn_script_log "Success! Updating functions"
 else
 	fn_print_fail "Updating functions"
-	fn_scriptlog "Failure! Updating functions"
+	fn_script_log "Failure! Updating functions"
 fi
 echo -ne "\n"

+ 3 - 3
functions/core_functions.sh

@@ -46,15 +46,15 @@ if [ ! -f "${filedir}/${filename}" ]; then
 	if [ "$(basename ${curlcmd})" == "curl" ]; then
 		curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
 		if [ $? -ne 0 ]; then
-			echo -e "\e[0;31mFAIL\e[0m\n"
+			echo -e "${red}FAIL${default}\n"
 			echo "${curlfetch}"
 			echo -e "${githuburl}\n"
 			exit 1
 		else
-			echo -e "\e[0;32mOK\e[0m"
+			echo -e "${green}OK${default}"
 		fi
 	else
-		echo -e "\e[0;31mFAIL\e[0m\n"
+		echo -e "${red}FAIL${default}\n"
 		echo "Curl is not installed!"
 		echo -e ""
 		exit 1

+ 15 - 14
lgsm/functions/alert.sh

@@ -2,30 +2,31 @@
 # LGSM alert.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Overall function for managing alerts.
 
+local commandname="ALERT"
+local commandaction="Alert"
+
 fn_alert_test(){
-	fn_scriptlog "Sending test alert"
+	fn_script_log_info "Sending test alert"
 	alertsubject="LGSM - Test Alert - ${servername}"
 	alertbody="LGSM test alert, how you read?"
 }
 
 fn_alert_restart(){
-	fn_scriptlog "Sending restart alert: ${executable} process not running"
+	fn_script_log_info "Sending restart alert: ${executable} process not running"
 	alertsubject="LGSM - Restarted - ${servername}"
 	alertbody="${servicename} ${executable} process not running"
 }
 
 fn_alert_restart_query(){
-	fn_scriptlog "Sending restart alert: ${gsquerycmd}"
+	fn_script_log_info "Sending restart alert: ${gsquerycmd}"
 	alertsubject="LGSM - Restarted - ${servername}"
 	alertbody="gsquery.py failed to query: ${gsquerycmd}"
 }
 
 fn_alert_update(){
-	fn_scriptlog "Sending update alert"
+	fn_script_log_info "Sending update alert"
 	alertsubject="LGSM - Updated - ${servername}"
 	alertbody="${servicename} recieved update"
 }
@@ -43,19 +44,19 @@ fi
 if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
 	alert_email.sh
 elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
-	fn_print_info_nl "Email alerts not enabled"
-	fn_scriptlog "Email alerts not enabled"
+	fn_print_warn_nl "Email alerts not enabled"
+	fn_script_log_warn "Email alerts not enabled"
 elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
-	fn_print_fail_nl "Email not set"
-	fn_scriptlog "Email not set"
+	fn_print_error_nl "Email not set"
+	fn_script_log_error "Email not set"
 fi
 
 if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then
 	alert_pushbullet.sh
 elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
-	fn_print_info_nl "Pushbullet alerts not enabled"
-	fn_scriptlog "Pushbullet alerts not enabled"
+	fn_print_warn_nl "Pushbullet alerts not enabled"
+	fn_script_log_warn "Pushbullet alerts not enabled"
 elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
-	fn_print_fail_nl "Pushbullet token not set"
-	fn_scriptlog "Pushbullet token not set"
+	fn_print_error_nl "Pushbullet token not set"
+	fn_script_error_warn "Pushbullet token not set"
 fi

+ 10 - 10
lgsm/functions/alert_email.sh

@@ -1,13 +1,12 @@
 #!/bin/bash
-# LGSM email.sh function
+# LGSM alert_email.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Sends email alert if monitor picks up a failure.
 
-local modulename="Alert"
-
+local commandname="ALERT"
+local commandaction="Alert"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_details_email(){
 	#
@@ -214,7 +213,8 @@ fn_alert_email_template_logs(){
 	} | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1
 }
 
-fn_print_dots "Sending alert to ${email}"
+fn_print_dots "Sending alert: ${email}"
+fn_script_log_info "Sending alert: ${email}"
 info_distro.sh
 info_config.sh
 info_glibc.sh
@@ -233,9 +233,9 @@ fn_alert_email_template_logs
 mail -s "${alertsubject}" "${email}" < "${emaillog}"
 exitcode=$?
 if [ "${exitcode}" == "0" ]; then
-	fn_print_ok_nl "Sending alert to ${email}"
-	fn_scriptlog "Success! Sending alert to ${email}"
+	fn_print_ok_nl "Sending alert: ${email}"
+	fn_script_log_pass "Sending alert: ${email}"
 else
-	fn_print_fail_nl "Sending alert to ${email}"
-	fn_scriptlog "Failure! Sending alert to ${email}"
+	fn_print_fail_nl "Sending alert: ${email}"
+	fn_script_log_fatal "Sending alert: ${email}"
 fi

+ 6 - 6
lgsm/functions/alert_pushbullet.sh

@@ -2,12 +2,12 @@
 # LGSM alert_pushbullet.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: alerts using pushbullet.
 
-local modulename="Alert"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="ALERT"
+local commandaction="Alert"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 fn_print_dots "Sending Pushbullet alert"
 sleep 1
 
@@ -15,8 +15,8 @@ pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d bo
 
 if [ "${pushbulletsend}" == "invalid_access_token" ]; then
 	fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token"
-	fn_scriptlog "Failure! Sending Pushbullet alert: invalid_access_token"
+	fn_script_log_fatal "Sending Pushbullet alert: invalid_access_token"
 else
 	fn_print_ok_nl "Sending Pushbullet alert"
-	fn_scriptlog "Complete! Sent Pushbullet alert"
+	fn_script_log_pass "Sent Pushbullet alert"
 fi

+ 14 - 5
lgsm/functions/check.sh

@@ -1,12 +1,13 @@
 #!/bin/bash
-# LGSM fn_check function
+# LGSM check.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
 # Description: Overall function for managing checks.
 # Runs checks that will either halt on or fix an issue.
 
+local commandname="CHECK"
+
 # Every command that requires checks just references check.sh
 # check.sh selects which checks to run by using arrays
 
@@ -49,7 +50,7 @@ do
 	fi
 done
 
-local allowed_commands_array=( update_check.sh command_debug.sh command_start.sh command_validate.sh )
+local allowed_commands_array=( update_steamcmd.sh command_debug.sh command_start.sh command_validate.sh )
 for allowed_command in "${allowed_commands_array[@]}"
 do
 	if [ "${allowed_command}" == "${function_selfname}" ]; then
@@ -62,7 +63,7 @@ done
 local allowed_commands_array=( command_console.sh command_start.sh )
 for allowed_command in "${allowed_commands_array[@]}"
 do
-	if [ "${allowed_command}" == "${function_selfname}" ]; then
+	if [ "${allowed_command}" == "${function_selfname}" ]||[ "${gamename}" != "Teamspeak 3" ]; then
 		check_tmux.sh
 	fi
 done
@@ -75,10 +76,18 @@ do
 	fi
 done
 
-local allowed_commands_array=( command_details.sh command_monitor.sh command_start.sh command_stop.sh command_ts3_server_pass.sh update_check.sh command_details.sh command_validate.sh )
+local allowed_commands_array=( command_details.sh command_monitor.sh command_start.sh command_stop.sh command_ts3_server_pass.sh command_update.sh command_details.sh command_validate.sh )
 for allowed_command in "${allowed_commands_array[@]}"
 do
 	if [ "${allowed_command}" == "${function_selfname}" ]; then
 		check_status.sh
 	fi
 done
+
+local allowed_commands_array=( command_install.sh command_start.sh command_debug.sh )
+for allowed_command in "${allowed_commands_array[@]}"
+do
+	if [ "${allowed_command}" == "${function_selfname}" ]; then
+		check_system_requirements.sh
+	fi
+done

+ 28 - 6
lgsm/functions/check_config.sh

@@ -2,16 +2,38 @@
 # LGSM check_config.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: If server config missing warn user.
 
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 if [ ! -e "${servercfgfullpath}" ]; then
 	if [ "${gamename}" != "Hurtworld" ]; then
-		fn_print_warn_nl "Config file missing!"
+		fn_print_dots ""
+		sleep 0.5
+		fn_print_warn_nl "Configuration file missing!"
 		echo "${servercfgfullpath}"
-		fn_scriptlog "Configuration file missing!"
-		fn_scriptlog "${servercfgfullpath}"
+		fn_script_log_warn "Configuration file missing!"
+		fn_script_log_warn "${servercfgfullpath}"
+		sleep 2
+	fi
+fi
+
+if [ "${gamename}" == "Rust" ]; then
+	if  [ -z "${rconpassword}" ]; then
+		fn_print_dots ""
+		sleep 0.5
+		fn_print_fail_nl "RCON password is not set!"
+		echo "  * Not setting an RCON password causes issues with ${gamename}"
+		fn_script_log_fatal "RCON password is not set"
+		fn_script_log_fatal "Not setting an RCON password causes issues with ${gamename}"
+		core_exit.sh
+	elif [ "${rconpassword}" == "CHANGE_ME" ]; then
+		fn_print_dots ""
+		sleep 0.5
+		fn_print_warn_nl "Default RCON Password detected!"
+		echo " * Having ${rconpassword} as a password is not very safe."
+		fn_script_log_warn "Default RCON Password detected"
 		sleep 2
 	fi
-fi
+fi

+ 26 - 21
lgsm/functions/check_deps.sh

@@ -2,10 +2,9 @@
 # LGSM check_deps.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="090616"
-
 # Description: Checks that the requires dependencies are installed for LGSM.
 
+local commandname="CHECK"
 
 fn_deps_detector(){
 	# Checks if dependency is missing
@@ -19,14 +18,14 @@ fn_deps_detector(){
 	if [ "${depstatus}" == "0" ]; then
 		missingdep=0
 		if [ "${function_selfname}" == "command_install.sh" ]; then
-			echo -e "\e[0;32m${deptocheck}\e[0m"
+			echo -e "${green}${deptocheck}${default}"
 			sleep 0.5
 		fi
 	else
 		# if missing dependency is found
 		missingdep=1
 		if [ "${function_selfname}" == "command_install.sh" ]; then
-			echo -e "\e[0;31m${deptocheck}\e[0m"
+			echo -e "${red}${deptocheck}${default}"
 			sleep 0.5
 		fi
 	fi
@@ -63,14 +62,14 @@ fn_deps_email(){
 fn_found_missing_deps(){
 	if [ "${#array_deps_missing[@]}" != "0" ]; then
 		fn_print_dots "Checking dependencies"
-		sleep 2
-		fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m"
-		fn_scriptlog "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m"
+		sleep 0.5
+		fn_print_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}"
+		fn_script_log_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}"
 		sleep 1
-		echo -e ""
-		sudo -n true > /dev/null 2>&1
+		sudo -v > /dev/null 2>&1
 		if [ $? -eq 0 ]; then
-			fn_print_info_nl "Attempting to install missing dependencies automatically"
+			fn_print_infomation_nl "Automatically installing missing dependencies."
+			fn_script_log_info "Automatically installing missing dependencies."
 			echo -en ".\r"
 			sleep 1
 			echo -en "..\r"
@@ -80,20 +79,26 @@ fn_found_missing_deps(){
 			echo -en "   \r"
 			if [ -n "$(command -v dpkg-query)" ]; then
 				cmd="sudo dpkg --add-architecture i386; sudo apt-get -y install ${array_deps_missing[@]}"
-				eval $cmd
+				eval ${cmd}
 			elif [ -n "$(command -v yum)" ]; then
 				cmd="sudo yum -y install ${array_deps_missing[@]}"
-				eval $cmd
+				eval ${cmd}
+			fi
+			if [ $? != 0 ]; then
+				fn_print_failure_nl "Unable to install dependencies"
+				fn_script_log_fail "Unable to install dependencies"
+			else
+				fn_print_complete_nl "Install dependencies completed"
+				fn_script_log_pass "Install dependencies completed"
 			fi
 		else
 			echo ""
-			fn_print_infomation_nl "$(whoami) does not have sudo access. Please manually install dependencies"
-			fn_scriptlog "$(whoami) does not have sudo access. Please manually install dependencies"
-			echo ""
+			fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies."
+			fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies."
 			if [ -n "$(command -v dpkg-query)" ]; then
-				echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}"
+				echo "	sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}"
 			elif [ -n "$(command -v yum)" ]; then
-				echo "sudo yum install ${array_deps_missing[@]}"
+				echo "	sudo yum install ${array_deps_missing[@]}"
 			fi
 			echo ""
 		fi
@@ -127,8 +132,8 @@ if [ -n "$(command -v dpkg-query)" ]; then
 	# Generate array of missing deps
 	array_deps_missing=()
 
-	# LGSM requirement for curl
-	array_deps_required=( curl ca-certificates file bsdmainutils python )
+	# LGSM requirements
+	array_deps_required=( curl ca-certificates file bsdmainutils util-linux python )
 
 	# All servers except ts3 require tmux
 	if [ "${executable}" != "./ts3server_startscript.sh" ]; then
@@ -177,7 +182,7 @@ elif [ -n "$(command -v yum)" ]; then
 	# Generate array of missing deps
 	array_deps_missing=()
 
-	# LGSM requirement for curl
+	# LGSM requirements
 	array_deps_required=( curl util-linux python file )
 
 	# All servers except ts3 require tmux
@@ -218,4 +223,4 @@ elif [ -n "$(command -v yum)" ]; then
 	fi
 	fn_deps_email
 	fn_check_loop
-fi
+fi

+ 14 - 8
lgsm/functions/check_glibc.sh

@@ -2,32 +2,38 @@
 # LGSM check_glibc.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Checks if server has correct glibc or has a fix available.
 
+local commandname="CHECK"
+
 info_glibc.sh
 info_distro.sh
 
 if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
 	:
 elif [ "${glibcrequired}" == "UNKNOWN" ]; then
-		fn_print_info_nl "Glibc fix: \e[0;31m${glibcrequired}\e[0m"
-		echo -e "	* glibc required: \e[0;31m${glibcrequired}\e[0m"
+		fn_print_dots "Glibc fix"
+		sleep 0.5
+		fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}"
+		echo -e "	* glibc required: ${red}${glibcrequired}${default}"
 		echo -e "	* glibc installed: ${glibcversion}"
 elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
 	if [ "${glibcfix}" == "yes" ]; then
 		if [ "${function_selfname}" != "command_install.sh" ]; then
-			fn_print_info_nl "Glibc fix: \e[0;32mUsing Glibc fix\e[0m"
-			echo -e "	* glibc required: \e[0;31m${glibcrequired}\e[0m"
+			fn_print_dots "Glibc fix"
+			sleep 0.5
+			fn_print_info_nl "Glibc fix: ${green}Using Glibc fix${default}"
+			echo -e "	* glibc required: ${red}${glibcrequired}${default}"
 			echo -e "	* glibc installed: ${glibcversion}"
 			fix_glibc.sh
 		fi
 	else
-		fn_print_warn_nl "Glibc fix: \e[0;31mNo Glibc fix available!\e[0m"
+		fn_print_dots "Glibc fix"
+		sleep 0.5
+		fn_print_error_nl "Glibc fix: ${red}No Glibc fix available!${default}"
 		echo -en "\n"
 		echo -e "	* glibc required: ${glibcrequired}"
-		echo -e "	* glibc installed: \e[0;31m${glibcversion}\e[0m"
+		echo -e "	* glibc installed: ${red}${glibcversion}${default}"
 		echo -en "\n"
 		fn_print_infomation "The game server will probably not work. A distro upgrade is required!"
 		sleep 5

+ 11 - 5
lgsm/functions/check_ip.sh

@@ -2,11 +2,12 @@
 # LGSM check_ip.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Automatically identifies the server interface IP.
 # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0".
 
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 if [ "${gamename}" != "Teamspeak 3" ]; then
 	if [ ! -f "/bin/ip" ]; then
 		ipcommand="/sbin/ip"
@@ -18,14 +19,19 @@ if [ "${gamename}" != "Teamspeak 3" ]; then
 
 	if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
 		if [ "${getipwc}" -ge "2" ]; then
-			fn_print_warn "Multiple active network interfaces found.\n\n"
-			echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
+			fn_print_dots ""
+			sleep 0.5
+			fn_print_fail "Multiple active network interfaces found.\n\n"
+			fn_print_infomation "Specify the IP you want to use within the ${selfname} script.\n"
 			echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
 			echo -en "${getip}\n"
 			echo -en ""
 			echo -en "https://gameservermanagers.com/network-interfaces\n"
 			echo -en ""
-			exit 1
+			fn_script_log_fatal "Multiple active network interfaces found."
+			fn_script_log_fatal "Manually specify the IP you want to use within the ${selfname} script."
+			fn_script_log_fatal "https://gameservermanagers.com/network-interfaces\n"
+			core_exit.sh
 		else
 			ip=${getip}
 		fi

+ 5 - 4
lgsm/functions/check_logs.sh

@@ -2,14 +2,15 @@
 # LGSM check_logs.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Checks that log files exist on server start
 
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 # Create dir's for the script and console logs
-if [ ! -d "${scriptlogdir}" ]; then
+if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${gamename}" != "Teamspeak 3" ]; then
 	fn_print_dots "Checking for log files"
-	sleep 1
+	sleep 0.5
 	fn_print_info_nl "Checking for log files: Creating log files"
 	checklogs=1
 	install_logs.sh

+ 31 - 71
lgsm/functions/check_permissions.sh

@@ -3,53 +3,40 @@
 # Author: Daniel Gibbs
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Checks script, files and folders ownership and permissions.
 
-# Useful variables
-currentuser="$(whoami)"
-currentgroups="$(groups)"
-scriptfullpath="${rootdir}/${selfname}"
-conclusionpermissionerror="0"
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_check_ownership(){
-	# Check script ownership
-	if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then
-		fn_print_fail_nl "Oops ! Ownership issue..."
-		echo "	* Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\""
-		echo "	* To check the owner and allowed groups, run ls -l \"${selfname}\""
-		exit 1
-	fi
-
-	# Check rootdir ownership
-	if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then
-		fn_print_fail_nl "Oops ! Ownership issue..."
-		echo "	* Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${rootdir}\""
-		echo "	* To check the owner and allowed groups, run ls -dl \"${rootdir}\""
-		exit 1
+	if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]||[ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then
+		fn_print_fail_nl "Permissions issues found"
+		fn_script_log_fatal "Permissions issues found"
+		fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:"
+		fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:"
+		{
+			echo -e "User\tGroup\tFile\n"
+			find "${filesdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n"
+		} | column -s $'\t' -t | tee -a "${scriptlog}"
+		core_exit.sh
 	fi
+}
 
-	# Check functions ownership
-	funownfail="0"
+fn_check_permissions(){
 	if [ -n "${functionsdir}" ]; then
-		while read -r filename
-			do
-				if [ ! -O "${filename}" ] && [ ! -G "${filename}" ]; then
-					funownfail="1"
-					conclusionpermissionerror="1"
-				fi
-		done <<< "$(find "${functionsdir}" -name "*.sh")"
-
-		if [ "${funownfail}" == "1" ]; then
-			fn_print_fail_nl "Oops ! Ownership issue..."
-			echo "	* Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own all scripts in \"${functionsdir}\""
-			echo "	* To check the owner and allowed groups, run ls -l \"${functionsdir}\""
+		if [ $(find "${functionsdir}" -type f -not -executable|wc -l) -ne "0" ]; then
+			fn_print_fail_nl "Permissions issues found"
+			fn_script_log_fatal "Permissions issues found"
+			fn_print_infomation_nl "The following files are not executable:"
+			fn_script_log_info "The following files are not executable:"
+			{
+				echo -e "File\n"
+				find "${functionsdir}" -type f -not -executable -printf "%p\n"
+			} | column -s $'\t' -t | tee -a "${scriptlog}"
+			core_exit.sh
 		fi
 	fi
-}
 
-fn_check_permissions(){
 	# Check rootdir permissions
 	if [ -n "${rootdir}" ]; then
 		# Get permission numbers on folder under the form 775
@@ -58,42 +45,15 @@ fn_check_permissions(){
 		userrootdirperm="${rootdirperm:0:1}"
 		grouprootdirperm="${rootdirperm:1:1}"
 		if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
-			fn_print_fail_nl "Oops ! Permission issue..."
-			echo "	* Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control of \"${rootdir}\""
-			echo "	* You might wanna run : chmod -R 770 \"${rootdir}\""
-			conclusionpermissionerror="1"
+			fn_print_fail_nl "Permissions issues found"
+			fn_script_log_fatal "Permissions issues found"
+			fn_print_infomation_nl "The following directorys does not have the correct permissions:"
+			fn_script_log_info "The following directorys does not have the correct permissions:"
+			ls -l "${rootdir}"
+			core_exit.sh
 		fi
 	fi
-
-	# Check functions permissions
-	funcpermfail="0"
-	if [ -n "${functionsdir}" ]; then
-		while read -r filename
-			do
-				funcperm="$(stat -c %a "${filename}")"
-				userfuncdirperm="${funcperm:0:1}"
-				groupfuncdirperm="${funcperm:1:1}"
-				if [ "${userfuncdirperm}" != "7" ] && [ "${groupfuncdirperm}" != "7" ]; then
-					funcpermfail="1"
-					conclusionpermissionerror="1"
-				fi
-		done <<< "$(find "${functionsdir}" -name "*.sh")"
-
-		if [ "${funcpermfail}" == "1" ]; then
-			fn_print_fail_nl "Oops ! Permission issue..."
-			echo "	* Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control on scripts in \"${functionsdir}\""
-			echo "	* You might wanna run : chmod -R 770 \"${functionsdir}\""
-		fi
-	fi
-}
-
-fn_check_permissions_conclusion(){
-	# Exit if errors found
-	if [ "${conclusionpermissionerror}" == "1" ]; then
-		exit 1
-	fi
 }
 
 fn_check_ownership
-fn_check_permissions
-fn_check_permissions_conclusion
+fn_check_permissions

+ 5 - 3
lgsm/functions/check_root.sh

@@ -2,12 +2,14 @@
 # LGSM check_root.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 if [ $(whoami) = "root" ]; then
 	fn_print_fail_nl "Do NOT run this script as root!"
 	if [ -d "${scriptlogdir}" ]; then
-		fn_scriptlog "${selfname} attempted to run as root."
+		fn_script_log_fatal "${selfname} attempted to run as root."
 	fi
-	exit 1
+	core_exit.sh
 fi

+ 4 - 3
lgsm/functions/check_status.sh

@@ -1,11 +1,12 @@
 #!/bin/bash
-# LGSM check_status function
+# LGSM check_status.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Checks the proccess status of the server. Either online or offline.
 
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 if [ "${gamename}" == "Teamspeak 3" ]; then
 	# 1: Server is running
 	# 0: Server seems to have died

+ 10 - 10
lgsm/functions/check_steamcmd.sh

@@ -2,10 +2,9 @@
 # LGSM check_steamcmd.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Checks SteamCMD is installed and correct.
 
+local commandname="CHECK"
 
 fn_install_steamcmd(){
 	if [ ! -d "${steamcmddir}" ]; then
@@ -20,18 +19,18 @@ fn_install_steamcmd(){
 fn_check_steamcmd_user(){
 	# Checks steamuser is setup.
 	if [ "${steamuser}" == "username" ]; then
-		fn_print_fail_nl "Steam login not set. Update steamuser."
+		fn_print_fail_nl "Steam login not set. Update steamuser in ${selfname}."
 		echo "	* Change steamuser=\"username\" to a valid steam login."
 		if [ -d "${scriptlogdir}" ]; then
-			fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
-			exit 1
+			fn_script_log_fatal "Steam login not set. Update steamuser in ${selfname}."
 		fi
+		core_exit.sh
 	fi
 	# Anonymous user is set if steamuser is missing
 	if [ -z "${steamuser}" ]; then
-		fn_print_warn_nl "Steam login not set. Using anonymous login."
+		fn_print_error_nl "Steam login not set. Using anonymous login."
 		if [ -d "${scriptlogdir}" ]; then
-			fn_scriptlog "Steam login not set. Using anonymous login."
+			fn_script_log_error "Steam login not set. Using anonymous login."
 		fi
 		steamuser="anonymous"
 		steampass=""
@@ -47,8 +46,8 @@ fn_check_steamcmd_sh(){
 		if [ "${function_selfname}" == "command_install.sh" ]; then
 			fn_install_steamcmd
 		else
-			fn_print_warn_nl "SteamCMD is missing"
-			fn_scriptlog "SteamCMD is missing"
+			fn_print_error_nl "SteamCMD is missing"
+			fn_script_log_error "SteamCMD is missing"
 			sleep 1
 			fn_install_steamcmd
 		fi
@@ -70,4 +69,5 @@ fn_check_steamcmd_guard(){
 
 fn_check_steamcmd_user
 fn_check_steamcmd_sh
-fn_check_steamcmd_guard
+# stdbuf has now replaced unbuffer. This shoudl no longer be required
+#fn_check_steamcmd_guard

+ 5 - 3
lgsm/functions/check_system_dir.sh

@@ -2,12 +2,14 @@
 # LGSM check_system_dir.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 if [ ! -d "${systemdir}" ]; then
 	fn_print_fail_nl "Cannot access ${systemdir}: No such directory"
 	if [ -d "${scriptlogdir}" ]; then
-		fn_scriptlog "Cannot access ${systemdir}: No such directory."
+		fn_script_log_fatal "Cannot access ${systemdir}: No such directory."
 	fi
-	exit 1
+	core_exit.sh
 fi

+ 28 - 0
lgsm/functions/check_system_requirements.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+# LGSM check_system_requirements.sh
+# Author: Daniel Gibbs
+# Contributor: UltimateByte
+# Website: https://gameservermanagers.com
+# Description: Checks RAM requirements
+
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+info_distro.sh
+
+# RAM requirements in megabytes for each game or engine.
+if [ "${gamename}" == "Rust" ]; then
+	ramrequirementmb="4000"
+	ramrequirementgb="4"
+fi
+
+# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM.
+if [ -n "${ramrequirement}" ]; then
+	if [ "${physmemtotalmb}" -lt "${ramrequirementmb}" ]; then
+		# Warn the user
+		fn_print_warn "Insufficient memory: ${ramrequirementgb}G required, ${physmemtotal} available"
+		sleep 1
+		fn_print_warning "You may experiance poor performance from your server"
+		sleep 1
+	fi
+fi

+ 5 - 4
lgsm/functions/check_tmux.sh

@@ -2,19 +2,20 @@
 # LGSM check_tmux.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Checks if tmux is installed as too many users do not RTFM or know how to use Google.
 
-# Checks if tmux is installed as too many users do not RTFM or know how to use Google.
+local commandname="CHECK"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then
 	:
 else
 	fn_print_fail_nl "Tmux not installed"
 	sleep 1
-	fn_scriptlog "Tmux is not installed"
+	fn_script_log_fatal "Tmux is not installed"
 	echo "	* Tmux is required to run this server."
 	# Suitable passive agressive message
 	echo "	* Please see the the following link."
 	echo "	* https://gameservermanagers.com/tmux-not-found"
-	exit 127
+	core_exit.sh
 fi

+ 19 - 11
lgsm/functions/command_backup.sh

@@ -2,21 +2,22 @@
 # LGSM command_backup.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Creates a .tar.gz file in the backup directory.
 
-local modulename="Backup"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="BACKUP"
+local commandaction="Backup"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
+info_distro.sh
 backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')"
-echo ""
-fn_print_info_nl "A total of $(du -sh "${rootdir}" --exclude="${backupdir}" | awk '{print $1}') will be compressed into the following backup:"
+fn_print_dots ""
+sleep 0.5
+fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the following backup:"
 echo "${backupdir}/${backupname}.tar.gz"
 echo ""
 while true; do
-	read -p "Continue? [Y/N]" yn
+	read -e -i "y" -p "Continue? [Y/N]" yn
 	case $yn in
 	[Yy]* ) break;;
 	[Nn]* ) echo Exiting; return;;
@@ -38,14 +39,21 @@ if [ "${status}" != "0" ]; then
 	esac
 	done
 fi
-fn_scriptlog "Started backup"
+
 fn_print_dots "Backup in progress, please wait..."
+fn_script_log_info "Started backup"
 sleep 2
 if [ ! -d "${backupdir}" ]; then
 	mkdir "${backupdir}"
 fi
 tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./*
-fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size"
-fn_scriptlog "Complete, Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size"
+if [ $? != 0 ]; then
+	fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size"
+	fn_script_log_pass "Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size"
+else
+	fn_print_error_nl "Backup failed: ${backupname}.tar.gz"
+	fn_script_log_error "Backup failed: ${backupname}.tar.gz"
+fi
 sleep 1
-echo ""
+echo ""
+core_exit.sh

+ 14 - 11
lgsm/functions/command_console.sh

@@ -2,12 +2,11 @@
 # LGSM command_console.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Gives access to the server tmux console.
 
-local modulename="Console"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="CONSOLE"
+local commandaction="Console"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
 echo ""
@@ -25,24 +24,28 @@ while true; do
 	* ) echo "Please answer yes or no.";;
 esac
 done
-fn_print_dots "Starting"
+fn_print_dots "Accessing console"
 sleep 1
 check_status.sh
 if [ "${status}" != "0" ]; then
-	fn_print_ok_nl "Starting"
-	fn_scriptlog "accessed"
+	fn_print_ok_nl "Accessing console"
+	fn_script_log_pass "Console accessed"
 	sleep 1
 	tmux attach-session -t ${servicename}
+	fn_print_ok_nl "Closing console"
+	fn_script_log_pass "Console closed"
 else
-	fn_print_fail_nl "Server not running"
-	fn_scriptlog "Failed to access: Server not running"
+	fn_print_error_nl "Server not running"
+	fn_script_log_error "Failed to access: Server not running"
 	sleep 1
 	while true; do
-		read -p "Do you want to start the server? [y/N]" yn
+		read -e -i "y" -p  "Do you want to start the server? [Y/n]" yn
 		case $yn in
-		[Yy]* ) command_start.sh; break;;
+		[Yy]* ) exitbypass=1; command_start.sh; break;;
 		[Nn]* ) break;;
 		* ) echo "Please answer yes or no.";;
 	esac
 	done
 fi
+
+core_exit.sh

+ 30 - 9
lgsm/functions/command_debug.sh

@@ -2,16 +2,27 @@
 # LGSM command_debug.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Runs the server without tmux. Runs direct from the terminal.
 
-local modulename="Debug"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="DEBUG"
+local commandaction="Debug"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+# Trap to remove lockfile on quit.
+fn_lockfile_trap(){
+	# Remove lock file
+	rm -f "${rootdir}/${lockselfname}"
+	# resets terminal. Servers can sometimes mess up the terminal on exit.
+	reset
+	fn_print_ok_nl "Closing debug"
+	fn_script_log_pass "Debug closed"
+	core_exit.sh
+}
 
 check.sh
 fix.sh
 info_distro.sh
+# NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh
 fn_parms
 echo ""
 echo "${gamename} Debug"
@@ -41,19 +52,29 @@ while true; do
 	* ) echo "Please answer yes or no.";;
 esac
 done
-fn_scriptlog "Starting debug"
+
 fn_print_info_nl "Stopping any running servers"
-fn_scriptlog "Stopping any running servers"
+fn_script_log_info "Stopping any running servers"
 sleep 1
+exitbypass=1
 command_stop.sh
 fn_print_dots "Starting debug"
+fn_script_log_info "Starting debug"
 sleep 1
 fn_print_ok_nl "Starting debug"
-fn_scriptlog "Started debug"
+
+# create lock file.
+date > "${rootdir}/${lockselfname}"
+# trap to remove lockfile on quit.
+trap fn_lockfile_trap INT
+
 cd "${executabledir}"
-fix.sh
 if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 	${executable} ${parms} -debug
 else
 	${executable} ${parms}
-fi
+fi
+
+# remove trap.
+trap - INT
+core_exit.sh

+ 90 - 83
lgsm/functions/command_details.sh

@@ -2,11 +2,11 @@
 # LGSM command_details.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Displays server infomation.
 
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="DETAILS"
+local commandaction="Details"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 # Standard Details
 # This applies to all engines
@@ -23,15 +23,15 @@ fn_details_os(){
 	# GLIBC:     2.19
 
 	echo -e ""
-	echo -e "\e[93mDistro Details\e[0m"
+	echo -e "${lightyellow}Distro Details${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mDistro:\t\e[0m${os}"
-		echo -e "\e[34mArch:\t\e[0m${arch}"
-		echo -e "\e[34mKernel:\t\e[0m${kernel}"
-		echo -e "\e[34mHostname:\t\e[0m$HOSTNAME"
-		echo -e "\e[34mtmux:\t\e[0m${tmuxv}"
-		echo -e "\e[34mGLIBC:\t\e[0m${glibcversion}"
+		echo -e "${blue}Distro:\t${default}${os}"
+		echo -e "${blue}Arch:\t${default}${arch}"
+		echo -e "${blue}Kernel:\t${default}${kernel}"
+		echo -e "${blue}Hostname:\t${default}$HOSTNAME"
+		echo -e "${blue}tmux:\t${default}${tmuxv}"
+		echo -e "${blue}GLIBC:\t${default}${glibcversion}"
 	} | column -s $'\t' -t
 }
 
@@ -42,22 +42,22 @@ fn_details_performance(){
 	# Uptime:    55d, 3h, 38m
 	# Avg Load:  1.00, 1.01, 0.78
 	#
-	# Mem:       total   used   free
-	# Physical:  741M    656M   85M
+	# Mem:       total   used   free  cached
+	# Physical:  741M    656M   85M   256M 
 	# Swap:      0B      0B     0B
 
 	echo -e ""
-	echo -e "\e[93mPerformance\e[0m"
+	echo -e "${lightyellow}Performance${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mUptime:\t\e[0m${days}d, ${hours}h, ${minutes}m"
-		echo -e "\e[34mAvg Load:\t\e[0m${load}"
+		echo -e "${blue}Uptime:\t${default}${days}d, ${hours}h, ${minutes}m"
+		echo -e "${blue}Avg Load:\t${default}${load}"
 	} | column -s $'\t' -t
 	echo -e ""
 	{
-		echo -e "\e[34mMem:\t\e[34mtotal\t used\t free\e[0m"
-		echo -e "\e[34mPhysical:\t\e[0m${physmemtotal}\t${physmemused}\t${physmemfree}\e[0m"
-		echo -e "\e[34mSwap:\t\e[0m${swaptotal}\t${swapused}\t${swapfree}\e[0m"
+		echo -e "${blue}Mem:\t${blue}total\t used\t free\t cached${default}"
+		echo -e "${blue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}\t${physmemcached}${default}"
+		echo -e "${blue}Swap:\t${default}${swaptotal}\t${swapused}\t${swapfree}${default}"
 	} | column -s $'\t' -t
 }
 
@@ -69,19 +69,22 @@ fn_details_disk(){
 	# Total:        15G
 	# Used:         8.4G
 	# Available:    5.7G
+	# LGSM Total:	1G
 	# Serverfiles:  961M
+	# Backups:  	2G
 
 	echo -e ""
-	echo -e "\e[93mStorage\e[0m"
+	echo -e "${lightyellow}Storage${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mFilesystem:\t\e[0m${filesystem}"
-		echo -e "\e[34mTotal:\t\e[0m${totalspace}"
-		echo -e "\e[34mUsed:\t\e[0m${usedspace}"
-		echo -e "\e[34mAvailable:\t\e[0m${availspace}"
-		echo -e "\e[34mServerfiles:\t\e[0m${filesdirdu}"
+		echo -e "${blue}Filesystem:\t${default}${filesystem}"
+		echo -e "${blue}Total:\t${default}${totalspace}"
+		echo -e "${blue}Used:\t${default}${usedspace}"
+		echo -e "${blue}Available:\t${default}${availspace}"
+		echo -e "${blue}LGSM Total:\t${default}${rootdirdu}"
+		echo -e "${blue}Serverfiles:\t${default}${filesdirdu}"
 		if [ -d "${backupdir}" ]; then
-			echo -e "\e[34mBackups:\t\e[0m${backupdirdu}"
+			echo -e "${blue}Backups:\t${default}${backupdirdu}"
 		fi
 	} | column -s $'\t' -t
 }
@@ -98,65 +101,65 @@ fn_details_gameserver(){
 	# Status:           OFFLINE
 
 	echo -e ""
-	echo -e "\e[92m${gamename} Server Details\e[0m"
+	echo -e "${lightgreen}${gamename} Server Details${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
 		# Server name
-		echo -e "\e[34mServer name:\t\e[0m${servername}"
+		echo -e "${blue}Server name:\t${default}${servername}"
 
 		# Server ip
-		echo -e "\e[34mServer IP:\t\e[0m${ip}:${port}"
+		echo -e "${blue}Server IP:\t${default}${ip}:${port}"
 
 		# Server password
 		if [ -n "${serverpassword}" ]; then
-			echo -e "\e[34mServer password:\t\e[0m${serverpassword}"
+			echo -e "${blue}Server password:\t${default}${serverpassword}"
 		fi
 
 		# RCON password
 		if [ -n "${rconpassword}" ]; then
-			echo -e "\e[34mRCON password:\t\e[0m${rconpassword}"
+			echo -e "${blue}RCON password:\t${default}${rconpassword}"
 		fi
 
 		# Admin password
 		if [ -n "${adminpassword}" ]; then
-			echo -e "\e[34mAdmin password:\t\e[0m${adminpassword}"
+			echo -e "${blue}Admin password:\t${default}${adminpassword}"
 		fi
 
 		# Stats password (Quake Live)
 		if [ -n "${statspassword}" ]; then
-			echo -e "\e[34mStats password:\t\e[0m${statspassword}"
+			echo -e "${blue}Stats password:\t${default}${statspassword}"
 		fi
 
 		# Slots
 		if [ -n "${slots}" ]; then
-			echo -e "\e[34mSlots:\t\e[0m${slots}"
+			echo -e "${blue}Slots:\t${default}${slots}"
 		fi
 
 		# Game mode
 		if [ -n "${gamemode}" ]; then
-			echo -e "\e[34mGame mode:\t\e[0m${gamemode}"
+			echo -e "${blue}Game mode:\t${default}${gamemode}"
 		fi
 
 		# Game world
 		if [ -n "${gameworld}" ]; then
-			echo -e "\e[34mGame world:\t\e[0m${gameworld}"
+			echo -e "${blue}Game world:\t${default}${gameworld}"
 		fi
 
 		# Tick rate
 		if [ -n "${tickrate}" ]; then
-			echo -e "\e[34mTick rate:\t\e[0m${tickrate}"
+			echo -e "${blue}Tick rate:\t${default}${tickrate}"
 		fi
 
 		# Teamspeak dbplugin
 		if [ -n "${dbplugin}" ]; then
-			echo -e "\e[34mdbplugin:\t\e[0m${dbplugin}"
+			echo -e "${blue}dbplugin:\t${default}${dbplugin}"
 		fi
 
 		# Online status
 		if [ "${status}" == "0" ]; then
-			echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m"
+			echo -e "${blue}Status:\t${red}OFFLINE${default}"
 		else
-			echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m"
+			echo -e "${blue}Status:\t${green}ONLINE${default}"
 		fi
 	} | column -s $'\t' -t
 	echo -e ""
@@ -174,58 +177,61 @@ fn_details_script(){
 	# Location:            /home/lgsm/qlserver
 	# Config file:         /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
 
-	echo -e "\e[92m${selfname} Script Details\e[0m"
+	echo -e "${lightgreen}${selfname} Script Details${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
 		# Service name
-		echo -e "\e[34mService name:\t\e[0m${servicename}"
+		echo -e "${blue}Service name:\t${default}${servicename}"
 
 		# Script version
 		if [ -n "${version}" ]; then
-			echo -e "\e[34m${selfname} version:\t\e[0m${version}"
+			echo -e "${blue}${selfname} version:\t${default}${version}"
 		fi
 
 		# User
-		echo -e "\e[34mUser:\t\e[0m$(whoami)"
+		echo -e "${blue}User:\t${default}$(whoami)"
 
 		# GLIBC required
 		if [ -n "${glibcrequired}" ]; then
 			if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
 					:
 			elif [ "${glibcrequired}" == "UNKNOWN" ]; then
-				echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired}"
+				echo -e "${blue}GLIBC required:\t${red}${glibcrequired}"
 			elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
 				if [ "${glibcfix}" == "yes" ]; then
-					echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;32mUsing GLIBC fix\e[0m)"
+					echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${green}Using GLIBC fix${default})"
 				else
-					echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;31mGLIBC version too old\e[0m)"
+					echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${red}GLIBC version too old${default})"
 				fi
 			else
-				echo -e "\e[34mGLIBC required:\t\e[0;32m${glibcrequired}\e[0m"
+				echo -e "${blue}GLIBC required:\t${green}${glibcrequired}${default}"
 			fi
 		fi
 
 		# Email alert
-		echo -e "\e[34mEmail alert:\t\e[0m${emailalert}"
+		echo -e "${blue}Email alert:\t${default}${emailalert}"
+
+		# Pushbullet alert
+		echo -e "${blue}Pushbullet alert:\t${default}${pushbulletalert}"
 
 		# Update on start
-		echo -e "\e[34mUpdate on start:\t\e[0m${updateonstart}"
+		echo -e "${blue}Update on start:\t${default}${updateonstart}"
 
 		# Script location
-		echo -e "\e[34mLocation:\t\e[0m${rootdir}"
+		echo -e "${blue}Location:\t${default}${rootdir}"
 
 		# Config file location
 		if [ -n "${servercfgfullpath}" ]; then
 			if [ -f "${servercfgfullpath}" ]; then
-				echo -e "\e[34mConfig file:\t\e[0m${servercfgfullpath}"
+				echo -e "${blue}Config file:\t${default}${servercfgfullpath}"
 			else
-				echo -e "\e[34mConfig file:\t\e[0m\e[0;31m${servercfgfullpath}\e[0m (\e[0;31mFILE MISSING\e[0m)"
+				echo -e "${blue}Config file:\t${default}${red}${servercfgfullpath}${default} (${red}FILE MISSING${default})"
 			fi
 		fi
 
 		# Network config file location (ARMA 3)
 		if [ -n "${networkcfgfullpath}" ]; then
-			echo -e "\e[34mNetwork config file:\t\e[0m${networkcfgfullpath}"
+			echo -e "${blue}Network config file:\t${default}${networkcfgfullpath}"
 		fi
 	} | column -s $'\t' -t
 }
@@ -241,17 +247,17 @@ fn_details_backup(){
 	#     size:          945M
 
 	echo -e ""
-	echo -e "\e[92mBackups\e[0m"
+	echo -e "${lightgreen}Backups${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
 		echo -e "No Backups created"
 	else
 		{
-			echo -e "\e[34mNo. of backups:\t\e[0m${backupcount}"
-			echo -e "\e[34mLatest backup:\e[0m"
-			echo -e "\e[34m    date:\t\e[0m${lastbackupdate}"
-			echo -e "\e[34m    file:\t\e[0m${lastbackup}"
-			echo -e "\e[34m    size:\t\e[0m${lastbackupsize}"
+			echo -e "${blue}No. of backups:\t${default}${backupcount}"
+			echo -e "${blue}Latest backup:${default}"
+			echo -e "${blue}    date:\t${default}${lastbackupdate}"
+			echo -e "${blue}    file:\t${default}${lastbackup}"
+			echo -e "${blue}    size:\t${default}${lastbackupsize}"
 		} | column -s $'\t' -t
 	fi
 }
@@ -263,7 +269,7 @@ fn_details_commandlineparms(){
 	# ./run_server_x86.sh +set net_strict 1
 
 	echo -e ""
-	echo -e "\e[92mCommand-line Parameters\e[0m"
+	echo -e "${lightgreen}Command-line Parameters${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	echo -e "${executable} ${parms}"
 }
@@ -275,11 +281,11 @@ fn_details_ports(){
 	# /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
 
 	echo -e ""
-	echo -e "\e[92mPorts\e[0m"
+	echo -e "${lightgreen}Ports${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	echo -e "Change ports by editing the parameters in:"
 
-	parmslocation="\e[0;31mUNKNOWN\e[0m"
+	parmslocation="${red}UNKNOWN${default}"
 	local ports_edit_array=( "avalanche" "dontstarve" "projectzomboid" "idtech3" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "Teamspeak 3" "7 Days To Die" )
 	for port_edit in "${ports_edit_array[@]}"
 	do
@@ -303,9 +309,9 @@ fn_details_ports(){
 fn_details_statusbottom(){
 	echo -e ""
 	if [ "${status}" == "0" ]; then
-		echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m"
+		echo -e "${blue}Status:\t${red}OFFLINE${default}"
 	else
-		echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m"
+		echo -e "${blue}Status:\t${green}ONLINE${default}"
 	fi
 	echo -e ""
 }
@@ -344,7 +350,7 @@ fn_details_realvirtuality(){
 	echo -e "netstat -atunp | grep arma3server"
 	echo -e ""
 	if [ -z "${port}" ]||[ -z "${queryport}" ]||[ -z "${masterport}" ]; then
-		echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}."
+		echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}."
 		echo -e ""
 	fi
 	{
@@ -359,7 +365,7 @@ fn_details_idtech3(){
 	echo -e "netstat -atunp | grep qzeroded"
 	echo -e ""
 	if [ -z "${port}" ]||[ -z "${rconport}" ]||[ -z "${statsport}" ]; then
-		echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}."
+		echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}."
 		echo -e ""
 	fi
 	{
@@ -404,12 +410,12 @@ fn_details_spark(){
 		echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp"
 	} | column -s $'\t' -t
 	echo -e ""
-	echo -e "\e[92m${servername} WebAdmin\e[0m"
+	echo -e "${lightgreen}${servername} WebAdmin${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}/index.html"
-		echo -e "\e[34mWebAdmin username:\t\e[0m${webadminuser}"
-		echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}"
+		echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}/index.html"
+		echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
+		echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
 	} | column -s $'\t' -t
 }
 
@@ -464,20 +470,20 @@ fn_details_sdtd(){
 		echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp"
 	} | column -s $'\t' -t
 	echo -e ""
-	echo -e "\e[92m${servername} WebAdmin\e[0m"
+	echo -e "${lightgreen}${servername} WebAdmin${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mWebAdmin enabled:\t\e[0m${webadminenabled}"
-		echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}"
-		echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}"
+		echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
+		echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
+		echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
 	} | column -s $'\t' -t
 	echo -e ""
-	echo -e "\e[92m${servername} Telnet\e[0m"
+	echo -e "${lightgreen}${servername} Telnet${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mTelnet enabled:\t\e[0m${telnetenabled}"
-		echo -e "\e[34mTelnet address:\t\e[0m${ip} ${telnetport}"
-		echo -e "\e[34mTelnet password:\t\e[0m${telnetpass}"
+		echo -e "${blue}Telnet enabled:\t${default}${telnetenabled}"
+		echo -e "${blue}Telnet address:\t${default}${ip} ${telnetport}"
+		echo -e "${blue}Telnet password:\t${default}${telnetpass}"
 	} | column -s $'\t' -t
 }
 
@@ -529,13 +535,13 @@ fn_details_unreal(){
 		echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}"
 	} | column -s $'\t' -t
 	echo -e ""
-	echo -e "\e[92m${servername} WebAdmin\e[0m"
+	echo -e "${lightgreen}${servername} WebAdmin${default}"
 	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	{
-		echo -e "\e[34mWebAdmin enabled:\t\e[0m${webadminenabled}"
-		echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}"
-		echo -e "\e[34mWebAdmin username:\t\e[0m${webadminuser}"
-		echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}"
+		echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
+		echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
+		echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
+		echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
 	} | column -s $'\t' -t
 }
 
@@ -609,3 +615,4 @@ else
 fi
 
 fn_details_statusbottom
+core_exit.sh

+ 12 - 8
lgsm/functions/command_dev_debug.sh

@@ -1,17 +1,21 @@
 #!/bin/bash
-# LGSM dev_debug.sh function
+# LGSM command_dev_debug.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Dev only: enables debuging log to be saved to dev-debug.log.
 
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="DEV-DEBUG"
+local commandaction="Dev-Debug"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 
-if [ -f ".dev-debug" ]; then
-	rm .dev-debug
+if [ -f "${rootdir}/.dev-debug" ]; then
+	rm "${rootdir}/.dev-debug"
 	fn_print_ok_nl "Disabled dev-debug"
+	fn_script_log_info "Disabled dev-debug"
 else
-	date > .dev-debug
+	date > "${rootdir}/.dev-debug"
 	fn_print_ok_nl "Enabled dev-debug"
-fi
+	fn_script_log_info "Enabled dev-debug"
+fi
+core_exit.sh

+ 4 - 5
lgsm/functions/command_dev_detect_deps.sh

@@ -1,13 +1,12 @@
 #!/bin/bash
-# LGSM fn_dep_detect function
+# LGSM command_dev_detect_deps.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Detects dependencies the server binary requires.
 
-local modulename="Backup"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="DEPS-DETECT"
+local commandaction="Deps-Detect"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
 cd "${executabledir}"

+ 33 - 34
lgsm/functions/command_fastdl.sh

@@ -1,14 +1,13 @@
 #!/bin/bash
-# LGSM command_fastdl function
+# LGSM command_fastdl.sh function
 # Author: Daniel Gibbs
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
-lgsm_version="060616"
-
 # Description: Creates a FastDL folder
 
-local modulename="FastDL"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="FASTDL"
+local commandaction="FastDL"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
 
@@ -26,7 +25,7 @@ fn_check_bzip2(){
 	if [ -z "$(command -v bzip2)" ]; then
 		bzip2installed="0"
 		fn_print_info "bzip2 is not installed !"
-		fn_scriptlog "bzip2 is not installed"
+		fn_script_log_info "bzip2 is not installed"
 		echo -en "\n"
 		sleep 1
 		echo "We advise using it"
@@ -42,7 +41,7 @@ fn_fastdl_init(){
 	fn_print_ok "Welcome to LGSM's FastDL generator"
 	sleep 1
 	echo -en "\n"
-	fn_scriptlog "Started FastDL creation"
+	fn_script_log "Started FastDL creation"
 	while true; do
 		read -e -i "y" -p "Continue? [Y/n]" yn
 		case $yn in
@@ -51,7 +50,7 @@ fn_fastdl_init(){
 		* ) echo "Please answer yes or no.";;
 		esac
 	done
-	fn_scriptlog "Initiating FastDL creation"
+	fn_script_log "Initiating FastDL creation"
 
 	# Check and create folders
 	if [ ! -d "${webdir}" ]; then
@@ -63,7 +62,7 @@ fn_fastdl_init(){
 		sleep 0.5
 		mkdir "${webdir}"
 		fn_print_ok "Created www directory"
-		fn_scriptlog "FastDL created www directory"
+		fn_script_log "FastDL created www directory"
 		sleep 1
 		echo -en "\n"
 	fi
@@ -74,7 +73,7 @@ fn_fastdl_init(){
 		sleep 0.5
 		mkdir "${fastdldir}"
 		fn_print_ok "Created fastdl directory"
-		fn_scriptlog "FastDL created fastdl directory"
+		fn_script_log "FastDL created fastdl directory"
 		sleep 1
 		echo -en "\n"
 		clearoldfastdl="off" # Nothing to clear
@@ -86,7 +85,7 @@ fn_fastdl_init(){
 fn_fastdl_config(){
 	# Global settings for FastDL creation
 	fn_print_info "Entering configuration"
-	fn_scriptlog "Configuration"
+	fn_script_log "Configuration"
 	sleep 2
 	echo -en "\n"
 	# Prompt for clearing old files if folder was already here
@@ -95,8 +94,8 @@ fn_fastdl_config(){
 		while true; do
 			read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn
 			case $yn in
-			[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled"; break;;
-			[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_print_ok "Clearing Disabled"; break;;
+			[Yy]* ) clearoldfastdl="on"; fn_script_log "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled"; break;;
+			[Nn]* ) clearoldfastdl="off"; fn_script_log "clearoldfastdl disabled"; fn_print_ok "Clearing Disabled"; break;;
 			* ) echo "Please answer yes or no.";;
 			esac
 		done
@@ -108,8 +107,8 @@ fn_fastdl_config(){
 		while true; do
 			read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn
 			case $yn in
-			[Yy]* ) bzip2enable="on"; fn_scriptlog "bzip2 enabled"; fn_print_ok "bzip2 Enabled"; break;;
-			[Nn]* ) bzip2enable="off"; fn_scriptlog "bzip2 disabled"; fn_print_ok "bzip2 Disabled"; break;;
+			[Yy]* ) bzip2enable="on"; fn_script_log "bzip2 enabled"; fn_print_ok "bzip2 Enabled"; break;;
+			[Nn]* ) bzip2enable="off"; fn_script_log "bzip2 disabled"; fn_print_ok "bzip2 Disabled"; break;;
 			* ) echo "Please answer yes or no.";;
 			esac
 		done
@@ -123,8 +122,8 @@ fn_fastdl_gmod_config(){
 	while true; do
 		read -e -i "y" -p "Use client download enforcer? [Y/n]" yn
 		case $yn in
-		[Yy]* ) luaressource="on"; fn_scriptlog "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled"; break;;
-		[Nn]* ) luaressource="off"; fn_scriptlog "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled"; break;;
+		[Yy]* ) luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled"; break;;
+		[Nn]* ) luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled"; break;;
 		* ) echo "Please answer yes or no.";;
 		esac
 	done
@@ -135,11 +134,11 @@ fn_clear_old_fastdl(){
 	# Clearing old FastDL if user answered yes
 	if [ "${clearoldfastdl}" == "on" ]; then
 		fn_print_info "Clearing existing FastDL folder"
-		fn_scriptlog "Clearing existing FastDL folder"
+		fn_script_log "Clearing existing FastDL folder"
 		sleep 0.5
 		rm -R "${fastdldir:?}"/*
 		fn_print_ok "Old FastDL folder cleared"
-		fn_scriptlog "Old FastDL folder cleared"
+		fn_script_log "Old FastDL folder cleared"
 		sleep 1
 		echo -en "\n"
 	fi
@@ -149,7 +148,7 @@ fn_gmod_fastdl(){
 	# Copy all needed files for FastDL
 	echo ""
 	fn_print_dots "Starting gathering all needed files"
-	fn_scriptlog "Starting gathering all needed files"
+	fn_script_log "Starting gathering all needed files"
 	sleep 1
 	echo -en "\n"
 
@@ -158,7 +157,7 @@ fn_gmod_fastdl(){
 
 	# Map Files
 	fn_print_dots "Copying map files..."
-	fn_scriptlog "Copying map files"
+	fn_script_log "Copying map files"
 	sleep 0.5
 	find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
 	fn_print_ok "Map files copied"
@@ -167,7 +166,7 @@ fn_gmod_fastdl(){
 
 	# Materials
 	fn_print_dots "Copying materials..."
-	fn_scriptlog "Copying materials"
+	fn_script_log "Copying materials"
 	sleep 0.5
 	find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
 	find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
@@ -177,7 +176,7 @@ fn_gmod_fastdl(){
 
 	# Models
 	fn_print_dots "Copying models..."
-	fn_scriptlog "Copying models"
+	fn_script_log "Copying models"
 	sleep 1
 	find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
 	find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
@@ -189,7 +188,7 @@ fn_gmod_fastdl(){
 
 	# Particles
 	fn_print_dots "Copying particles..."
-	fn_scriptlog "Copying particles"
+	fn_script_log "Copying particles"
 	sleep 0.5
 	find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
 	fn_print_ok "Particles copied"
@@ -198,7 +197,7 @@ fn_gmod_fastdl(){
 
 	# Sounds
 	fn_print_dots "Copying sounds..."
-	fn_scriptlog "Copying sounds"
+	fn_script_log "Copying sounds"
 	sleep 0.5
 	find . -name '*.wav' | cpio --quiet -updm "${fastdldir}"
 	find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}"
@@ -209,7 +208,7 @@ fn_gmod_fastdl(){
 
 	# Resources (mostly fonts)
 	fn_print_dots "Copying fonts and png..."
-	fn_scriptlog "Copying fonts and png"
+	fn_script_log "Copying fonts and png"
 	sleep 1
 	find . -name '*.otf' | cpio --quiet -updm "${fastdldir}"
 	find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}"
@@ -224,7 +223,7 @@ fn_gmod_fastdl(){
 	# Correct addons folder structure for FastDL
 	if [ -d "${fastdldir}/addons" ]; then
 		fn_print_info "Adjusting addons' file structure"
-		fn_scriptlog "Adjusting addon's file structure"
+		fn_script_log "Adjusting addon's file structure"
 		sleep 1
 		cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
 	#Don't remove yet	rm -R "${fastdldir:?}/addons"
@@ -254,7 +253,7 @@ fn_lua_fastdl(){
 			sleep 1
 			rm -R "${luafastdlfullpath:?}"
 			fn_print_ok "Removed download enforcer"
-			fn_scriptlog "Removed old download inforcer"
+			fn_script_log "Removed old download inforcer"
 			echo -en "\n"
 			sleep 2
 		fi
@@ -266,19 +265,19 @@ fn_lua_fastdl(){
 			sleep 1
 			rm "${luafastdlfullpath}"
 			fn_print_ok "Removed old download enforcer"
-			fn_scriptlog "Removed old download enforcer"
+			fn_script_log "Removed old download enforcer"
 			echo -en "\n"
 			sleep 1
 		fi
 		fn_print_dots "Generating new download enforcer"
-		fn_scriptlog "Generating new download enforcer"
+		fn_script_log "Generating new download enforcer"
 		sleep 1
 		# Read all filenames and put them into a lua file at the right path
 		find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do
 			echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath}
 		done
 		fn_print_ok "Download enforcer generated"
-		fn_scriptlog "Download enforcer generated"
+		fn_script_log "Download enforcer generated"
 		echo -en "\n"
 		echo ""
 		sleep 2
@@ -293,11 +292,11 @@ fn_fastdl_bzip2(){
 		echo -en "\n"
 		echo ""
 		fn_print_dots "Compressing files using bzip2..."
-		fn_scriptlog "Compressing files using bzip2..."
+		fn_script_log "Compressing files using bzip2..."
 		# bzip2 all files that are not already compressed (keeping original files)
 		find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \;
 		fn_print_ok "bzip2 compression done"
-		fn_scriptlog "bzip2 compression done"
+		fn_script_log "bzip2 compression done"
 		sleep 1
 		echo -en "\n"
 	fi
@@ -307,7 +306,7 @@ fn_fastdl_completed(){
 	# Finished message
 	echo ""
 	fn_print_ok "Congratulations, it's done !"
-	fn_scriptlog "FastDL job done"
+	fn_script_log "FastDL job done"
 	sleep 2
 	echo -en "\n"
 	echo ""

+ 8 - 8
lgsm/functions/command_install.sh

@@ -1,13 +1,12 @@
 #!/bin/bash
-# LGSM fn_install function
+# LGSM command_install.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Overall function for the installer.
 
-local modulename="Install"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
 install_header.sh
@@ -18,10 +17,9 @@ check_deps.sh
 if [ "${gamename}" == "Unreal Tournament 2004" ]; then
 	install_server_files.sh
 	install_ut2k4_key.sh
-elif [ "${gamename}" == "Unreal Tournament 99" ]; then
+elif [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Teamspeak 3" ]; then
+	installer=1
 	install_server_files.sh
-elif [ "${gamename}" == "Teamspeak 3" ]; then
-	install_ts3.sh
 elif [ -n "${appid}" ]; then
 	install_steamcmd.sh
 	install_server_files.sh
@@ -34,5 +32,7 @@ if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "
 elif [ "${gamename}" == "Teamspeak 3" ]; then
 	install_ts3db.sh
 fi
+
 fix.sh
 install_complete.sh
+core_exit.sh

+ 27 - 28
lgsm/functions/command_monitor.sh

@@ -2,38 +2,37 @@
 # LGSM command_monitor.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Monitors server by checking for running proccesses
 # then passes to monitor_gsquery.sh.
 
-local modulename="Monitor"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="MONITOR"
+local commandaction="Monitor"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_monitor_check_lockfile(){
 	# Monitor does not run it lockfile is not found
 	if [ ! -f "${rootdir}/${lockselfname}" ]; then
-		fn_print_info_nl "Disabled: No lock file found"
-		fn_scriptlog "Disabled: No lock file found"
+		fn_print_error_nl "Disabled: No lock file found"
+		fn_script_log_error "Disabled: No lock file found"
 		echo "	* To enable monitor run ./${selfname} start"
-		exit 1
+		core_exit.sh
 	fi
 }
 
 fn_monitor_check_update(){
 	# Monitor will not check if update is running.
 	if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then
-		fn_print_info_nl "SteamCMD is currently checking for updates"
-		fn_scriptlog "SteamCMD is currently checking for updates"
+		fn_print_error_nl "SteamCMD is currently checking for updates"
+		fn_script_log_error "SteamCMD is currently checking for updates"
 		sleep 1
-		exit
+		core_exit.sh
 	fi
 }
 
 fn_monitor_msg_checking(){
 	fn_print_dots "Checking session: "
 	fn_print_checking_eol
-	fn_scriptlog "Checking session: CHECKING"
+	fn_script_log_info "Checking session: CHECKING"
 	sleep 1
 }
 
@@ -41,19 +40,18 @@ fn_monitor_teamspeak3(){
 	if [ "${status}" != "0" ]; then
 		fn_print_ok "Checking session: "
 		fn_print_ok_eol_nl
-		fn_scriptlog "Checking session: OK"
-		exit
+		fn_script_log_pass "Checking session: OK"
 	else
-		fn_print_fail "Checking session: ${ts3error}: "
+		fn_print_error "Checking session: ${ts3error}: "
 		fn_print_fail_eol_nl
-		fn_scriptlog "Checking session: ${ts3error}: FAIL"
+		fn_script_log_error "Checking session: ${ts3error}: FAIL"
 		failurereason="${ts3error}"
 		alert="restart"
 		alert.sh
+		fn_script_log_info "Monitor is starting ${servername}"
+		sleep 1
+		command_restart.sh
 	fi
-	fn_scriptlog "Monitor is starting ${servername}"
-	sleep 1
-	fn_restart
 }
 
 fn_monitor_tmux(){
@@ -61,7 +59,7 @@ fn_monitor_tmux(){
 	if [ "${status}" != "0" ]; then
 		fn_print_ok "Checking session: "
 		fn_print_ok_eol_nl
-		fn_scriptlog "Checking session: OK"
+		fn_script_log_pass "Checking session: OK"
 		# runs gsquery check on game with specific engines.
 		local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 )
 		for allowed_engine in "${allowed_engines_array[@]}"
@@ -70,25 +68,25 @@ fn_monitor_tmux(){
 				monitor_gsquery.sh
 			fi
 		done
-		exit
 	else
-		fn_print_fail "Checking session: "
+		fn_print_error "Checking session: "
 		fn_print_fail_eol_nl
-		fn_scriptlog "Checking session: FAIL"
+		fn_script_log_error "Checking session: FAIL"
 		alert="restart"
 		alert.sh
-		fn_scriptlog "Monitor is starting ${servername}"
+		fn_script_log_info "Monitor is starting ${servername}"
 		sleep 1
-		command_start.sh
+		command_restart.sh
 	fi
 }
 
+fn_print_dots "${servername}"
+sleep 1
 check.sh
 logs.sh
 info_config.sh
-fn_print_dots "${servername}"
-fn_scriptlog "${servername}"
-sleep 1
+
+
 fn_monitor_check_lockfile
 fn_monitor_check_update
 fn_monitor_msg_checking
@@ -96,4 +94,5 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_monitor_teamspeak3
 else
 	fn_monitor_tmux
-fi
+fi
+core_exit.sh

+ 14 - 0
lgsm/functions/command_restart.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+# LGSM command_start.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: Starts the server.
+
+local commandname="RESTART"
+local commandaction="Restarting"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+info_config.sh
+exitbypass=1
+command_stop.sh
+command_start.sh

+ 31 - 33
lgsm/functions/command_start.sh

@@ -2,37 +2,33 @@
 # LGSM command_start.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Starts the server.
 
-local modulename="Starting"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="START"
+local commandaction="Starting"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_start_teamspeak3(){
 	if [ ! -e "${servercfgfullpath}" ]; then
 		fn_print_warn_nl "${servercfgfullpath} is missing"
-		fn_scriptlog "${servercfgfullpath} is missing"
+		fn_script_log_warn "${servercfgfullpath} is missing"
 		echo  "	* Creating blank ${servercfg}"
-		fn_scriptlog "Creating blank ${servercfg}"
+		fn_script_log_info "Creating blank ${servercfg}"
 		sleep 2
 		echo  "	* ${servercfg} can remain blank by default."
-		fn_scriptlog "${servercfgfullpath} can remain blank by default."
+		fn_script_log_info "${servercfgfullpath} can remain blank by default."
 		sleep 2
 		echo  "	* ${servercfg} is located in ${servercfgfullpath}."
-		fn_scriptlog "${servercfg} is located in ${servercfgfullpath}."
+		fn_script_log_info "${servercfg} is located in ${servercfgfullpath}."
 		sleep 5
 		touch "${servercfgfullpath}"
 	fi
-
-	fn_print_dots "${servername}"
-	fn_scriptlog "${servername}"
 	sleep 1
 	check_status.sh
 	if [ "${status}" != "0" ]; then
 		fn_print_info_nl "${servername} is already running"
-		fn_scriptlog "${servername} is already running"
-		exit
+		fn_script_log_error "${servername} is already running"
+		core_exit.sh
 	fi
 
 	mv "${scriptlog}" "${scriptlogdate}"
@@ -48,25 +44,22 @@ fn_start_teamspeak3(){
 	check_status.sh
 	if [ "${status}" == "0" ]; then
 		fn_print_fail_nl "Unable to start ${servername}"
-		fn_scriptlog "Unable to start ${servername}"
+		fn_script_log_fatal "Unable to start ${servername}"
 		echo -e "	Check log files: ${rootdir}/log"
-		exit 1
+		core_exit.sh
 	else
 		fn_print_ok_nl "${servername}"
-		fn_scriptlog "Started ${servername}"
+		fn_script_log_pass "Started ${servername}"
 	fi
 }
 
 fn_start_tmux(){
 	fn_parms
-	fn_print_dots "${servername}"
-	fn_scriptlog "${servername}"
-	sleep 1
 
 	# Log rotation
 	check_status.sh
 	if [ "${status}" == "0" ]; then
-		fn_scriptlog "Rotating log files"
+		fn_script_log_info "Rotating log files"
 		if [ "${engine}" == "unreal2" ]; then
 			if [ -f "${gamelog}" ]; then
 				mv "${gamelog}" "${gamelogdate}"
@@ -80,8 +73,8 @@ fn_start_tmux(){
 	check_status.sh
 	if [ "${status}" != "0" ]; then
 		fn_print_info_nl "${servername} is already running"
-		fn_scriptlog "${servername} is already running"
-		exit
+		fn_script_log_error "${servername} is already running"
+		core_exit.sh
 	fi
 
 	# Create lock file
@@ -110,7 +103,7 @@ fn_start_tmux(){
 	elif [ "${consolelogging}" == "off" ]; then
 		touch "${consolelog}"
 		cat "Console logging disabled by user" >> "{consolelog}"
-		fn_scriptlog "Console logging disabled by user"
+		fn_script_log_info "Console logging disabled by user"
 	fi
 	sleep 1
 
@@ -118,11 +111,11 @@ fn_start_tmux(){
 	check_status.sh
 	if [ "${status}" == "0" ]; then
 		fn_print_fail_nl "Unable to start ${servername}"
-		fn_scriptlog "Unable to start ${servername}"
+		fn_script_log_fatal "Unable to start ${servername}"
 		sleep 1
 		if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then
 			fn_print_fail_nl "Unable to start ${servername}: Tmux error:"
-			fn_scriptlog "Tmux error"
+			fn_script_log_fatal "Unable to start ${servername}: Tmux error:"
 			echo ""
 			echo "Command"
 			echo "================================="
@@ -139,35 +132,38 @@ fn_start_tmux(){
 			echo "================================="
 				if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then
 					echo "$(whoami) is not part of the tty group."
-					fn_scriptlog "$(whoami) is not part of the tty group."
+					fn_script_log_info "$(whoami) is not part of the tty group."
 					group=$(grep tty /etc/group)
 					echo ""
 					echo "	${group}"
-					fn_scriptlog "${group}"
+					fn_script_log_info "${group}"
 					echo ""
 					echo "Run the following command with root privileges."
 					echo ""
 					echo "	usermod -G tty $(whoami)"
 					echo ""
 					echo "https://gameservermanagers.com/tmux-op-perm"
-					fn_scriptlog "https://gameservermanagers.com/tmux-op-perm"
+					fn_script_log_info "https://gameservermanagers.com/tmux-op-perm"
 				else
 					echo "No known fix currently. Please log an issue."
-					fn_scriptlog "No known fix currently. Please log an issue."
+					fn_script_log_info "No known fix currently. Please log an issue."
 					echo "https://gameservermanagers.com/issues"
-					fn_scriptlog "https://gameservermanagers.com/issues"
+					fn_script_log_info "https://gameservermanagers.com/issues"
 				fi
 			fi
 		fi
-	exit 1
+
+		core_exit.sh
 	else
 		fn_print_ok "${servername}"
-		fn_scriptlog "Started ${servername}"
+		fn_script_log_pass "Started ${servername}"
 	fi
 	rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"
 	echo -en "\n"
 }
 
+fn_print_dots "${servername}"
+sleep 1
 check.sh
 fix.sh
 info_config.sh
@@ -176,7 +172,8 @@ logs.sh
 # Will check for updates is updateonstart is yes
 if [ "${status}" == "0" ]; then
 	if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then
-		update_check.sh
+		exitbypass=1
+		command_update.sh
 	fi
 fi
 
@@ -185,3 +182,4 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
 else
 	fn_start_tmux
 fi
+core_exit.sh

+ 75 - 78
lgsm/functions/command_stop.sh

@@ -2,17 +2,16 @@
 # LGSM command_stop.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="050616"
-
 # Description: Stops the server.
 
-local modulename="Stopping"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="STOP"
+local commandaction="Stopping"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 # Attempts Graceful of source using rcon 'quit' command.
 fn_stop_graceful_source(){
 	fn_print_dots "Graceful: rcon quit"
-	fn_scriptlog "Graceful: rcon quit"
+	fn_script_log_info "Graceful: rcon quit"
 	# sends quit
 	tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
 	# waits up to 30 seconds giving the server time to shutdown gracefuly
@@ -21,7 +20,7 @@ fn_stop_graceful_source(){
 		if [ "${status}" == "0" ]; then
 			fn_print_ok "Graceful: rcon quit: ${seconds}: "
 			fn_print_ok_eol_nl
-			fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds"
+			fn_script_log_pass "Graceful: rcon quit: OK: ${seconds} seconds"
 			break
 		fi
 		sleep 1
@@ -29,9 +28,9 @@ fn_stop_graceful_source(){
 	done
 	check_status.sh
 	if [ "${status}" != "0" ]; then
-		fn_print_fail "Graceful: rcon quit: "
+		fn_print_error "Graceful: rcon quit: "
 		fn_print_fail_eol_nl
-		fn_scriptlog "Graceful: rcon quit: FAIL"
+		fn_script_log_error "Graceful: rcon quit: FAIL"
 	fi
 	sleep 1
 	fn_stop_tmux
@@ -43,7 +42,7 @@ fn_stop_graceful_source(){
 # preventing the server from coming back online.
 fn_stop_graceful_goldsource(){
 	fn_print_dots "Graceful: rcon quit"
-	fn_scriptlog "Graceful: rcon quit"
+	fn_script_log_info "Graceful: rcon quit"
 	# sends quit
 	tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
 	# waits 3 seconds as goldsource servers restart with the quit command
@@ -53,7 +52,7 @@ fn_stop_graceful_goldsource(){
 	done
 	fn_print_ok "Graceful: rcon quit: ${seconds}: "
 	fn_print_ok_eol_nl
-	fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds"
+	fn_script_log_pass "Graceful: rcon quit: OK: ${seconds} seconds"
 	sleep 1
 	fn_stop_tmux
 }
@@ -77,12 +76,11 @@ fn_stop_telnet_sdtd(){
 	expect { eof }
 	puts "Completed.\n"
 	')
-
 }
 
 fn_stop_graceful_sdtd(){
 	fn_print_dots "Graceful: telnet"
-	fn_scriptlog "Graceful: telnet"
+	fn_script_log_info "Graceful: telnet"
 	sleep 1
 	if [ "${telnetenabled}" == "false" ]; then
 		fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
@@ -90,15 +88,15 @@ fn_stop_graceful_sdtd(){
 		# Tries to shutdown with both localhost and server IP.
 		for telnetip in 127.0.0.1 ${ip}; do
 			fn_print_dots "Graceful: telnet: ${telnetip}"
-			fn_scriptlog "Graceful: telnet: ${telnetip}"
+			fn_script_log_info "Graceful: telnet: ${telnetip}"
 			sleep 1
 			fn_stop_telnet_sdtd
 			completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.")
 			refused=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Timeout or EOF")
 			if [ -n "${refused}" ]; then
-				fn_print_warn "Graceful: telnet: ${telnetip}: "
+				fn_print_error "Graceful: telnet: ${telnetip}: "
 				fn_print_fail_eol_nl
-				fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL"
+				fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL"
 				sleep 1
 			elif [ -n "${completed}" ]; then
 				break
@@ -114,7 +112,7 @@ fn_stop_graceful_sdtd(){
 				if [ -n "${refused}" ]; then
 					fn_print_ok "Graceful: telnet: ${telnetip}: "
 					fn_print_ok_eol_nl
-					fn_scriptlog "Graceful: telnet: ${telnetip}: ${seconds} seconds"
+					fn_script_log_pass "Graceful: telnet: ${telnetip}: ${seconds} seconds"
 					break
 				fi
 				sleep 1
@@ -124,12 +122,12 @@ fn_stop_graceful_sdtd(){
 		# If cannot shutdown correctly world save may be lost
 		else
 			if [ -n "${refused}" ]; then
-				fn_print_fail "Graceful: telnet: "
+				fn_print_error "Graceful: telnet: "
 				fn_print_fail_eol_nl
-				fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL"
+				fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL"
 			else
-				fn_print_fail_nl "Graceful: telnet: Unknown error"
-				fn_scriptlog "Graceful: telnet: Unknown error"
+				fn_print_error_nl "Graceful: telnet: Unknown error"
+				fn_script_log_error "Graceful: telnet: Unknown error"
 			fi
 			echo -en "\n" | tee -a "${scriptlog}"
 			echo -en "Telnet output:" | tee -a "${scriptlog}"
@@ -137,11 +135,9 @@ fn_stop_graceful_sdtd(){
 			echo -en "\n\n" | tee -a "${scriptlog}"
 		fi
 	else
-		fn_print_dots "Graceful: telnet: "
-		fn_scriptlog "Graceful: telnet: "
-		fn_print_fail "Graceful: telnet: expect not installed: "
+		fn_print_warn "Graceful: telnet: expect not installed: "
 		fn_print_fail_eol_nl
-		fn_scriptlog "Graceful: telnet: expect not installed: FAIL"
+		fn_script_log_warn "Graceful: telnet: expect not installed: FAIL"
 	fi
 	sleep 1
 	fn_stop_tmux
@@ -160,47 +156,48 @@ fn_stop_graceful_select(){
 }
 
 fn_stop_ark(){
-    	MAXPIDITER=15 # The maximum number of times to check if the ark pid has closed gracefully.
-        info_config.sh
-        if [ -z $queryport ] ; then
-                fn_print_warn "no queryport found using info_config.sh"
-                userconfigfile="${filesdir}"
-                userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini"
-                queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g")
-        fi
-        if [ -z $queryport ] ; then
-                fn_print_warn "no queryport found in the GameUsersettings.ini file"
-                return
-        fi
+		maxpiditer=15 # The maximum number of times to check if the ark pid has closed gracefully.
+		info_config.sh
+		if [ -z "${queryport}" ]; then
+				fn_print_warn "No queryport found using info_config.sh"
+				fn_script_log_warn "No queryport found using info_config.sh"
+				userconfigfile="${filesdir}"
+				userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini"
+				queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g")
+		fi
+		if [ -z "${queryport}" ]; then
+				fn_print_warn "No queryport found in the GameUsersettings.ini file"
+				fn_script_log_warn "No queryport found in the GameUsersettings.ini file"
+				return
+		fi
 
-        if [[ ${#queryport} -gt 0 ]] ; then
-                for (( pidcheck=0 ; pidcheck < ${MAXPIDITER} ; pidcheck++ )) ; do
-                        pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\
-                                grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\
-                                rev | cut -d\/ -f1)
-                        #
-                        # check for a valid pid
-                        let pid+=0 # turns an empty string into a valid number, '0',
-                        # and a valid numeric pid remains unchanged.
-                        if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then
-                        fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck"
-                                sleep 1
-                        else
-                                break # Our job is done here
-                        fi # end if for pid range check
-                done
-                if [[ ${pidcheck} -eq ${MAXPIDITER} ]] ; then
-                        # The process doesn't want to close after 20 seconds.
-                        # kill it hard.
-                        fn_print_warn "Terminating reluctant Ark process: $pid"
-                        kill -9 $pid
-                fi
-        fi # end if for port check
+		if [[ ${#queryport} -gt 0 ]] ; then
+				for (( pidcheck=0 ; pidcheck < ${maxpiditer} ; pidcheck++ )) ; do
+						pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\
+								grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\
+								rev | cut -d\/ -f1)
+						#
+						# check for a valid pid
+						let pid+=0 # turns an empty string into a valid number, '0',
+						# and a valid numeric pid remains unchanged.
+						if [[ ${pid} -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then
+						fn_print_dots "Process still bound. Awaiting graceful exit: ${pidcheck}"
+								sleep 1
+						else
+								break # Our job is done here
+						fi # end if for pid range check
+				done
+				if [[ ${pidcheck} -eq ${maxpiditer} ]] ; then
+						# The process doesn't want to close after 20 seconds.
+						# kill it hard.
+						fn_print_error "Terminating reluctant Ark process: ${pid}"
+						kill -9 $pid
+				fi
+		fi # end if for port check
 } # end of fn_stop_ark
 
 fn_stop_teamspeak3(){
 	fn_print_dots "${servername}"
-	fn_scriptlog "${servername}"
 	sleep 1
 	${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1
 	check_status.sh
@@ -208,16 +205,16 @@ fn_stop_teamspeak3(){
 		# Remove lock file
 		rm -f "${rootdir}/${lockselfname}"
 		fn_print_ok_nl "${servername}"
-		fn_scriptlog "Stopped ${servername}"
+		fn_script_log_pass "Stopped ${servername}"
 	else
-		fn_print_fail_nl "Unable to stop${servername}"
-		fn_scriptlog "Unable to stop${servername}"
+		fn_print_fail_nl "Unable to stop ${servername}"
+		fn_script_log_fail "Unable to stop ${servername}"
 	fi
 }
 
 fn_stop_tmux(){
 	fn_print_dots "${servername}"
-	fn_scriptlog "tmux kill-session: ${servername}"
+	fn_script_log_info "tmux kill-session: ${servername}"
 	sleep 1
 	# Kill tmux session
 	tmux kill-session -t "${servicename}" > /dev/null 2>&1
@@ -227,16 +224,16 @@ fn_stop_tmux(){
 		# Remove lock file
 		rm -f "${rootdir}/${lockselfname}"
 		# ARK doesn't clean up immediately after tmux is killed.
-                # Make certain the ports are cleared before continuing.
-                if [ "${gamename}" == "ARK: Survivial Evolved" ]; then
-                        fn_stop_ark
-                        echo -en "\n"
-                fi
+				# Make certain the ports are cleared before continuing.
+				if [ "${gamename}" == "ARK: Survivial Evolved" ]; then
+						fn_stop_ark
+						echo -en "\n"
+				fi
 		fn_print_ok_nl "${servername}"
-		fn_scriptlog "Stopped ${servername}"
+		fn_script_log_pass "Stopped ${servername}"
 	else
 		fn_print_fail_nl "Unable to stop${servername}"
-		fn_scriptlog "Unable to stop${servername}"
+		fn_script_log_fatal "Unable to stop${servername}"
 	fi
 }
 
@@ -245,25 +242,25 @@ fn_stop_pre_check(){
 	if [ "${gamename}" == "Teamspeak 3" ]; then
 		check_status.sh
 		if [ "${status}" == "0" ]; then
-			fn_print_ok_nl "${servername} is already stopped"
-			fn_scriptlog "${servername} is already stopped"
+			fn_print_info_nl "${servername} is already stopped"
+			fn_script_log_error "${servername} is already stopped"
 		else
 			fn_stop_teamspeak3
 		fi
 	else
 		check_status.sh
 		if [ "${status}" == "0" ]; then
-			fn_print_ok_nl "${servername} is already stopped"
-			fn_scriptlog "${servername} is already stopped"
+			fn_print_info_nl "${servername} is already stopped"
+			fn_script_log_error "${servername} is already stopped"
 		else
 			fn_stop_graceful_select
 		fi
 	fi
 }
 
-check.sh
-info_config.sh
 fn_print_dots "${servername}"
-fn_scriptlog "${servername}"
 sleep 1
+check.sh
+info_config.sh
 fn_stop_pre_check
+core_exit.sh

+ 7 - 5
lgsm/functions/command_test_alert.sh

@@ -1,15 +1,17 @@
 #!/bin/bash
-# LGSM command_email_test.sh function
+# LGSM command_test_alert.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Sends a test email alert.
 
-local modulename="Alert"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="ALERT"
+local commandaction="Alert"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
+fn_print_dots "${servername}"
+sleep 1
 check.sh
 info_config.sh
 alert="test"
 alert.sh
+core_exit.sh

+ 9 - 9
lgsm/functions/command_ts3_server_pass.sh

@@ -1,14 +1,13 @@
 #!/bin/bash
-# LGSM command_serveradmin_password.sh function
+# LGSM command_ts3_server_pass.sh function
 # Author: Daniel Gibbs
 # Contributor : UltimateByte
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Changes TS3 serveradmin password
 
-local modulename="Change password"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="TS3-CHANGE-PASS"
+local commandaction="TS3 Change Password"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 
 fn_serveradmin_password_prompt(){
@@ -28,14 +27,14 @@ fn_serveradmin_password_prompt(){
 		* ) echo "Please answer yes or no.";;
 	esac
 	done
-	fn_scriptlog "Initiating ${gamename} ServerAdmin password change"
+	fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
 	read -p "Enter new password : " newpassword
 	}
 
 
 	fn_serveradmin_password_set(){
 	fn_print_info_nl "Applying new password"
-	fn_scriptlog "Applying new password"
+	fn_script_log_info "Applying new password"
 	sleep 1
 	# Stop any running server
 	command_stop.sh
@@ -47,7 +46,7 @@ fn_serveradmin_password_prompt(){
 	command_stop.sh
 	ts3serverpass="0"
 	fn_print_ok_nl "Password applied"
-	fn_scriptlog "New ServerAdmin password applied"
+	fn_script_log_pass "New ServerAdmin password applied"
 	sleep 1
 }
 
@@ -60,4 +59,5 @@ if [ "${status}" != "0" ]; then
 	command_start.sh
 else
 	fn_serveradmin_password_set
-fi
+fi
+core_exit.sh

+ 22 - 0
lgsm/functions/command_update.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+# LGSM command_update.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: Handles updating of servers.
+
+local commandname="UPDATE"
+local commandaction="Update"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+fn_print_dots ""
+sleep 0.5
+check.sh
+
+
+if [ "${gamename}" == "Teamspeak 3" ]; then
+	update_ts3.sh
+else
+	update_steamcmd.sh
+fi
+
+core_exit.sh

+ 36 - 13
lgsm/functions/command_update_functions.sh

@@ -2,15 +2,15 @@
 # LGSM command_update_functions.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
 
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
-check.sh
+local commandaction="Update LGSM"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 fn_print_dots "Updating functions"
-fn_scriptlog "Updating functions"
 sleep 1
+check.sh
+fn_script_log_info "Updating functions"
 echo -ne "\n"
 
 # Removed legecy functions dir
@@ -23,16 +23,39 @@ fi
 
 if [ -n "${functionsdir}" ]; then
 	if [ -d "${functionsdir}" ]; then
-		rm -rfv "${functionsdir}/"*
-		exitcode=$?
+		cd "${functionsdir}"
+		for functionfile in *
+		do
+			# Check curl exists and use available path
+			curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
+			for curlcmd in ${curlpaths}
+			do
+				if [ -x "${curlcmd}" ]; then
+					curlcmd=${curlcmd}
+					break
+				fi
+			done
+
+			echo -ne "    checking ${functionfile}...\c"
+			function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
+			if [ "${function_file_diff}" != "" ]; then
+				fn_print_update_eol_nl
+				fn_script_log_info "checking ${functionfile}: UPDATE"
+				rm -rf "${functionsdir}/${functionfile}"
+				fn_update_function
+			else
+				fn_print_ok_eol_nl
+			fi
+		done
 	fi
 fi
 
-if [ "${exitcode}" == "0" ]; then
-	fn_print_ok "Updating functions"
-	fn_scriptlog "Success! Updating functions"
-else
+if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then
 	fn_print_fail "Updating functions"
-	fn_scriptlog "Failure! Updating functions"
+	fn_script_log_fatal "Updating functions"
+else
+	fn_print_ok "Updating functions"
+	fn_script_log_pass "Updating functions"
 fi
-echo -ne "\n"
+echo -ne "\n"
+core_exit.sh

+ 25 - 16
lgsm/functions/command_validate.sh

@@ -2,29 +2,24 @@
 # LGSM command_validate.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Runs a server validation.
 
-local modulename="Validate"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandname="VALIDATE"
+local commandaction="Validate"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_validation(){
-	fn_print_warn_nl "Validating may overwrite some customised files."
-	echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
-	sleep 5
+	echo -e "	* Validating may overwrite some customised files."
+	echo -en "	* https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
+	sleep 3
 	echo -en "\n"
-	fn_print_dots "Checking server files"
-	sleep 1
-	fn_print_ok "Checking server files"
-	fn_scriptlog "Checking server files"
+
+	fn_script_log_info "Validating files: SteamCMD"
 	sleep 1
 
 	cd "${rootdir}/steamcmd"
 
-        if [ $(command -v unbuffer) ]; then
-		unbuffer=unbuffer
-        elif  [ $(command -v stdbuf) ]; then
+    if  [ $(command -v stdbuf) ]; then
 		unbuffer="stdbuf -i0 -o0 -e0"
 	fi
 
@@ -33,16 +28,30 @@ fn_validation(){
 	else
 		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
 	fi
-
+	if [ $? != 0 ]; then
+		fn_print_fail_nl "Validating files: SteamCMD"
+		fn_script_log_fatal "Validating files: SteamCMD: FAIL"
+	else
+		fn_print_ok_nl "Validating files: SteamCMD"
+		fn_script_log_pass "Validating files: SteamCMD: OK"
+	fi
 	fix.sh
-	fn_scriptlog "Checking complete"
+
 }
 
+fn_print_dots_nl "Validating files:"
+sleep 0.5
+fn_print_dots_nl "Validating files: SteamCMD"
+sleep 1
+check.sh
 check_status.sh
 if [ "${status}" != "0" ]; then
+	exitbypass=1
     command_stop.sh
     fn_validation
+    exitbypass=1
     command_start.sh
 else
     fn_validation
 fi
+core_exit.sh

+ 4 - 2
lgsm/functions/compress_unreal2_maps.sh

@@ -2,9 +2,10 @@
 # LGSM compress_unreal2_maps.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: compresses unreal maps
 
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandaction="Unreal Map Compressor"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
 clear
@@ -33,3 +34,4 @@ for map in "${filesdir}/Maps/"*; do
 	./ucc-bin compress "${map}" --nohomedir
 done
 mv -fv "${filesdir}/Maps/"*.ut2.uz2 "${compressedmapsdir}"
+core_exit.sh

+ 4 - 2
lgsm/functions/compress_ut99_maps.sh

@@ -2,9 +2,10 @@
 # LGSM compress_ut99_maps.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: compresses unreal maps
 
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+local commandaction="Unreal Map Compressor"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 check.sh
 clear
@@ -33,3 +34,4 @@ for map in "${filesdir}/Maps/"*; do
 	./ucc-bin compress "${map}" --nohomedir
 done
 mv -fv "${filesdir}/Maps/"*.unr.uz "${compressedmapsdir}"
+core_exit.sh

+ 39 - 20
lgsm/functions/core_dl.sh

@@ -2,8 +2,6 @@
 # LGSM core_dl.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Deals with all downloads for LGSM.
 
 # fileurl: The URL of the file: http://example.com/dl/File.tar.bz2
@@ -18,6 +16,10 @@ lgsm_version="210516"
 # fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
 # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd"
 
+local commandname="DOWNLOAD"
+local commandaction="Download"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 fn_dl_md5(){
 	# Runs MD5 Check if available
 	if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then
@@ -28,15 +30,15 @@ fn_dl_md5(){
 			fn_print_fail_eol_nl
 			echo "${filename} returned MD5 checksum: ${md5sumcmd}"
 			echo "expected MD5 checksum: ${md5}"
-			fn_scriptlog "verifying ${filename} with MD5: FAIL"
-			fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
-			fn_scriptlog "expected MD5 checksum: ${md5}"
-			exit 1
+			fn_script_log_fatal "Verifying ${filename} with MD5: FAIL"
+			fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}"
+			fn_script_log_info "Expected MD5 checksum: ${md5}"
+			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_scriptlog "verifying ${filename} with MD5: OK"
-			fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}"
-			fn_scriptlog "expected MD5 checksum: ${md5}"
+			fn_script_log_pass "Verifying ${filename} with MD5: OK"
+			fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}"
+			fn_script_log_info "Expected MD5 checksum: ${md5}"
 		fi
 	fi
 }
@@ -51,7 +53,7 @@ fn_dl_extract(){
 	extractdir="${3}"
 	# extracts archives
 	echo -ne "extracting ${filename}..."
-	fn_scriptlog "extracting download"
+	fn_script_log_info "Extracting download"
 	mime=$(file -b --mime-type "${filedir}/${filename}")
 
 	if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then
@@ -62,26 +64,26 @@ fn_dl_extract(){
 	local exitcode=$?
 	if [ ${exitcode} -ne 0 ]; then
 		fn_print_fail_eol_nl
-		fn_scriptlog "extracting download: FAIL"
+		fn_script_log_fatal "Extracting download: FAIL"
 		echo "${tarcmd}" | tee -a "${scriptlog}"
-		exit ${exitcode}
+		core_exit.sh
 	else
 		fn_print_ok_eol_nl
 	fi
 }
 
 # Trap to remove file download if canceled before completed
-fn_fetch_trap() {
+fn_fetch_trap(){
 	echo ""
 	echo -ne "downloading ${filename}: "
 	fn_print_canceled_eol_nl
-	fn_scriptlog "downloading ${filename}: CANCELED"
+	fn_script_log_info "downloading ${filename}: CANCELED"
 	sleep 1
 	rm -f "${filedir}/${filename}" | tee -a "${scriptlog}"
 	echo -ne "downloading ${filename}: "
 	fn_print_removed_eol_nl
-	fn_scriptlog "downloading ${filename}: REMOVED"
-	exit
+	fn_script_log_info "downloading ${filename}: REMOVED"
+	core_exit.sh
 }
 
 fn_fetch_file(){
@@ -125,15 +127,15 @@ fn_fetch_file(){
 			if [ ${exitcode} -ne 0 ]; then
 				fn_print_fail_eol_nl
 				if [ -f "${scriptlog}" ]; then
-					fn_scriptlog "downloading ${filename}: FAIL"
+					fn_script_log_fatal "downloading ${filename}: FAIL"
 				fi
 				echo "${curlcmd}" | tee -a "${scriptlog}"
 				echo -e "${fileurl}\n" | tee -a "${scriptlog}"
-				exit ${exitcode}
+				core_exit.sh
 			else
 				fn_print_ok_eol_nl
 				if [ -f "${scriptlog}" ]; then
-					fn_scriptlog "downloading ${filename}: OK"
+					fn_script_log_pass "downloading ${filename}: OK"
 				fi
 			fi
 			# remove trap
@@ -142,7 +144,10 @@ fn_fetch_file(){
 			fn_print_fail_eol_nl
 			echo "Curl is not installed!"
 			echo -e ""
-			exit 1
+			if [ -f "${scriptlog}" ]; then
+				fn_script_log_fatal "Curl is not installed!"
+			fi
+			core_exit.sh
 		fi
 		# make file executecmd if executecmd is set
 		if [ "${executecmd}" == "executecmd" ]; then
@@ -199,4 +204,18 @@ fn_fetch_function(){
 	force="noforce"
 	md5="nomd5"
 	fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
+}
+
+fn_update_function(){
+	github_file_url_dir="lgsm/functions" # github dir containing the file
+	github_file_url_name="${functionfile}" # name of the github file
+	githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
+	fileurl="${githuburl}"
+	filedir="${functionsdir}"
+	filename="${github_file_url_name}"
+	executecmd="executecmd"
+	run="norun"
+	force="noforce"
+	md5="nomd5"
+	fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
 }

+ 38 - 0
lgsm/functions/core_exit.sh

@@ -0,0 +1,38 @@
+#!/bin/bash
+# LGSM core_exit.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: handles exiting of LGSM by running and reporting an exit code.
+
+fn_exit_dev_debug(){
+	if [ -f "${rootdir}/.dev-debug" ]; then
+		echo ""
+		echo "${function_selfname} exiting with code: ${exitcode}"
+	fi
+}
+
+if [ -n "${exitbypass}" ]; then
+	unset exitbypass
+elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then
+	if [ "${exitcode}" == "1" ]; then
+		fn_script_log_fatal "${function_selfname} exiting with code: ${exitcode}"
+	elif [ "${exitcode}" == "2" ]; then
+		fn_script_log_error "${function_selfname} exiting with code: ${exitcode}"
+	elif [ "${exitcode}" == "3" ]; then
+		fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}"
+	else
+		fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}"
+	fi
+	fn_exit_dev_debug
+	# remove trap.
+	trap - INT
+	exit ${exitcode}
+else
+	exitcode=0
+	fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}"
+	fn_exit_dev_debug
+	# remove trap.
+	trap - INT
+	exit ${exitcode}
+fi
+

+ 29 - 19
lgsm/functions/core_functions.sh

@@ -2,10 +2,8 @@
 # LGSM core_functions.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Defines all functions to allow download and execution of functions using fn_fetch_function.
-# This function is called first before any other function. Without this file other functions would not load.
+# This function is called first before any other function. Without this file other functions will not load.
 
 # Code/functions for legacy servers
 
@@ -51,15 +49,15 @@ if [ ! -f "${filedir}/${filename}" ]; then
 	if [ "$(basename ${curlcmd})" == "curl" ]; then
 		curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
 		if [ $? -ne 0 ]; then
-			echo -e "\e[0;31mFAIL\e[0m\n"
+			echo -e "${red}FAIL${default}\n"
 			echo "${curlfetch}"
 			echo -e "${githuburl}\n"
 			exit 1
 		else
-			echo -e "\e[0;32mOK\e[0m"
+			echo -e "${green}OK${default}"
 		fi
 	else
-		echo -e "\e[0;31mFAIL\e[0m\n"
+		echo -e "${red}FAIL${default}\n"
 		echo "Curl is not installed!"
 		echo -e ""
 		exit 1
@@ -78,17 +76,22 @@ functionfile="${FUNCNAME}"
 fn_fetch_core_dl
 }
 
+core_exit.sh(){
+functionfile="${FUNCNAME}"
+fn_fetch_core_dl
+}
+
 core_getopt.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_core_dl
 }
 
-core_messages.sh(){
+core_trap.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_core_dl
 }
 
-core_dl.sh(){
+core_messages.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_core_dl
 }
@@ -156,14 +159,9 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
-fn_restart(){
-local modulename="Restarting"
-info_config.sh
-if [ -d "${scriptlogdir}" ]; then
-	fn_scriptlog "${servername}"
-fi
-command_stop.sh
-command_start.sh
+command_restart.sh(){
+functionfile="${FUNCNAME}"
+fn_fetch_function
 }
 
 
@@ -224,6 +222,11 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
+check_system_requirements.sh(){
+functionfile="${FUNCNAME}"
+fn_fetch_function
+}
+
 check_tmux.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_function
@@ -367,17 +370,22 @@ fn_fetch_function
 
 # Update
 
-update_check.sh(){
+command_update_functions.sh(){
+functionfile="${FUNCNAME}"
+fn_fetch_function
+}
+
+command_update.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
-command_update_functions.sh(){
+update_ts3.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
-update_dl.sh(){
+update_steamcmd.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_function
 }
@@ -476,6 +484,8 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
+# Calls the global Ctrl-C trap
+core_trap.sh
 
 # Calls on-screen messages
 core_messages.sh

+ 152 - 130
lgsm/functions/core_getopt.sh

@@ -2,23 +2,23 @@
 # LGSM core_getopt.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: getopt arguments.
 
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 fn_getopt_generic(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	u|update)
-		update_check.sh;;
+		command_update.sh;;
 	fu|force-update|update-restart)
 		forceupdate=1;
-		update_check.sh;;
+		command_update.sh;;
 	uf|update-functions)
 		command_update_functions.sh;;
 	v|validate)
@@ -44,42 +44,45 @@ case "$getopt" in
 	dd|depsdetect)
 		command_dev_detect_deps.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate\t\e[0mu  |Checks and applies updates from SteamCMD."
-		echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mvalidate\t\e[0mv  |Validate server files with SteamCMD."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34mconsole\t\e[0mc  |Console allows you to access the live view of a server."
-		echo -e "\e[34mdebug\t\e[0md  |See the output of the server directly to your terminal."
-		echo -e "\e[34minstall\t\e[0mi  |Install the server."
-		echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update\t${default}u  |Checks and applies updates from SteamCMD."
+		echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}validate\t${default}v  |Validate server files with SteamCMD."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}console\t${default}c  |Console allows you to access the live view of a server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
+		echo -e "${blue}install\t${default}i  |Install the server."
+		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 fn_getopt_teamspeak3(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	u|update)
-		update_check.sh;;
+		command_update.sh;;
 	uf|update-functions)
 		command_update_functions.sh;;
 	m|monitor)
@@ -101,37 +104,40 @@ case "$getopt" in
 	dd|depsdetect)
 		command_dev_detect_deps.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate\t\e[0mu  |Checks and applies updates from SteamCMD."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
-		echo -e "\e[34mchange-password\t\e[0mpw |Changes TS3 serveradmin password."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34minstall\t\e[0mi  |Install the server."
-		echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update\t${default}u  |Checks and applies updates from SteamCMD."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
+		echo -e "${blue}change-password\t${default}pw |Changes TS3 serveradmin password."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}install\t${default}i  |Install the server."
+		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 fn_getopt_mumble(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	uf|update-functions)
 		command_update_functions.sh;;
 	m|monitor)
@@ -149,36 +155,39 @@ case "$getopt" in
 	dd|depsdetect)
 		command_dev_detect_deps.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34mconsole\t\e[0mc  |Console allows you to access the live view of a server."
-		echo -e "\e[34mdebug\t\e[0md  |See the output of the server directly to your terminal."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}console\t${default}c  |Console allows you to access the live view of a server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 fn_getopt_gmodserver(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	u|update)
-		update_check.sh;;
+		command_update.sh;;
 	fu|force-update|update-restart)
 		forceupdate=1;
 		update_check.sh;;
@@ -209,41 +218,44 @@ case "$getopt" in
 	fd|fastdl)
 		command_fastdl.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
-		echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mvalidate\t\e[0mv  |Validate server files with SteamCMD."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34mconsole\t\e[0mc  |Console allows you to access the live view of a server."
-		echo -e "\e[34mdebug\t\e[0md  |See the output of the server directly to your terminal."
-		echo -e "\e[34minstall\t\e[0mi  |Install the server."
-		echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
-		echo -e "\e[34mfastdl\t\e[0mfd |Generates or update a FastDL folder for your server."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
+		echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}validate\t${default}v  |Validate server files with SteamCMD."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}console\t${default}c  |Console allows you to access the live view of a server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
+		echo -e "${blue}install\t${default}i  |Install the server."
+		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
+		echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 fn_getopt_unreal(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	uf|update-functions)
 		command_update_functions.sh;;
 	m|monitor)
@@ -269,41 +281,44 @@ case "$getopt" in
 	dd|depsdetect)
 		command_dev_detect_deps.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34mconsole\t\e[0mc  |Console allows you to access the live view of a server."
-		echo -e "\e[34mdebug\t\e[0md  |See the output of the server directly to your terminal."
-		echo -e "\e[34minstall\t\e[0mi  |Install the server."
-		echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
-		echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}console\t${default}c  |Console allows you to access the live view of a server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
+		echo -e "${blue}install\t${default}i  |Install the server."
+		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
+		echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 
 fn_getopt_unreal2(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	u|update)
-		update_check.sh;;
+		command_update.sh;;
 	fu|force-update|update-restart)
 		forceupdate=1;
 		update_check.sh;;
@@ -334,42 +349,45 @@ case "$getopt" in
 	mc|map-compressor)
 		compress_unreal2_maps.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
-		echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mvalidate\t\e[0mv  |Validate server files with SteamCMD."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34mconsole\t\e[0mc  |Console allows you to access the live view of a server."
-		echo -e "\e[34mdebug\t\e[0md  |See the output of the server directly to your terminal."
-		echo -e "\e[34minstall\t\e[0mi  |Install the server."
-		echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
-		echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
+		echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}validate\t${default}v  |Validate server files with SteamCMD."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}console\t${default}c  |Console allows you to access the live view of a server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
+		echo -e "${blue}install\t${default}i  |Install the server."
+		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
+		echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 
 fn_getopt_ut2k4(){
-case "$getopt" in
+case "${getopt}" in
 	st|start)
 		command_start.sh;;
 	sp|stop)
 		command_stop.sh;;
 	r|restart)
-		fn_restart;;
+		command_restart.sh;;
 	uf|update-functions)
 		command_update_functions.sh;;
 	m|monitor)
@@ -397,29 +415,32 @@ case "$getopt" in
 	dd|depsdetect)
 		command_dev_detect_deps.sh;;
 	*)
+	if [ -n "${getopt}" ]; then
+		echo -e "${red}Unknown command${default}: $0 ${getopt}"
+		exitcode=2
+	fi
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "https://gameservermanagers.com/${selfname}"
 	echo -e ""
-	echo -e "\e[93mCommands\e[0m"
+	echo -e "${lightyellow}Commands${default}"
 	{
-		echo -e "\e[34mstart\t\e[0mst |Start the server."
-		echo -e "\e[34mstop\t\e[0msp |Stop the server."
-		echo -e "\e[34mrestart\t\e[0mr  |Restart the server."
-		echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
-		echo -e "\e[34mmonitor\t\e[0mm  |Checks that the server is running."
-		echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
-		echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
-		echo -e "\e[34mbackup\t\e[0mb  |Create archive of the server."
-		echo -e "\e[34mconsole\t\e[0mc  |Console allows you to access the live view of a server."
-		echo -e "\e[34mdebug\t\e[0md  |See the output of the server directly to your terminal."
-		echo -e "\e[34minstall\t\e[0mi  |Install the server."
-		echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
-		echo -e "\e[34mserver-cd-key\t\e[0mcd |Add your server cd key"
-		echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps."
+		echo -e "${blue}start\t${default}st |Start the server."
+		echo -e "${blue}stop\t${default}sp |Stop the server."
+		echo -e "${blue}restart\t${default}r  |Restart the server."
+		echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
+		echo -e "${blue}monitor\t${default}m  |Checks that the server is running."
+		echo -e "${blue}test-alert\t${default}ta |Sends test alert."
+		echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
+		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}console\t${default}c  |Console allows you to access the live view of a server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
+		echo -e "${blue}install\t${default}i  |Install the server."
+		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
+		echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key"
+		echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
 	} | column -s $'\t' -t
 	esac
-exit
 }
 
 if [ "${gamename}" == "Mumble" ]; then
@@ -439,3 +460,4 @@ elif [ "${engine}" == "unreal" ]; then
 else
 	fn_getopt_generic
 fi
+core_exit.sh

+ 211 - 84
lgsm/functions/core_messages.sh

@@ -1,204 +1,331 @@
 #!/bin/bash
-# LGSM fn_messages function
+# LGSM core_messages.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Defines on-screen messages such as [  OK  ] and how script logs look.
 
 # nl: new line: message is following by a new line
 # eol: end of line: message is placed at the end of the current line
 
-# Date, servicename & module details displayed in log files.
-# e.g Feb 28 14:56:58 ut99-server: Monitor:
-fn_scriptlog(){
-	if [ -n "${modulename}" ]; then
-		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}"
+if [ "${ansi}" != "off" ]; then
+	# echo colors
+	default="\e[0m"
+	red="\e[31m"
+	green="\e[32m"
+	yellow="\e[33m"
+	blue="\e[34m"
+	magenta="\e[35m"
+	cyan="\e[36m"
+	lightyellow="\e[93m"
+	# carriage return & erase to end of line
+	creeol="\r\033[K"
+fi
+
+# Log display
+##########
+## Feb 28 14:56:58 ut99-server: Monitor:
+fn_script_log(){
+	if [ -n "${commandname}" ]; then
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandname}: ${1}" >> "${scriptlog}"
 	else
 		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
 	fi
 }
 
-# [ FAIL ]
-fn_print_fail(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@"
+## Feb 28 14:56:58 ut99-server: Monitor: PASS:
+fn_script_log_pass(){
+	if [ -n "${commandname}" ]; then
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandname}: PASS: ${1}" >> "${scriptlog}"
 	else
-		echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: PASS: ${1}" >> "${scriptlog}"
 	fi
+	exitcode=0
 }
 
-fn_print_fail_nl(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@"
+## Feb 28 14:56:58 ut99-server: Monitor: FATAL:
+fn_script_log_fatal(){
+	if [ -n "${commandname}" ]; then
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandname}: FATAL: ${1}" >> "${scriptlog}"
+	else
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: FATAL: ${1}" >> "${scriptlog}"
+	fi
+	exitcode=1
+}
+
+## Feb 28 14:56:58 ut99-server: Monitor: ERROR:
+fn_script_log_error(){
+	if [ -n "${commandname}" ]; then
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandname}: ERROR: ${1}" >> "${scriptlog}"
+	else
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ERROR: ${1}" >> "${scriptlog}"
+	fi
+	exitcode=2
+}
+
+## Feb 28 14:56:58 ut99-server: Monitor: WARN:
+fn_script_log_warn(){
+	if [ -n "${commandname}" ]; then
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandname}: WARN: ${1}" >> "${scriptlog}"
+	else
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: WARN: ${1}" >> "${scriptlog}"
+	fi
+	exitcode=3
+}
+
+## Feb 28 14:56:58 ut99-server: Monitor: INFO:
+fn_script_log_info(){
+	if [ -n "${commandname}" ]; then
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandname}: INFO: ${1}" >> "${scriptlog}"
+	else
+		echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: INFO: ${1}" >> "${scriptlog}"
+	fi
+}
+
+# On-Screen
+##########
+
+# [ .... ]
+fn_print_dots(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[ .... ] ${commandaction} ${servicename}: $@"
+	else
+		echo -en "${creeol}[ .... ] $@"
+	fi
+}
+
+fn_print_dots_nl(){
+	if [ -n "${commandaction}" ]; then
+		echo -e "${creeol}[ .... ] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
+		echo -e "${creeol}[ .... ] $@"
 	fi
-	sleep 1
+	sleep 0.5
 	echo -en "\n"
 }
 
 # [  OK  ]
 fn_print_ok(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[0;32m  OK  \e[0m] ${modulename} ${servicename}: $@"
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${green}  OK  ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[0;32m  OK  \e[0m] $@"
+		echo -en "${creeol}[${green}  OK  ${default}] $@"
 	fi
 }
 
 fn_print_ok_nl(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[0;32m  OK  \e[0m] ${modulename} ${servicename}: $@"
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${green}  OK  ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[0;32m  OK  \e[0m] $@"
+		echo -en "${creeol}[${green}  OK  ${default}] $@"
 	fi
-	sleep 1
+	sleep 0.5
 	echo -en "\n"
 }
 
-# [ INFO ]
-fn_print_info(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@"
+# [ FAIL ]
+fn_print_fail(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@"
+		echo -en "${creeol}[${red} FAIL ${default}] $@"
 	fi
 }
 
-fn_print_info_nl(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@"
+fn_print_fail_nl(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $@"
+	else
+		echo -en "${creeol}[${red} FAIL ${default}] $@"
+	fi
+	sleep 0.5
+	echo -en "\n"
+}
+
+# [ ERROR ]
+fn_print_error(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $@"
+	else
+		echo -en "${creeol}[${red}ERROR ${default}] $@"
+	fi
+}
+
+fn_print_error_nl(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@"
+		echo -en "${creeol}[${red}ERROR ${default}] $@"
 	fi
-	sleep 1
+	sleep 0.5
 	echo -en "\n"
 }
 
 # [ WARN ]
 fn_print_warn(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@"
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@"
+		echo -en "${creeol}[${yellow} WARN ${default}] $@"
 	fi
 }
 
 fn_print_warn_nl(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@"
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@"
+		echo -en "${creeol}[${yellow} WARN ${default}] $@"
 	fi
-	sleep 1
+	sleep 0.5
 	echo -en "\n"
 }
 
-# [ .... ]
-fn_print_dots(){
-	if [ -n "${modulename}" ]; then
-		echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@"
+# [ INFO ]
+fn_print_info(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@"
 	else
-		echo -en "\r\033[K[ .... ] $@"
+		echo -en "${creeol}[${cyan} INFO ${default}] $@"
 	fi
 }
 
-# Complete!
-fn_print_complete(){
-	echo -en "\e[0;32mComplete!\e[0m $@"
+fn_print_info_nl(){
+	if [ -n "${commandaction}" ]; then
+		echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@"
+	else
+		echo -en "${creeol}[${cyan} INFO ${default}] $@"
+	fi
+	sleep 0.5
+	echo -en "\n"
 }
 
-fn_print_complete_nl(){
-	echo -e "\e[0;32mComplete!\e[0m $@"
-}
+# On-Screen full word
+##########
 
-# Warning!
-fn_print_warning(){
-	echo -en "\e[0;33mWarning!\e[0m $@"
+# Complete!
+fn_print_complete(){
+	echo -en "${green}Complete!${default} $@"
 }
 
-fn_print_warning_nl(){
-	echo -e "\e[0;33mWarning!\e[0m $@"
+fn_print_complete_nl(){
+	echo -e "${green}Complete!${default} $@"
 }
 
 # Failure!
 fn_print_failure(){
-	echo -en "\e[0;31mFailure!\e[0m $@"
+	echo -en "${red}Failure!${default} $@"
 }
 
 fn_print_failure_nl(){
-	echo -e "\e[0;31mFailure!\e[0m $@"
+	echo -e "${red}Failure!${default} $@"
 }
 
 # Error!
-fn_print_error(){
-	echo -en "\e[0;31mError!\e[0m $@"
+fn_print_error2(){
+	echo -en "${red}Error!${default} $@"
 }
 
-fn_print_error_nl(){
-	echo -e "\e[0;31mError!\e[0m $@"
+fn_print_error2_nl(){
+	echo -e "${red}Error!${default} $@"
+}
+
+# Warning!
+fn_print_warning(){
+	echo -en "${yellow}Warning!${default} $@"
+}
+
+fn_print_warning_nl(){
+	echo -e "${yellow}Warning!${default} $@"
 }
 
 # Infomation!
 fn_print_infomation(){
-	echo -en "\e[0;36mInfomation!\e[0m $@"
+	echo -en "${cyan}Infomation!${default} $@"
 }
 
 fn_print_infomation_nl(){
-	echo -e "\e[0;36mInfomation!\e[0m $@"
+	echo -e "${cyan}Infomation!${default} $@"
 }
 
-# FAIL for end of line
+# On-Screen End of Line
+##########
+
+# OK
 fn_print_ok_eol(){
-	echo -en "\e[0;32mOK\e[0m"
+	echo -en "${green}OK${default}"
 }
 
 fn_print_ok_eol_nl(){
-	echo -e "\e[0;32mOK\e[0m"
+	echo -e "${green}OK${default}"
 }
 
-# FAIL for end of line
+# FAIL
 fn_print_fail_eol(){
-	echo -en "\e[0;31mFAIL\e[0m"
+	echo -en "${red}FAIL${default}"
 }
 
 fn_print_fail_eol_nl(){
-	echo -e "\e[0;31mFAIL\e[0m"
+	echo -e "${red}FAIL${default}"
+}
+
+# WARN
+fn_print_warn_eol(){
+	echo -en "${red}FAIL${default}"
 }
 
-# QUERYING for end of line
+fn_print_warn_eol_nl(){
+	echo -e "${red}FAIL${default}"
+}
+
+# INFO
+fn_print_info_eol(){
+	echo -en "${red}FAIL${default}"
+}
+
+fn_print_info_eol_nl(){
+	echo -e "${red}FAIL${default}"
+}
+
+# QUERYING
 fn_print_querying_eol(){
-	echo -en "\e[0;36mQUERYING\e[0m"
+	echo -en "${cyan}QUERYING${default}"
 }
 
 fn_print_querying_eol_nl(){
-	echo -e "\e[0;36mQUERYING\e[0m"
+	echo -e "${cyan}QUERYING${default}"
 }
 
-# CHECKING for end of line
+# CHECKING
 fn_print_checking_eol(){
-	echo -en "\e[0;36mCHECKING\e[0m"
+	echo -en "${cyan}CHECKING${default}"
 }
 
 fn_print_checking_eol_nl(){
-	echo -e "\e[0;36mCHECKING\e[0m"
+	echo -e "${cyan}CHECKING${default}"
 }
 
-# CANCELED for end of line
+# CANCELED
 fn_print_canceled_eol(){
-	echo -en "\e[0;33mCANCELED\e[0m"
+	echo -en "${yellow}CANCELED${default}"
 }
 
 fn_print_canceled_eol_nl(){
-	echo -e "\e[0;33mCANCELED\e[0m"
+	echo -e "${yellow}CANCELED${default}"
 }
 
-# REMOVED for end of line
+# REMOVED
 fn_print_removed_eol(){
-	echo -en "\e[0;31mREMOVED\e[0m"
+	echo -en "${red}REMOVED${default}"
 }
 
 fn_print_removed_eol_nl(){
-	echo -e "\e[0;31mREMOVED\e[0m"
+	echo -e "${red}REMOVED${default}"
+}
+
+# UPDATE
+fn_print_update_eol(){
+	echo -en "${cyan}UPDATE${default}"
+}
+
+fn_print_update_eol_nl(){
+	echo -e "${cyan}UPDATE${default}"
 }

+ 13 - 0
lgsm/functions/core_trap.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+# LGSM core_trap.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: handles ctrl-C trap to give an exitcode.
+
+fn_exit_trap(){
+	echo ""
+	core_exit.sh
+}
+
+# trap to give an exitcode.
+trap fn_exit_trap INT

+ 8 - 6
lgsm/functions/fix.sh

@@ -2,27 +2,29 @@
 # LGSM fix.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Overall function for managing fixes.
 # Runs functions that will fix an issue.
 
+local commandname="FIX"
+local commandaction="Fix"
+
 # Messages that are displayed for some fixes
 fn_fix_msg_start(){
 	fn_print_dots "Applying ${fixname} fix: ${gamename}"
 	sleep 1
 	fn_print_info "Applying ${fixname} fix: ${gamename}"
-	fn_scriptlog "Applying ${fixname} fix: ${gamename}"
+	fn_script_log_info "Applying ${fixname} fix: ${gamename}"
 	sleep 1
 }
 
 fn_fix_msg_end(){
 	if [ $? -ne 0 ]; then
-		fn_print_fail_nl "Applying ${fixname} fix: ${gamename}"
-		fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}"
+		fn_print_error_nl "Applying ${fixname} fix: ${gamename}"
+		fn_script_log_error "Applying ${fixname} fix: ${gamename}"
+		exitcode=2
 	else
 		fn_print_ok_nl "Applying ${fixname} fix: ${gamename}"
-		fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}"
+		fn_script_log_pass "Applying ${fixname} fix: ${gamename}"
 	fi
 }
 

+ 5 - 1
lgsm/functions/fix_arma3.sh

@@ -2,7 +2,11 @@
 # LGSM fix_arma3.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="240516"
+# Description: Resolves an issue with ARMA3.
+
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 # Fixes: 20150 Segmentation fault (core dumped) error.
 if [ ! -d "${HOME}/.local/share/Arma 3" ]||[ ! -d "${HOME}/.local/share/Arma 3 - Other Profiles" ]; then

+ 4 - 2
lgsm/functions/fix_csgo.sh

@@ -2,10 +2,12 @@
 # LGSM fix_csgo.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Resolves various issues with csgo.
 
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 # Fixes: server not always creating steam_appid.txt file.
 if [ ! -f "${filesdir}/steam_appid.txt" ]; then
 	fixname="730 steam_appid.txt"

+ 4 - 2
lgsm/functions/fix_dst.sh

@@ -2,10 +2,12 @@
 # LGSM fix_dst.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Resolves various issues with Dont Starve together.
 
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer)
 # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS.
 if [ -f "/etc/redhat-release" ] && [ ! -f "${filesdir}/bin/lib32/libcurl-gnutls.so.4" ]; then

+ 4 - 2
lgsm/functions/fix_glibc.sh

@@ -2,10 +2,12 @@
 # LGSM fix_glibc.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Downloads required glibc files and applys teh glibc fix if required
 
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" )
 for libstdc_server in "${libstdc_servers_array[@]}"
 do

+ 7 - 6
lgsm/functions/fix_ins.sh

@@ -2,18 +2,19 @@
 # LGSM fix_ins.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Resolves various issues with Insurgency.
 
-# Resolves ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory
+local commandname="FIX"
+local commandaction="Fix"
+
+# Fixes: ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory.
 
 export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH}
 
-# fix for issue #529 - gamemode not passed to debug or start
+# Fixes: issue #529 - gamemode not passed to debug or start.
 
 if [ "${function_selfname}" == "command_debug.sh" ]; then
-        defaultmap="\"${defaultmap}\""
+	defaultmap="\"${defaultmap}\""
 else
-        defaultmap="\\\"${defaultmap}\\\""
+	defaultmap="\\\"${defaultmap}\\\""
 fi

+ 5 - 1
lgsm/functions/fix_kf.sh

@@ -2,7 +2,11 @@
 # LGSM fix_kf.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Resolves various issues with Killing Floor.
+
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 echo "Applying WebAdmin ROOst.css fix."
 echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

+ 4 - 2
lgsm/functions/fix_ro.sh

@@ -2,9 +2,11 @@
 # LGSM fix_ro.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Resolves various issues with Red Orchestra.
 
-# Description: Resolves various issues with red orchestra.
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 echo "Applying WebAdmin ROOst.css fix."
 echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

+ 4 - 2
lgsm/functions/fix_steamcmd.sh

@@ -2,9 +2,11 @@
 # LGSM fix_steamcmd.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Resolves various issues related to steamCMD.
 
-# Description: fixes various issues related to steamCMD.
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so.
 if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then

+ 4 - 2
lgsm/functions/fix_ut2k4.sh

@@ -2,9 +2,11 @@
 # LGSM fix_ut2k4.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Resolves various issues with Unreal Tournament 2004.
 
-# Description: Resolves various issues with unreal tournament 2004.
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 echo "applying WebAdmin ut2003.css fix."
 echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

+ 6 - 1
lgsm/functions/fix_ut99.sh

@@ -2,7 +2,12 @@
 # LGSM fix_ut99.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Resolves various issues with Unreal Tournament 99.
+
+local commandname="FIX"
+local commandaction="Fix"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 echo "${servercfgfullpath}"
 echo "enabling UdpServerUplink."
 {

+ 1 - 1
lgsm/functions/fn_functions

@@ -1,5 +1,5 @@
 #!/bin/bash
-# LGSM core_functions.sh function
+# LGSM fn_functions function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
 lgsm_version="210516"

+ 1 - 1
lgsm/functions/fn_getopt

@@ -1,5 +1,5 @@
 #!/bin/bash
-# LGSM core_getopt.sh function
+# LGSM fn_getopt function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
 lgsm_version="210516"

+ 3 - 4
lgsm/functions/fn_update_functions

@@ -1,5 +1,5 @@
 #!/bin/bash
-# LGSM fn_update_functions.sh function
+# LGSM fn_update_functions function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
 lgsm_version="210516"
@@ -7,16 +7,15 @@ lgsm_version="210516"
 # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub.
 
 fn_print_dots "Updating functions"
-fn_scriptlog "Updating functions"
 sleep 1
 echo -ne "\n"
 rm -rfv "${rootdir}/functions/"*
 exitcode=$?
 if [ "${exitcode}" == "0" ]; then
 	fn_print_ok "Updating functions"
-	fn_scriptlog "Success! Updating functions"
+	fn_script_log "Success! Updating functions"
 else
 	fn_print_fail "Updating functions"
-	fn_scriptlog "Failure! Updating functions"
+	fn_script_log "Failure! Updating functions"
 fi
 echo -ne "\n"

+ 2 - 2
lgsm/functions/gsquery.py

@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 # Game Server Query
 # Author: Anonymous & Daniel Gibbs
-# # Website: https://gameservermanagers.com
-# Version: 190216
+# Website: https://gameservermanagers.com
+# Description: Handles querying of .
 
 import optparse
 import socket

+ 85 - 5
lgsm/functions/info_config.sh

@@ -2,18 +2,18 @@
 # LGSM info_config.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Gets specific details from config files.
 
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 ## Examples of filtering to get info from config files
 # sed 's/foo//g' - remove foo
 # tr -cd '[:digit:]' leave only digits
 # tr -d '=\"; ' remove selected charectors =\";
 # grep -v "foo" filter out lines that contain foo
 
-unavailable="\e[0;31mUNAVAILABLE\e[0m"
-zero="\e[0;31m0\e[0m"
+unavailable="${red}UNAVAILABLE${default}"
+zero="${red}0${default}"
 
 fn_info_config_avalanche(){
 	if [ ! -f "${servercfgfullpath}" ]; then
@@ -161,6 +161,32 @@ fn_info_config_source(){
 	fi
 }
 
+fn_info_config_starbound(){
+	if [ ! -f "${servercfgfullpath}" ]; then
+		servername="${unavailable}"
+		rconpassword="${unavailable}"
+		port="21025"
+		queryport="21025"
+		rconport="21026"
+		slots="8"
+	else
+		servername=$(grep "serverName" "${servercfgfullpath}" | sed 's/"serverName" \: //g' | grep -oP '"\K[^"]+(?=["])')
+		rconpassword=$(grep "rconServerPassword" "${servercfgfullpath}" | sed 's/"rconServerPassword" \: //g' | grep -oP '"\K[^"]+(?=["])')
+		port=$(grep "gameServerPort" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		queryport=$(grep "queryServerPort" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		rconport=$(grep "rconServerPort" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		slots=$(grep "maxPlayers" "${servercfgfullpath}" | tr -cd '[:digit:]')
+
+		# Not Set
+		servername=${servername:-"NOT SET"}
+		rconpassword=${rconpassword:-"NOT SET"}
+		port=${port:-"21025"}
+		queryport=${queryport:-"21025"}
+		rconport=${rconport:-"21026"}
+		slots=${slots:-"8"}
+	fi
+}
+
 fn_info_config_teamspeak3(){
 	if [ ! -f "${servercfgfullpath}" ]; then
 		dbplugin="${unavailable}"
@@ -267,7 +293,55 @@ fn_info_config_unreal(){
 		webadminpass=${webadminpass:-"NOT SET"}
 	fi
 }
+ 
+fn_info_config_sdtd(){
+	if [ ! -f "${servercfgfullpath}" ]; then
+		servername="${unavailable}"
+		serverpassword="${unavailable}"
+		port="${zero}"
+		queryport="${zero}"
+		webadminenabled="${unavailable}"
+		webadminport="${zero}"
+		webadminpass="${unavailable}"
+		telnetenabled="${unavailable}"
+		telnetport="${zero}"
+		telnetpass="${unavailable}"
+		slots="${unavailable}"
+		gamemode="${unavailable}"
+		gameworld="${unavailable}"
+	else
+		servername=$(grep "ServerName" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+		serverpassword=$(grep "ServerPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+		port=$(grep "ServerPort" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		queryport=$((port + 1))
 
+		webadminenabled=$(grep "ControlPanelEnabled" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+		webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd '[:digit:]')		
+		webadminpass=$(grep "ControlPanelPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+		telnetenabled=$(grep "TelnetEnabled" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+		telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		telnetpass=$(grep "TelnetPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+
+		slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		gamemode=$(grep "GameMode" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+		gameworld=$(grep "GameWorld" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"")
+
+		# Not Set
+		servername=${servername:-"NOT SET"}
+		serverpassword=${serverpassword:-"NOT SET"}
+		port=${port:-"0"}
+		queryport=${queryport:-"0"}
+		webadminenabled=${webadminenabled:-"NOT SET"}
+		webadminport=${webadminport:-"0"}
+		webadminpass=${webadminpass:-"NOT SET"}
+		telnetenabled=${telnetenabled:-"NOT SET"}
+		telnetport=${telnetport:-"0"}
+		telnetpass=${telnetpass:-"NOT SET"}
+		slots=${slots:-"NOT SET"}
+		gamemode=${gamemode:-"NOT SET"}
+		gameworld=${gameworld:-"NOT SET"}
+	fi
+}
 ## Just Cause 2
 if [ "${engine}" == "avalanche" ]; then
 	fn_info_config_avalanche
@@ -289,6 +363,9 @@ elif [ "${engine}" == "seriousengine35" ]; then
 # Source Engine Games
 elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 	fn_info_config_source
+# Starbound
+elif [ "${engine}" == "starbound" ]; then
+	fn_info_config_starbound
 elif [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_info_config_teamspeak3
 # Teeworlds
@@ -300,4 +377,7 @@ elif [ "${engine}" == "terraria" ]; then
 # Unreal/Unreal 2 engine
 elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
 	fn_info_config_unreal
-fi
+# 7 Day To Die (unity3d)
+elif [ "${gamename}" == "7 Days To Die" ]; then
+	fn_info_config_sdtd
+fi

+ 54 - 33
lgsm/functions/info_distro.sh

@@ -2,86 +2,107 @@
 # LGSM info_distro.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Variables providing useful info on the Operating System such as disk and performace info.
-# Used for command_details.sh, command_debug.sh and email.sh.
+# Used for command_details.sh, command_debug.sh and alert.sh.
+
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+### Distro infomation
 
-## Distro infomation
+## Distro
 # Returns architecture, kernel and distro/os.
 arch=$(uname -m)
 kernel=$(uname -r)
 if [ -n "$(command -v lsb_release)" ]; then
 	os=$(lsb_release -s -d)
-elif [ -f /etc/debian_version ]; then
+elif [ -f "/etc/debian_version" ]; then
 	os="Debian $(cat /etc/debian_version)"
-elif [ -f /etc/redhat-release ]; then
+elif [ -f "/etc/redhat-release" ]; then
 	os=$(cat /etc/redhat-release)
 else
 	os="$(uname -s) $(uname -r)"
 fi
 
-# Glibc version number
+## Glibc version
 # e.g: 1.17
 glibcversion="$(ldd --version | sed -n '1s/.* //p')"
 
-# tmux version
+## tmux version
 # e.g: tmux 1.6
 if [ -z "$(command -v tmux)" ]; then
-	tmuxv="\e[0;31mNOT INSTALLED!\e[0m"
+	tmuxv="${red}NOT INSTALLED!${default}"
 elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then
 	tmuxv="$(tmux -V) (>= 1.6 required for console log)"
 else
 	tmuxv=$(tmux -V)
 fi
 
-## Performance
+## Uptime
+uptime=$(</proc/uptime)
+uptime=${uptime/[. ]*/}
+minutes=$(( uptime/60%60 ))
+hours=$(( uptime/60/60%24 ))
+days=$(( uptime/60/60/24 ))
+
 
-# Average server load
+### Performance infomation
+
+## Average server load
 load=$(uptime|awk -F 'load average: ' '{ print $2 }')
 
-# Memory
+## Memory Infomation
+# Available RAM and swap.
 
 # Older versions of free do not support -h option.
 if [ "$(free -h > /dev/null 2>&1; echo $?)" -ne "0" ]; then
-	option="-m"
+	humanreadable="-m"
 else
-	option="-h"
+	humanreadable="-h"
 fi
-physmemtotal=$(free ${option} | awk '/Mem:/ {print $2}')
-physmemused=$(free ${option} | awk '/Mem:/ {print $3}')
-physmemfree=$(free ${option} | awk '/Mem:/ {print $4}')
-swaptotal=$(free ${option} | awk '/Swap:/ {print $2}')
-swapused=$(free ${option} | awk '/Swap:/ {print $3}')
-swapfree=$(free ${option} | awk '/Swap:/ {print $4}')
-
-# Uptime
-uptime=$(</proc/uptime)
-uptime=${uptime/[. ]*/}
-minutes=$(( uptime/60%60 ))
-hours=$(( uptime/60/60%24 ))
-days=$(( uptime/60/60/24 ))
 
-# Disk usage
-# available space on the partition.
+physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}')
+physmemtotalmb=$(free -m | awk '/Mem:/ {print $2}')
+physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}')
+physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}')
+physmemcached=$(free ${humanreadable} | awk '/cache:/ {print $4}')
+swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}')
+swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}')
+swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}')
+
+### Disk Infomation
+
+## Available disk space on the partition.
 filesystem=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $1}')
 totalspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $2}')
 usedspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $3}')
 availspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $4}')
 
-# used space in serverfiles dir.
+## LGSM used space total.
+rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')
+if [ -z "${rootdirdu}" ]; then
+	rootdirdu="0M"
+fi
+
+## LGSM used space in serverfiles dir.
 filesdirdu=$(du -sh "${filesdir}" 2> /dev/null | awk '{print $1}')
-if [ -z ${filesdirdu} ]; then
+if [ -z "${filesdirdu}" ]; then
 	filesdirdu="0M"
 fi
 
-# Backup info
+## LGSM used space total minus backup dir.
+rootdirduexbackup=$(du -sh --exclude="${backupdir}" "${filesdir}" 2> /dev/null | awk '{print $1}')
+if [ -z "${rootdirduexbackup}" ]; then
+	rootdirduexbackup="0M"
+fi
+
+## Backup info
 if [ -d "${backupdir}" ]; then
 	# used space in backups dir.
 	backupdirdu=$(du -sh "${backupdir}" | awk '{print $1}')
-	if [ -z ${backupdirdu} ]; then
+	if [ -z "${backupdirdu}" ]; then
 		backupdirdu="0M"
 	fi
+
 	# number of backups.
 	backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
 	# most recent backup.

+ 2 - 2
lgsm/functions/info_glibc.sh

@@ -2,10 +2,10 @@
 # LGSM info_glibc.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: stores details on servers Glibc requirements.
 
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 if [ "${gamename}" == "Blade Symphony" ]; then
 	glibcrequired="2.15"
 	glibcfix="yes"

+ 4 - 30
lgsm/functions/info_parms.sh

@@ -2,9 +2,9 @@
 # LGSM info_parms.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
+# Description: Gets specific details from server parameters.
 
-# Description: Gets specific details server parameters.
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 ## Examples of filtering to get info from config files
 # sed 's/foo//g' - remove foo
@@ -12,8 +12,8 @@ lgsm_version="210516"
 # tr -d '=\"; ' remove selected charectors =\";
 # grep -v "foo" filter out lines that contain foo
 
-unavailable="\e[0;31mUNAVAILABLE\e[0m"
-zero="\e[0;31m0\e[0m"
+unavailable="${red}UNAVAILABLE${default}"
+zero="${red}0${default}"
 
 
 fn_info_config_idtech3(){
@@ -45,30 +45,6 @@ fn_info_config_source(){
 	clientport=${clientport:-"0"}
 }
 
-fn_info_config_teamspeak3(){
-	if [ ! -f "${servercfgfullpath}" ]; then
-		dbplugin="${unavailable}"
-		port="9987"
-		queryport="10011"
-		fileport="30033"
-	else
-		# check if the ip exists in the config file. Failing this will fall back to the default.
-		ipconfigcheck=$(grep "voice_ip=" "${servercfgfullpath}" | sed 's/\voice_ip=//g')
-		if [ -n "${ipconfigcheck}" ]; then
-			ip="${ipconfigcheck}"
-		fi
-		dbplugin=$(grep "dbplugin=" "${servercfgfullpath}" | sed 's/\dbplugin=//g')
-		port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd '[:digit:]')
-		queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd '[:digit:]')
-		fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd '[:digit:]')
-
-		# Not Set
-		port=${port:-"9987"}
-		queryport=${queryport:-"10011"}
-		fileport=${fileport:-"30033"}
-	fi
-}
-
 fn_info_config_teeworlds(){
 	if [ ! -f "${servercfgfullpath}" ]; then
 		servername="unnamed server"
@@ -164,8 +140,6 @@ elif [ "${engine}" == "seriousengine35" ]; then
 # Source Engine Games
 elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 	fn_info_config_source
-elif [ "${gamename}" == "Teamspeak 3" ]; then
-	fn_info_config_teamspeak3
 # Teeworlds
 elif [ "${engine}" == "teeworlds" ]; then
 	fn_info_config_teeworlds

+ 5 - 3
lgsm/functions/install_complete.sh

@@ -2,9 +2,10 @@
 # LGSM install_complete.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 if [ "${gamename}" == "Don't Starve Together" ]; then
   echo ""
@@ -14,8 +15,9 @@ if [ "${gamename}" == "Don't Starve Together" ]; then
 fi
 echo "================================="
 echo "Install Complete!"
-fn_scriptlog "Install Complete!"
+fn_script_log_info "Install Complete!"
 echo ""
 echo "To start server type:"
 echo "./${selfname} start"
 echo ""
+core_exit.sh

+ 30 - 2
lgsm/functions/install_config.sh

@@ -2,12 +2,14 @@
 # LGSM install_config.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_defaultconfig(){
 	echo "creating ${servercfg} config file."
+	fn_script_log_info "creating ${servercfg} config file."
 	cp -v "${servercfgdefault}" "${servercfgfullpath}"
 	sleep 1
 }
@@ -26,9 +28,11 @@ fn_userinputconfig(){
 		rconpass="rconpassword"
 	fi
 	echo "changing hostname."
+	fn_script_log_info "changing hostname."
 	sed -i "s/\"<hostname>\"/\"${servername}\"/g" "${servercfgfullpath}"
 	sleep 1
 	echo "changing rconpassword."
+	fn_script_log_info "changing rconpassword."
 	sed -i "s/\"<rconpassword>\"/\"${rconpass}\"/g" "${servercfgfullpath}"
 	sleep 1
 	}
@@ -36,6 +40,7 @@ fn_userinputconfig(){
 fn_arma3config(){
 	fn_defaultconfig
 	echo "creating ${networkcfg} config file."
+	fn_script_log_info "creating ${networkcfg} config file."
 	cp -v "${networkcfgdefault}" "${networkcfgfullpath}"
 	sleep 1
 	echo ""
@@ -46,18 +51,22 @@ fn_goldsourceconfig(){
 
 	# server.cfg redirects to ${servercfg} for added security
 	echo "creating server.cfg."
+	fn_script_log_info "creating server.cfg."
 	touch "server.cfg"
 	sleep 1
 	echo "creating redirect."
+	fn_script_log_info "creating redirect."
 	echo "server.cfg > ${servercfg}."
 	echo "exec ${servercfg}" > "server.cfg"
 	sleep 1
 
 	# creating other files required
 	echo "creating listip.cfg."
+	fn_script_log_info "creating listip.cfg."
 	touch "${systemdir}/listip.cfg"
 	sleep 1
 	echo "creating banned.cfg."
+	fn_script_log_info "creating banned.cfg."
 	touch "${systemdir}/banned.cfg"
 	sleep 1
 
@@ -70,6 +79,8 @@ fn_serious3config(){
 	echo ""
 	echo "To edit ${gamename} server config use SS3 Server GUI 3 tool"
 	echo "http://mrag.nl/sgui3/"
+	fn_script_log_info "To edit ${gamename} server config use SS3 Server GUI 3 tool"
+	fn_script_log_info "http://mrag.nl/sgui3/"
 	sleep 1
 	echo ""
 }
@@ -79,9 +90,11 @@ fn_sourceconfig(){
 
 	# server.cfg redirects to ${servercfg} for added security
 	echo "creating server.cfg."
+	fn_script_log_info "creating server.cfg."
 	touch "server.cfg"
 	sleep 1
 	echo "creating redirect."
+	fn_script_log_info "creating redirect."
 	echo "server.cfg > ${servercfg}."
 	echo "exec ${servercfg}" > "server.cfg"
 	sleep 1
@@ -94,9 +107,11 @@ fn_teeworldsconfig(){
 	fn_defaultconfig
 
 	echo "adding logfile location to config."
+	fn_script_log_info "adding logfile location to config."
 	sed -i "s@\"<logfile>\"@\"${gamelog}\"@g" "${servercfgfullpath}"
 	sleep 1
 	echo "removing password holder."
+	fn_script_log_info "removing password holder."
 	sed -i "s/<password>//" "${servercfgfullpath}"
 	sleep 1
 
@@ -105,6 +120,8 @@ fn_teeworldsconfig(){
 }
 
 fn_ut99config(){
+	echo "creating ${servercfg} config file."
+	fn_script_log_info "creating ${servercfg} config file."
 	echo "${servercfgdefault} > ${servercfgfullpath}"
 	tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}"
 	sleep 1
@@ -113,9 +130,11 @@ fn_ut99config(){
 	echo "================================="
 	sleep 1
 	echo "enabling WebAdmin."
+	fn_script_log_info "enabling WebAdmin."
 	sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
 	sleep 1
 	echo "setting WebAdmin port to 8076."
+	fn_script_log_info "setting WebAdmin port to 8076."
 	sed -i '467i\ListenPort=8076' "${servercfgfullpath}"
 	sleep 1
 	echo ""
@@ -128,14 +147,17 @@ fn_unreal2config(){
 	echo "================================="
 	sleep 1
 	echo "setting WebAdmin username and password."
+	fn_script_log_info "setting WebAdmin username and password."
 	sed -i 's/AdminName=/AdminName=admin/g' "${servercfgfullpath}"
 	sed -i 's/AdminPassword=/AdminPassword=admin/g' "${servercfgfullpath}"
 	sleep 1
 	echo "enabling WebAdmin."
+	fn_script_log_info "enabling WebAdmin."
 	sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
 	if [ "${gamename}" == "Unreal Tournament 2004" ]; then
 		sleep 1
 		echo "setting WebAdmin port to 8075."
+		fn_script_log_info "setting WebAdmin port to 8075."
 		sed -i 's/ListenPort=80/ListenPort=8075/g' "${servercfgfullpath}"
 	fi
 	sleep 1
@@ -313,6 +335,12 @@ elif [ "${gamename}" == "Sven Co-op" ]; then
 	wget -N /dev/null ${githuburl}/SvenCoop/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq
 	sleep 1
 	fn_goldsourceconfig
+elif [ "${gamename}" == "Starbound" ]; then
+	echo -e "downloading lgsm-default.config...\c"
+	wget -N /dev/null ${githuburl}/Starbound/cfg/lgsm-default.config 2>&1 | grep -F HTTP | cut -c45- | uniq
+	sleep 1
+	fn_defaultconfig
+	fn_userinputconfig
 elif [ "${gamename}" == "Teamspeak 3" ]; then
 	echo -e "downloading lgsm-default.ini...\c"
 	wget -N /dev/null ${githuburl}/TeamSpeak3/cfg/lgsm-default.ini 2>&1 | grep -F HTTP | cut -c45- | uniq

+ 8 - 8
lgsm/functions/install_gslt.sh

@@ -2,11 +2,11 @@
 # LGSM install_gslt.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Configures GSLT.
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 echo ""
 echo "Game Server Login Token"
@@ -14,16 +14,16 @@ echo "================================="
 sleep 1
 if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
 	echo "GSLT is required to run a public ${gamename} server"
-	fn_scriptlog "GSLT is required to run a public ${gamename} server"
+	fn_script_log_info "GSLT is required to run a public ${gamename} server"
 else
 	echo "GSLT is an optional feature for ${gamename} server"
-	fn_scriptlog "GSLT is an optional feature for ${gamename} server"
+	fn_script_log_info "GSLT is an optional feature for ${gamename} server"
 fi
 
 echo "Get more info and a token here:"
 echo "https://gameservermanagers.com/gslt"
-fn_scriptlog "Get more info and a token here:"
-fn_scriptlog "https://gameservermanagers.com/gslt"
+fn_script_log_info "Get more info and a token here:"
+fn_script_log_info "https://gameservermanagers.com/gslt"
 echo ""
 if [ -z "${autoinstall}" ]; then
 	echo "Enter token below (Can be blank)."
@@ -33,5 +33,5 @@ if [ -z "${autoinstall}" ]; then
 fi
 sleep 1
 echo "The GSLT can be changed by editing ${selfname}."
-fn_scriptlog "The GSLT can be changed by editing ${selfname}."
+fn_script_log_info "The GSLT can be changed by editing ${selfname}."
 echo ""

+ 0 - 30
lgsm/functions/install_gsquery.sh

@@ -1,30 +0,0 @@
-#!/bin/bash
-# LGSM install_gsquery.sh function
-# Author: Daniel Gibbs
-# Website: https://gameservermanagers.com
-lgsm_version="210516"
-
-fn_dlgsquery(){
-	cd "${functionsdir}"
-	echo -e "downloading gsquery.py...\c"
-	wget -N /dev/null "https://gameservermanagers.com/dl/gsquery.py" 2>&1 | grep -F "HTTP" | grep -v "Moved Permanently" | cut -c45- | uniq
-	chmod +x gsquery.py
-}
-
-if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "idtech3" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${gamename}" == "Hurtworld" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
-	echo ""
-	echo "GameServerQuery"
-	echo "================================="
-	if [ -z ${autoinstall} ]; then
-		while true; do
-			read -e -i "y" -p "Do you want to install GameServerQuery? [Y/n]" yn
-			case $yn in
-			[Yy]* ) fn_dlgsquery;break;;
-			[Nn]* ) echo ""; echo "Not installing GameServerQuery.";break;;
-			* ) echo "Please answer yes or no.";;
-		esac
-		done
-	else
-		fn_dlgsquery
-	fi
-fi

+ 3 - 2
lgsm/functions/install_header.sh

@@ -2,9 +2,10 @@
 # LGSM install_header.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 clear
 echo "================================="

+ 4 - 3
lgsm/functions/install_logs.sh

@@ -2,9 +2,10 @@
 # LGSM install_logs.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 if [ "${checklogs}" != "1" ]; then
 	echo ""
@@ -40,4 +41,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then
 	fi
 fi
 sleep 1
-fn_scriptlog "logs installed"
+fn_script_log_info "Logs installed"

+ 3 - 2
lgsm/functions/install_retry.sh

@@ -2,9 +2,10 @@
 # LGSM install_retry.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 while true; do
 	read -e -i "y" -p "Retry install? [Y/n]" yn

+ 4 - 3
lgsm/functions/install_server_dir.sh

@@ -1,10 +1,11 @@
 #!/bin/bash
-# LGSM install_serverdir.sh function
+# LGSM install_server_dir.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 echo ""
 echo "Server Directory"

+ 13 - 11
lgsm/functions/install_server_files.sh

@@ -2,9 +2,10 @@
 # LGSM install_server_files.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="270516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_install_server_files(){
 	if [ "${gamename}" == "Unreal Tournament 99" ]; then
@@ -32,7 +33,7 @@ fn_install_server_files_steamcmd(){
 
 			if [ "${counter}" -ge "2" ]; then
 				fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
-				fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}"
+				fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}"
 			fi
 
 			if [ "${counter}" -ge "7" ]; then
@@ -45,9 +46,7 @@ fn_install_server_files_steamcmd(){
 			fi
 
 			# Detects if unbuffer command is available.
-			if [ $(command -v unbuffer) ]; then
-				unbuffer=unbuffer
-                        elif  [ $(command -v stdbuf) ]; then
+            if  [ $(command -v stdbuf) ]; then
 		            unbuffer="stdbuf -i0 -o0 -e0"
 			fi
 
@@ -70,7 +69,7 @@ fn_install_server_files_steamcmd(){
 			fi
 		elif [ "${counter}" -ge "11" ]; then
 			fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
-			fn_scriptlog "SteamCMD did not complete the download, too many retrys"
+			fn_script_log "SteamCMD did not complete the download, too many retrys"
 			break
 		fi
 	done
@@ -92,14 +91,17 @@ echo ""
 echo "Installing ${gamename} Server"
 echo "================================="
 sleep 1
-if [ -n "${appid}" ]; then
-	fn_install_server_files_steamcmd
-fi
 
-if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
+if [ "${gamename}" == "Teamspeak 3" ]; then
+	update_ts3.sh
+elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
 	fn_install_server_files
 fi
 
+if [ -n "${appid}" ]; then
+	fn_install_server_files_steamcmd
+fi
+
 if [ -z "${autoinstall}" ]; then
 	echo ""
 	echo "================================="

+ 2 - 3
lgsm/functions/install_steamcmd.sh

@@ -2,11 +2,10 @@
 # LGSM install_steamcmd.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Downloads SteamCMD on install.
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
 
 echo ""
 echo "Installing SteamCMD"

+ 0 - 81
lgsm/functions/install_ts3.sh

@@ -1,81 +0,0 @@
-#!/bin/bash
-# LGSM install_ts3.sh function
-# Author: Daniel Gibbs
-# Website: https://gameservermanagers.com
-lgsm_version="210516"
-
-local modulename="Install"
-
-info_distro.sh
-# Gets the teamspeak server architecture
-if [ "${arch}" == "x86_64" ]; then
-	ts3arch="amd64"
-elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
-	ts3arch="x86"
-else
-	fn_print_failure "${arch} is an unsupported architecture"
-	exit 1
-fi
-
-# Grabs all version numbers but not in correct order
-wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
-
-# Sort version numbers
-cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp
-
-# Finds directory with most recent server version.
-while read ts3_version_number; do
-	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
-	if [ $? -eq 0 ]; then
-		availablebuild="${ts3_version_number}"
-		# Break while-loop, if the latest release could be found
-		break
-	fi
-done < .ts3_version_numbers_sorted.tmp
-
-# Tidy up
-rm -f ".ts3_version_numbers_unsorted.tmp"
-rm -f ".ts3_version_numbers_sorted.tmp"
-
-# Checks availablebuild info is available
-if [ -z "${availablebuild}" ]; then
-	fn_print_fail "Checking for update: teamspeak.com"
-	sleep 1
-	fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
-	sleep 2
-	exit 1
-fi
-
-echo ""
-echo "Installing ${gamename} Server"
-echo "================================="
-cd "${rootdir}"
-echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
-wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
-sleep 1
-echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
-tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> ".${servicename}-tar-error.tmp"
-local status=$?
-if [ ${status} -eq 0 ]; then
-	echo "OK"
-else
-	echo "FAIL - Exit status ${status}"
-	sleep 1
-	cat ".${servicename}-tar-error.tmp"
-	rm ".${servicename}-tar-error.tmp"
-	exit $?
-fi
-echo -e "copying to ${filesdir}...\c"
-cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp"
-local status=$?
-if [ ${status} -eq 0 ]; then
-	echo "OK"
-else
-	echo "FAIL - Exit status ${status}"
-	sleep 1
-	cat ".${servicename}-cp-error.tmp"
-	rm ".${servicename}-cp-error.tmp"
-	exit $?
-fi
-rm -f "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
-rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"

+ 4 - 3
lgsm/functions/install_ts3db.sh

@@ -1,11 +1,12 @@
 #!/bin/bash
-# LGSM fn_install_ts3_mariadb function
+# LGSM install_ts3db.sh function
 # Author: Daniel Gibbs
 # Contributor: PhilPhonic
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_install_ts3db_mariadb(){
 	echo ""

+ 4 - 3
lgsm/functions/install_ut2k4_key.sh

@@ -2,9 +2,10 @@
 # LGSM install_ut2k4_key.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
 
-local modulename="Install"
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 echo ""
 echo "Enter ${gamename} CD Key"
@@ -20,7 +21,7 @@ if [ -z "${autoinstall}" ]; then
 	read CODE
 	echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey"
 	if [ -f "${systemdir}/cdkey" ]; then
-		fn_scriptlog "UT2K4 Server CD Key created"
+		fn_script_log_info "UT2K4 Server CD Key created"
 	fi
 else
 	echo "You can add your key using the following command"

+ 5 - 7
lgsm/functions/logs.sh

@@ -3,11 +3,10 @@
 # Author: Daniel Gibbs
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: Acts as a log rotater, removing old logs.
 
-local modulename="Log Manager"
+local commandname="LOGS"
+local commandaction="Log-Manager"
 
 # Check if logfile variable and file exist, create logfile if it doesn't exist
 if [ -n "${consolelog}" ]; then
@@ -20,7 +19,7 @@ fi
 if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then
 	if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then
 		fn_print_info "Moving game logs to ${gamelogdir}"
-		fn_scriptlog "Moving game logs to ${gamelogdir}"
+		fn_script_log_info "Moving game logs to ${gamelogdir}"
 		echo -en "\n"
 		sleep 1
 		mv "${systemdir}"/gamelog*.log "${gamelogdir}"
@@ -39,9 +38,8 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
 	scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0"
 	sleep 1
 	fn_print_ok_nl "Starting"
-	fn_scriptlog "Starting"
 	fn_print_info_nl "Removing logs older than "${logdays}" days"
-	fn_scriptlog "Removing logs older than "${logdays}" days"
+	fn_script_log_info "Removing logs older than "${logdays}" days"
 	# Logging logfiles to be removed according to "${logdays}", counting and removing them
 	# Script logfiles
 	find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}"
@@ -98,5 +96,5 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
 	count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount} + ${legacycount}))
 	# Job done
 	fn_print_ok_nl "Removed ${count} log files"
-	fn_scriptlog "Removed ${count} log files"
+	fn_script_log "Removed ${count} log files"
 fi

+ 14 - 13
lgsm/functions/monitor_gsquery.sh

@@ -2,12 +2,12 @@
 # LGSM monitor_gsquery.sh function
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-lgsm_version="210516"
-
 # Description: uses gsquery.py to query the server port.
 # Detects if the server has frozen with the proccess still running.
 
-local modulename="Monitor"
+local commandname="MONITOR"
+local commandaction="Monitor"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 # Forces legecy servers to use gsquery
 if [ -z "${gsquery}" ]; then
@@ -26,7 +26,7 @@ if [ "${gsquery}" == "yes" ]; then
 	if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
 		port=$((port + 1))
 	elif [ "${engine}" == "realvirtuality" ]; then
-		port=$((port + 1))		
+		port=$((port + 1))
 	elif [ "${engine}" == "spark" ]; then
 		port=$((port + 1))
 	fi
@@ -36,7 +36,7 @@ if [ "${gsquery}" == "yes" ]; then
 	fi
 
 	fn_print_info "Querying port: gsquery.py enabled"
-	fn_scriptlog "Querying port: gsquery.py enabled"
+	fn_script_log_info "Querying port: gsquery.py enabled"
 	sleep 1
 
 	# Will query up to 4 times every 15 seconds.
@@ -46,7 +46,7 @@ if [ "${gsquery}" == "yes" ]; then
 	for queryattempt in {1..5}; do
 		fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
 		fn_print_querying_eol
-		fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING"
+		fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING"
 
 		gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1)
 		exitcode=$?
@@ -56,30 +56,30 @@ if [ "${gsquery}" == "yes" ]; then
 			# Server OK
 			fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : "
 			fn_print_ok_eol_nl
-			fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : OK"
-			sleep 1
-			exit
+			fn_script_log_pass "Querying port: ${ip}:${port} : ${queryattempt} : OK"
+			exitcode=0
+			break
 		else
 			# Server failed query
-			fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}"
+			fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}"
 
 			if [ "${queryattempt}" == "5" ]; then
 				# Server failed query 4 times confirmed failure
 				fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
 				fn_print_fail_eol_nl
-				fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : FAIL"
+				fn_script_log_error "Querying port: ${ip}:${port} : ${queryattempt} : FAIL"
 				sleep 1
 
 				# Send alert if enabled
 				alert="restartquery"
 				alert.sh
-				fn_restart
+				command_restart.sh
 				break
 			fi
 
 			# Seconds counter
 			for seconds in {1..15}; do
-				fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m"
+				fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : ${red}${gsquerycmd}${default}"
 				totalseconds=$((totalseconds + 1))
 				sleep 1
 				if [ "${seconds}" == "15" ]; then
@@ -89,3 +89,4 @@ if [ "${gsquery}" == "yes" ]; then
 		fi
 	done
 fi
+core_exit.sh

+ 0 - 342
lgsm/functions/update_check.sh

@@ -1,342 +0,0 @@
-#!/bin/bash
-# LGSM update_check.sh function
-# Author: Daniel Gibbs
-# Website: https://gameservermanagers.com
-lgsm_version="210516"
-
-# Description: Checks if a server update is available.
-
-local modulename="Update"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
-
-### SteamCMD Update Checker ###
-
-fn_appmanifestinfo(){
-	appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf")
-	appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l)
-}
-
-fn_appmanifestcheck(){
-	fn_appmanifestinfo
-	# Multiple or no matching appmanifest files may sometimes be available.
-	# This is an error is corrected below if required.
-	if [ "${appmanifestfilewc}" -ge "2" ]; then
-		sleep 1
-		fn_print_warn "Multiple appmanifest_${appid}.acf files found"
-		fn_scriptlog "Warning! Multiple appmanifest_${appid}.acf files found"
-		sleep 2
-		fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
-		sleep 1
-		for appfile in ${appmanifestfile}; do
-			rm "${appfile}"
-		done
-		appmanifestfilewc1="${appmanifestfilewc}"
-		fn_appmanifestinfo
-		if [ "${appmanifestfilewc}" -ge "2" ]; then
-			fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
-			fn_scriptlog "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
-			sleep 1
-			echo ""
-			echo "	Check user permissions"
-			for appfile in ${appmanifestfile}; do
-				echo "	${appfile}"
-			done
-			exit 1
-		else
-			sleep 1
-			fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
-			fn_scriptlog "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
-			sleep 1
-			fn_print_info_nl "Forcing update to correct issue"
-			fn_scriptlog "Forcing update to correct issue"
-			sleep 1
-			update_dl.sh
-			update_check.sh
-		fi
-	elif [ "${appmanifestfilewc}" -eq "0" ]; then
-		if [ "${forceupdate}" == "1" ]; then
-			fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update"
-			fn_scriptlog "Warning! Still no appmanifest_${appid}.acf found: Unable to update"
-			exit 1
-		fi
-		forceupdate=1
-		fn_print_warn "No appmanifest_${appid}.acf found"
-		fn_scriptlog "Warning! No appmanifest_${appid}.acf found"
-		sleep 2
-		fn_print_info_nl "Forcing update to correct issue"
-		fn_scriptlog "Forcing update to correct issue"
-		sleep 1
-		update_dl.sh
-		update_check.sh
-	fi
-}
-
-fn_logupdaterequest(){
-	# Checks for server update requests from server logs.
-	fn_print_dots "Checking for update: Server logs"
-	fn_scriptlog "Checking for update: Server logs"
-	sleep 1
-	requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}")
-	if [ "${requestrestart}" -ge "1" ]; then
-		fn_print_ok_nl "Checking for update: Server logs: Update requested"
-		sleep 1
-		echo ""
-		echo -ne "Applying update.\r"
-		sleep 1
-		echo -ne "Applying update..\r"
-		sleep 1
-		echo -ne "Applying update...\r"
-		sleep 1
-		echo -ne "\n"
-
-		unset updateonstart
-		check_status.sh
-		if [ "${status}" != "0" ]; then
-			command_stop.sh
-			update_dl.sh
-			command_start.sh
-		else
-			update_dl.sh
-		fi
-		alert="update"
-		alert.sh
-	else
-		fn_print_ok "Checking for update: Server logs: No update requested"
-		sleep 1
-	fi
-}
-
-fn_steamcmdcheck(){
-	fn_appmanifestcheck
-	# Checks for server update from SteamCMD
-	fn_print_dots "Checking for update: SteamCMD"
-	fn_scriptlog "Checking for update: SteamCMD"
-	sleep 1
-
-	# Gets currentbuild
-	currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
-
-	# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD
-
-	# Gets availablebuild info
-	cd "${rootdir}/steamcmd"
-	if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then
-		rm -f "${HOME}/Steam/appcache/appinfo.vdf"
-	fi
-
-	# set branch for updateinfo
-	IFS=' ' read -a branchsplits <<< "${branch}"
-	if [ "${#branchsplits[@]}" -gt 1 ]; then
-		branchname="${branchsplits[1]}"
-	else
-		branchname="public"
-	fi
-
-	availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
-	if [ -z "${availablebuild}" ]; then
-		fn_print_fail "Checking for update: SteamCMD"
-		fn_scriptlog "Failure! Checking for update: SteamCMD"
-		sleep 1
-		fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info"
-		fn_scriptlog "Failure! Checking for update: SteamCMD: Not returning version info"
-		exit 1
-	else
-		fn_print_ok "Checking for update: SteamCMD"
-		fn_scriptlog "Success! Checking for update: SteamCMD"
-		sleep 1
-	fi
-
-	if [ "${currentbuild}" != "${availablebuild}" ]; then
-		echo -e "\n"
-		echo -e "Update available:"
-		sleep 1
-		echo -e "	Current build: \e[0;31m${currentbuild}\e[0;39m"
-		echo -e "	Available build: \e[0;32m${availablebuild}\e[0;39m"
-		echo -e ""
-		echo -e "	https://steamdb.info/app/${appid}/"
-		sleep 1
-		echo ""
-		echo -en "Applying update.\r"
-		sleep 1
-		echo -en "Applying update..\r"
-		sleep 1
-		echo -en "Applying update...\r"
-		sleep 1
-		echo -en "\n"
-		fn_scriptlog "Update available"
-		fn_scriptlog "Current build: ${currentbuild}"
-		fn_scriptlog "Available build: ${availablebuild}"
-		fn_scriptlog "${currentbuild} > ${availablebuild}"
-
-		unset updateonstart
-		check_status.sh
-		if [ "${status}" != "0" ]; then
-			command_stop.sh
-			update_dl.sh
-			command_start.sh
-		else
-			update_dl.sh
-		fi
-		alert="update"
-		alert.sh
-	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current version: \e[0;32m${currentbuild}\e[0;39m"
-		echo -e "	Available version: \e[0;32m${availablebuild}\e[0;39m"
-		echo -e "	https://steamdb.info/app/${appid}/"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_scriptlog "Current build: ${currentbuild}"
-		fn_scriptlog "Available build: ${availablebuild}"
-	fi
-}
-
-### END SteamCMD Update Checker ###
-
-fn_teamspeak3_check(){
-	# Checks for server update from teamspeak.com using a mirror dl.4players.de
-	fn_print_dots "Checking for update: teamspeak.com"
-	fn_scriptlog "Checking for update: teamspeak.com"
-	sleep 1
-
-	# Gets currentbuild info
-	# Checks currentbuild info is available, if fails a server restart will be forced to generate logs
-	if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
-		fn_print_fail "Checking for update: teamspeak.com"
-		sleep 1
-		fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found"
-		fn_scriptlog "Failure! Checking for update: teamspeak.com: No logs with server version found"
-		sleep 2
-		fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
-		fn_scriptlog "Checking for update: teamspeak.com: Forcing server restart"
-		sleep 2
-		command_stop.sh
-		command_start.sh
-		sleep 2
-		# If still failing will exit
-		if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
-			fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found"
-			fn_scriptlog "Failure! Checking for update: teamspeak.com: Still No logs with server version found"
-			exit 1
-		fi
-	fi
-	currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
-
-	# Gets the teamspeak server architecture
-	info_distro.sh
-	if [ "${arch}" == "x86_64" ]; then
-		ts3arch="amd64"
-	elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
-		ts3arch="x86"
-	else
-		echo ""
-		fn_print_failure "${arch} is an unsupported architecture"
-		exit 1
-	fi
-
-	# Gets availablebuild info
-
-	# Grabs all version numbers but not in correct order
-	wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
-
-	# Sort version numbers
-	cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp
-
-	# Finds directory with most recent server version.
-	while read ts3_version_number; do
-		wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
-		if [ $? -eq 0 ]; then
-			availablebuild="${ts3_version_number}"
-			# Break while-loop, if the latest release could be found
-			break
-		fi
-	done < .ts3_version_numbers_sorted.tmp
-
-	# Tidy up
-	rm -f ".ts3_version_numbers_unsorted.tmp"
-	rm -f ".ts3_version_numbers_sorted.tmp"
-
-	# Checks availablebuild info is available
-	if [ -z "${availablebuild}" ]; then
-		fn_print_fail "Checking for update: teamspeak.com"
-		fn_scriptlog "Checking for update: teamspeak.com"
-		sleep 1
-		fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
-		fn_scriptlog "Failure! Checking for update: teamspeak.com: Not returning version info"
-		sleep 2
-		exit 1
-	else
-		fn_print_ok "Checking for update: teamspeak.com"
-		fn_scriptlog "Success! Checking for update: teamspeak.com"
-		sleep 1
-	fi
-
-	# Removes dots so if can compare version numbers
-	currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]')
-	availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]')
-	if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
-		echo -e "\n"
-		echo -e "Update available:"
-		sleep 1
-		echo -e "	Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m"
-		echo -e "	Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m"
-		echo -e ""
-		sleep 1
-		echo ""
-		echo -en "Applying update.\r"
-		sleep 1
-		echo -en "Applying update..\r"
-		sleep 1
-		echo -en "Applying update...\r"
-		sleep 1
-		echo -en "\n"
-		fn_scriptlog "Update available"
-		fn_scriptlog "Current build: ${currentbuild}"
-		fn_scriptlog "Available build: ${availablebuild}"
-		fn_scriptlog "${currentbuild} > ${availablebuild}"
-
-		unset updateonstart
-		check_status.sh
-		if [ "${status}" == "0" ]; then
-			update_dl.sh
-			command_start.sh
-			sleep 5
-			command_stop.sh
-		else
-			command_stop.sh
-			update_dl.sh
-			command_start.sh
-		fi
-		alert="update"
-		alert.sh
-	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current version: \e[0;32m${currentbuild}\e[0;39m"
-		echo -e "	Available version: \e[0;32m${availablebuild}\e[0;39m"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_scriptlog "Current build: ${currentbuild}"
-		fn_scriptlog "Available build: ${availablebuild}"
-	fi
-}
-
-check.sh
-fn_print_dots "Checking for update"
-if [ "${gamename}" == "Teamspeak 3" ]; then
-	fn_teamspeak3_check
-elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then
-	# Goldsource servers bypass checks as fn_steamcmdcheck does not work for appid 90 servers.
-	# forceupdate bypasses checks
-	if [ "${status}" != "0" ]; then
-		command_stop.sh
-		update_dl.sh
-		command_start.sh
-	else
-		update_dl.sh
-	fi
-else
-	fn_logupdaterequest
-	fn_steamcmdcheck
-fi

+ 0 - 85
lgsm/functions/update_dl.sh

@@ -1,85 +0,0 @@
-#!/bin/bash
-# LGSM update_dl.sh function
-# Author: Daniel Gibbs
-# Website: https://gameservermanagers.com
-lgsm_version="210516"
-
-# Description: Runs a server update.
-
-local modulename="Update"
-function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
-
-fn_steamcmd_dl(){
-	cd "${rootdir}"
-	cd "steamcmd"
-
-	# Detects if unbuffer command is available.
-	if [ $(command -v unbuffer) ]; then
-		unbuffer=unbuffer
-        elif  [ $(command -v stdbuf) ]; then
-		unbuffer="stdbuf -i0 -o0 -e0"
-	fi
-
-	if [ "${engine}" == "goldsource" ]; then
-		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}"
-	else
-		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}"
-	fi
-
-	fix.sh
-}
-
-fn_teamspeak3_dl(){
-	cd "${rootdir}"
-	echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
-	fn_scriptlog "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
-	wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
-	sleep 1
-	echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
-	fn_scriptlog "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
-	tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
-	local status=$?
-	if [ ${status} -eq 0 ]; then
-		echo "OK"
-	else
-		echo "FAIL - Exit status ${status}"
-		fn_scriptlog "Failed to extract - Exit status ${status}"
-		sleep 1
-		cat "${scriptlogdir}/.${servicename}-tar-error.tmp"
-		cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}"
-		rm "${scriptlogdir}/.${servicename}-tar-error.tmp"
-		fn_scriptlog "Failure! Unable to update"
-		exit ${status}
-	fi
-	echo -e "copying to ${filesdir}...\c"
-	fn_scriptlog "Copying to ${filesdir}"
-	cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
-	local status=$?
-	if [ ${status} -eq 0 ]; then
-		echo "OK"
-	else
-		echo "FAIL - Exit status ${status}"
-		fn_scriptlog "Failed to copy - Exit status ${status}"
-		sleep 1
-		cat "${scriptlogdir}/.${servicename}-cp-error.tmp"
-		cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}"
-		rm "${scriptlogdir}/.${servicename}-cp-error.tmp"
-		fn_scriptlog "Failure! Unable to update"
-		exit ${status}
-	fi
-	rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
-	rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"
-}
-
-check.sh
-info_config.sh
-fn_print_dots "Updating ${servername}"
-sleep 1
-fn_print_ok_nl "Updating ${servername}"
-fn_scriptlog "Updating ${servername}"
-sleep 1
-if [ "${gamename}" == "Teamspeak 3" ]; then
-	fn_teamspeak3_dl
-else
-	fn_steamcmd_dl
-fi

+ 238 - 0
lgsm/functions/update_steamcmd.sh

@@ -0,0 +1,238 @@
+#!/bin/bash
+# LGSM update_steamcmd.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description:Handles updating using steamCMD.
+
+local commandname="UPDATE"
+local commandaction="Update"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+fn_update_steamcmd_dl(){
+	check.sh
+	info_config.sh
+	fn_print_dots "SteamCMD"
+	sleep 1
+	fn_print_ok_nl "SteamCMD"
+	fn_script_log_info "Starting SteamCMD"
+
+	cd "${rootdir}/steamcmd"
+
+	# Detects if unbuffer command is available.
+	if [ $(command -v stdbuf) ]; then
+		unbuffer="stdbuf -i0 -o0 -e0"
+	fi
+
+	if [ "${engine}" == "goldsource" ]; then
+		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}"
+	else
+		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}"
+	fi
+
+	fix.sh
+}
+
+fn_appmanifest_info(){
+	appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf")
+	appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l)
+}
+
+fn_appmanifest_check(){
+	fn_appmanifest_info
+	# Multiple or no matching appmanifest files may sometimes be present.
+	# This error is corrected if required.
+	if [ "${appmanifestfilewc}" -ge "2" ]; then
+		sleep 1
+		fn_print_error "Multiple appmanifest_${appid}.acf files found"
+		fn_script_log_error "Multiple appmanifest_${appid}.acf files found"
+		sleep 2
+		fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
+		sleep 1
+		for appfile in ${appmanifestfile}; do
+			rm "${appfile}"
+		done
+		sleep 1
+		appmanifestfilewc1="${appmanifestfilewc}"
+		fn_appmanifest_info
+		if [ "${appmanifestfilewc}" -ge "2" ]; then
+			fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
+			fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
+			sleep 1
+			echo "	* Check user permissions"
+			for appfile in ${appmanifestfile}; do
+				echo "	${appfile}"
+			done
+			core_exit.sh
+		else
+			fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
+			fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
+			sleep 1
+			fn_print_info_nl "Forcing update to correct issue"
+			fn_script_log_info "Forcing update to correct issue"
+			sleep 1
+			fn_update_steamcmd_dl
+			fn_update_request_log
+		fi
+	elif [ "${appmanifestfilewc}" -eq "0" ]; then
+		fn_print_error "No appmanifest_${appid}.acf found"
+		fn_script_log_error "No appmanifest_${appid}.acf found"
+		sleep 1
+		fn_print_info_nl "Forcing update to correct issue"
+		fn_script_log_info "Forcing update to correct issue"
+		sleep 1
+		fn_update_steamcmd_dl
+		fn_update_request_log
+		fn_appmanifest_info
+		if [ "${appmanifestfilewc}" -eq "0" ]; then
+			fn_print_fatal "Still no appmanifest_${appid}.acf found"
+			fn_script_log_fatal "Still no appmanifest_${appid}.acf found"
+			core_exit.sh
+		fi
+	fi
+}
+
+fn_update_request_log(){
+	# Checks for server update requests from server logs.
+	fn_print_dots "Checking for update: Server logs"
+	fn_script_log_info "Checking for update: Server logs"
+	sleep 1
+	requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}")
+	if [ "${requestrestart}" -ge "1" ]; then
+		fn_print_ok_nl "Checking for update: Server logs: Update requested"
+		fn_script_log_pass "Checking for update: Server logs: Update requested"
+		sleep 1
+		echo ""
+		echo -en "Applying update.\r"
+		sleep 1
+		echo -en "Applying update..\r"
+		sleep 1
+		echo -en "Applying update...\r"
+		sleep 1
+		echo -en "\n"
+
+		unset updateonstart
+		check_status.sh
+		if [ "${status}" != "0" ]; then
+			exitbypass=1
+			command_stop.sh
+			fn_update_steamcmd_dl
+			exitbypass=1
+			command_start.sh
+		else
+			fn_update_steamcmd_dl
+		fi
+		alert="update"
+		alert.sh
+	else
+		fn_print_ok "Checking for update: Server logs: No update requested"
+		sleep 1
+	fi
+}
+
+fn_update_steamcmd_check(){
+	fn_appmanifest_check
+	# Checks for server update from SteamCMD
+	fn_print_dots "Checking for update: SteamCMD"
+	fn_script_log_info "Checking for update: SteamCMD"
+	sleep 1
+
+	# Gets currentbuild
+	currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
+
+	# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD
+	cd "${rootdir}/steamcmd"
+	if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then
+		rm -f "${HOME}/Steam/appcache/appinfo.vdf"
+	fi
+
+	# Set branch for updateinfo
+	IFS=' ' read -a branchsplits <<< "${branch}"
+	if [ "${#branchsplits[@]}" -gt 1 ]; then
+		branchname="${branchsplits[1]}"
+	else
+		branchname="public"
+	fi
+
+	# Gets availablebuild info
+	availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
+	if [ -z "${availablebuild}" ]; then
+		fn_print_fail "Checking for update: SteamCMD"
+		sleep 1
+		fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info"
+		fn_script_log_fatal "Checking for update: SteamCMD: Not returning version info"
+		core_exit.sh
+	else
+		fn_print_ok "Checking for update: SteamCMD"
+		fn_script_log_pass "Checking for update: SteamCMD"
+		sleep 1
+	fi
+
+	if [ "${currentbuild}" != "${availablebuild}" ]; then
+		fn_print_ok "Checking for update: SteamCMD: Update available"
+		fn_script_log_pass "Checking for update: SteamCMD: Update available"
+		echo -e "\n"
+		echo -e "Update available:"
+		sleep 1
+		echo -e "	Current build: ${red}${currentbuild}${default}"
+		echo -e "	Available build: ${green}${availablebuild}${default}"
+		echo -e ""
+		echo -e "	https://steamdb.info/app/${appid}/"
+		sleep 1
+		echo ""
+		echo -en "Applying update.\r"
+		sleep 1
+		echo -en "Applying update..\r"
+		sleep 1
+		echo -en "Applying update...\r"
+		sleep 1
+		echo -en "\n"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Current build: ${currentbuild}"
+		fn_script_log_info "Available build: ${availablebuild}"
+		fn_script_log_info "${currentbuild} > ${availablebuild}"
+
+		unset updateonstart
+		check_status.sh
+		if [ "${status}" != "0" ]; then
+			exitbypass=1
+			command_stop.sh
+			fn_update_steamcmd_dl
+			exitbypass=1
+			command_start.sh
+		else
+			fn_update_steamcmd_dl
+		fi
+		alert="update"
+		alert.sh
+	else
+		fn_print_ok "Checking for update: SteamCMD: No update available"
+		fn_script_log_pass "Checking for update: SteamCMD: No update available"
+		echo -e "\n"
+		echo -e "No update available:"
+		echo -e "	Current version: ${green}${currentbuild}${default}"
+		echo -e "	Available version: ${green}${availablebuild}${default}"
+		echo -e "	https://steamdb.info/app/${appid}/"
+		echo -e ""
+		fn_script_log_info "Current build: ${currentbuild}"
+		fn_script_log_info "Available build: ${availablebuild}"
+	fi
+}
+
+
+if [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then
+	# Goldsource servers bypass checks as fn_update_steamcmd_check does not work for appid 90 servers.
+	# forceupdate bypasses checks
+	check_status.sh
+	if [ "${status}" != "0" ]; then
+		exitbypass=1
+		command_stop.sh
+		fn_update_steamcmd_dl
+		exitbypass=1
+		command_start.sh
+	else
+		fn_update_steamcmd_dl
+	fi
+else
+	fn_update_request_log
+	fn_update_steamcmd_check
+fi

+ 196 - 0
lgsm/functions/update_ts3.sh

@@ -0,0 +1,196 @@
+#!/bin/bash
+# LGSM command_ts3.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: Handles updating of teamspeak 3 servers.
+
+local commandname="UPDATE"
+local commandaction="Update"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+fn_update_ts3_dl(){
+	fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
+	fn_dl_extract "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp"
+	echo -e "copying to ${filesdir}...\c"
+	fn_script_log "Copying to ${filesdir}"
+	cp -R "${lgsmdir}/tmp/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}"
+	local exitcode=$?
+	if [ ${exitcode} -eq 0 ]; then
+		fn_print_ok_eol_nl
+	else
+		fn_print_fail_eol_nl
+	fi
+}
+
+fn_update_ts3_currentbuild(){
+	# Gets currentbuild info
+	# Checks currentbuild info is available, if fails a server restart will be forced to generate logs.
+	if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
+		fn_print_error "Checking for update: teamspeak.com"
+		sleep 1
+		fn_print_error_nl "Checking for update: teamspeak.com: No logs with server version found"
+		fn_script_log_error "Checking for update: teamspeak.com: No logs with server version found"
+		sleep 1
+		fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
+		fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart"
+		sleep 1
+		exitbypass=1
+		command_stop.sh
+		exitbypass=1
+		command_start.sh
+		sleep 1
+		# Check again and exit on failure.
+		if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
+			fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found"
+			fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found"
+			core_exit.sh
+		fi
+	fi
+
+	currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
+	if [ -z "${currentbuild}" ]; then
+		fn_print_error_nl "Checking for update: teamspeak.com: Current build version not found"
+		fn_script_log_error "Checking for update: teamspeak.com: Current build version not found"
+		sleep 1
+		fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
+		fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart"
+		exitbypass=1
+		command_stop.sh
+		exitbypass=1
+		command_start.sh
+		currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
+		if [ -z "${currentbuild}" ]; then
+			fn_print_fail_nl "Checking for update: teamspeak.com: Current build version still not found"
+			fn_script_log_fatal "Checking for update: teamspeak.com: Current build version still not found"
+			core_exit.sh
+		fi
+	fi
+}
+
+fn_update_ts3_arch(){
+# Gets the teamspeak server architecture.
+info_distro.sh
+if [ "${arch}" == "x86_64" ]; then
+	ts3arch="amd64"
+elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
+	ts3arch="x86"
+else
+	echo ""
+	fn_print_failure "unknown or unsupported architecture: ${arch}"
+	fn_script_log_fatal "unknown or unsupported architecture: ${arch}"
+	core_exit.sh
+fi
+}
+
+fn_update_ts3_availablebuild(){
+# Gets availablebuild info.
+
+# Creates tmp dir if missing
+if [ ! -d "${lgsmdir}/tmp" ]; then
+	mkdir -p "${lgsmdir}/tmp"
+fi
+
+# Grabs all version numbers but not in correct order.
+wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp"
+
+# Sort version numbers
+cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp"
+
+# Finds directory with most recent server version.
+while read ts3_version_number; do
+	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
+	if [ $? -eq 0 ]; then
+		availablebuild="${ts3_version_number}"
+		# Break while-loop, if the latest release could be found.
+		break
+	fi
+done < "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp"
+
+# Tidy up
+rm -f "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp"
+rm -f "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp"
+
+# Checks availablebuild info is available
+if [ -z "${availablebuild}" ]; then
+	fn_print_fail "Checking for update: teamspeak.com"
+	sleep 1
+	fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
+	fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info"
+	core_exit.sh
+else
+	fn_print_ok_nl "Checking for update: teamspeak.com"
+	fn_script_log_pass "Checking for update: teamspeak.com"
+	sleep 1
+fi
+}
+
+fn_update_ts3_compare(){
+	# Removes dots so if can compare version numbers
+	currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]')
+	availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]')
+
+	if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
+		echo -e "\n"
+		echo -e "Update available:"
+		sleep 1
+		echo -e "	Current build: ${red}${currentbuild} ${architecture}${default}"
+		echo -e "	Available build: ${green}${availablebuild} ${architecture}${default}"
+		echo -e ""
+		sleep 1
+		echo ""
+		echo -en "Applying update.\r"
+		sleep 1
+		echo -en "Applying update..\r"
+		sleep 1
+		echo -en "Applying update...\r"
+		sleep 1
+		echo -en "\n"
+		fn_script_log "Update available"
+		fn_script_log "Current build: ${currentbuild}"
+		fn_script_log "Available build: ${availablebuild}"
+		fn_script_log "${currentbuild} > ${availablebuild}"
+
+		unset updateonstart
+
+		check_status.sh
+		if [ "${status}" == "0" ]; then
+			fn_update_ts3_dl
+			exitbypass=1
+			command_start.sh
+			exitbypass=1
+			command_stop.sh
+		else
+			exitbypass=1
+			command_stop.sh
+			fn_update_ts3_dl
+			exitbypass=1
+			command_start.sh
+		fi
+		alert="update"
+		alert.sh
+	else
+		echo -e "\n"
+		echo -e "No update available:"
+		echo -e "	Current version: ${green}${currentbuild}${default}"
+		echo -e "	Available version: ${green}${availablebuild}${default}"
+		echo -e ""
+		fn_print_ok_nl "No update available"
+		fn_script_log_info "Current build: ${currentbuild}"
+		fn_script_log_info "Available build: ${availablebuild}"
+	fi
+}
+
+
+fn_update_ts3_arch
+if [ "${installer}" == "1" ]; then
+	fn_update_ts3_availablebuild
+	fn_update_ts3_dl
+else
+	# Checks for server update from teamspeak.com using a mirror dl.4players.de.
+	fn_print_dots "Checking for update: teamspeak.com"
+	fn_script_log_info "Checking for update: teamspeak.com"
+	sleep 1
+	fn_update_ts3_currentbuild
+	fn_update_ts3_availablebuild
+	fn_update_ts3_compare
+fi

+ 232 - 166
tests/tests_jc2server.sh

@@ -1,16 +1,29 @@
 #!/bin/bash
-# TravisCI Tests
+# TravisCI Tests: Just Cause 2
 # Server Management Script
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-version="271215"
+version="101716"
+
+if [ -f ".dev-debug" ]; then
+	exec 5>dev-debug.log
+	BASH_XTRACEFD="5"
+	set -x
+fi
 
 #### Variables ####
 
-# Alert Email
+# Notification Alerts
 # (on|off)
+
+# Email
 emailalert="off"
-email=""
+email="email@example.com"
+
+# Pushbullet
+# https://www.pushbullet.com/#settings
+pushbulletalert="off"
+pushbullettoken="accesstoken"
 
 # Steam login
 steamuser="anonymous"
@@ -44,6 +57,9 @@ engine="avalanche"
 rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
 selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 lockselfname=".${servicename}.lock"
+lgsmdir="${rootdir}/lgsm"
+functionsdir="${lgsmdir}/functions"
+libdir="${lgsmdir}/lib"
 filesdir="${rootdir}/serverfiles"
 systemdir="${filesdir}"
 executabledir="${filesdir}"
@@ -59,6 +75,7 @@ logdays="7"
 #gamelogdir="" # No server logs available
 scriptlogdir="${rootdir}/log/script"
 consolelogdir="${rootdir}/log/console"
+consolelogging="on"
 
 scriptlog="${scriptlogdir}/${servicename}-script.log"
 consolelog="${consolelogdir}/${servicename}-console.log"
@@ -70,74 +87,80 @@ consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-
 ##### Script #####
 # Do not edit
 
-fn_getgithubfile(){
-filename=$1
-exec=$2
-fileurl=${3:-$filename}
-filepath="${rootdir}/${filename}"
-filedir=$(dirname "${filepath}")
-# If the function file is missing, then download
-if [ ! -f "${filepath}" ]; then
+# Fetches core_dl for file downloads
+fn_fetch_core_dl(){
+github_file_url_dir="lgsm/functions"
+github_file_url_name="${functionfile}"
+filedir="${functionsdir}"
+filename="${github_file_url_name}"
+githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
+# If the file is missing, then download
+if [ ! -f "${filedir}/${filename}" ]; then
 	if [ ! -d "${filedir}" ]; then
-		mkdir "${filedir}"
+		mkdir -p "${filedir}"
 	fi
-	githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
 	echo -e "    fetching ${filename}...\c"
-	if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
-		:
+	# Check curl exists and use available path
+	curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
+	for curlcmd in ${curlpaths}
+	do
+		if [ -x "${curlcmd}" ]; then
+			break
+		fi
+	done
+	# If curl exists download file
+	if [ "$(basename ${curlcmd})" == "curl" ]; then
+		curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
+		if [ $? -ne 0 ]; then
+			echo -e "\e[0;31mFAIL\e[0m\n"
+			echo "${curlfetch}"
+			echo -e "${githuburl}\n"
+			exit 1
+		else
+			echo -e "\e[0;32mOK\e[0m"
+		fi
 	else
 		echo -e "\e[0;31mFAIL\e[0m\n"
 		echo "Curl is not installed!"
 		echo -e ""
-		exit
-	fi
-	curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
-	if [ $? -ne 0 ]; then
-		echo -e "\e[0;31mFAIL\e[0m\n"
-		echo "${curl}"
-		echo -e "${githuburl}\n"
-		exit
-	else
-		echo -e "\e[0;32mOK\e[0m"
-	fi
-	if [ "${exec}" ]; then
-		chmod +x "${filepath}"
+		exit 1
 	fi
+	chmod +x "${filedir}/${filename}"
 fi
-if [ "${exec}" ]; then
-	source "${filepath}"
-fi
+source "${filedir}/${filename}"
 }
 
-fn_runfunction(){
-	fn_getgithubfile "functions/${functionfile}" 1
+core_dl.sh(){
+# Functions are defined in core_functions.sh.
+functionfile="${FUNCNAME}"
+fn_fetch_core_dl
 }
 
 core_functions.sh(){
 # Functions are defined in core_functions.sh.
 functionfile="${FUNCNAME}"
-fn_runfunction
+fn_fetch_core_dl
 }
 
+core_dl.sh
 core_functions.sh
 
 fn_currentstatus_tmux(){
-pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:")
-if [ "${pid}" != "0" ]; then
-	currentstatus="ONLINE"
-else
-	currentstatus="OFFLINE"
-fi
+	check_status.sh
+	if [ "${status}" != "0" ]; then
+		currentstatus="ONLINE"
+	else
+		currentstatus="OFFLINE"
+	fi
 }
 
 fn_currentstatus_ts3(){
-ts3status=$(${executable} status servercfgfullpathfile=${servercfgfullpath})
-
-if [ "${ts3status}" == "Server is running" ]; then
-	currentstatus="ONLINE"
-else
-	currentstatus="OFFLINE"
-fi
+	check_status.sh
+	if [ "${status}" != "0" ]; then
+		currentstatus="ONLINE"
+	else
+		currentstatus="OFFLINE"
+	fi
 }
 
 fn_setstatus(){
@@ -146,9 +169,9 @@ fn_setstatus(){
 	echo "Required status: ${requiredstatus}"
 	counter=0
 	echo "Current status:  ${currentstatus}"
-    while [  "${requiredstatus}" != "${currentstatus}" ]; do
-    	counter=$((counter+1))
-    	fn_currentstatus_tmux
+	while [  "${requiredstatus}" != "${currentstatus}" ]; do
+		counter=$((counter+1))
+		fn_currentstatus_tmux
 		echo -ne "New status:  ${currentstatus}\\r"
 
 		if [ "${requiredstatus}" == "ONLINE" ]; then
@@ -171,6 +194,44 @@ fn_setstatus(){
     sleep 0.5
 }
 
+# End of every test will expect the result to either pass or fail
+# If the script does not do as intended the whole test will fail
+# if excpecting a pass
+fn_test_result_pass(){
+	if [ $? != 0 ]; then
+		echo "================================="
+		echo "Expected result: PASS"
+		echo "Actual result: FAIL"
+		fn_print_fail_nl "TEST FAILED"
+		exitcode=1
+		core_exit.sh
+	else
+		echo "================================="
+		echo "Expected result: PASS"
+		echo "Actual result: PASS"
+		fn_print_ok_nl "TEST PASSED"
+		echo ""
+	fi
+}
+
+# if excpecting a fail
+fn_test_result_fail(){
+	if [ $? == 0 ]; then
+		echo "================================="
+		echo "Expected result: FAIL"
+		echo "Actual result: PASS"
+		fn_print_fail_nl "TEST FAILED"
+		exitcode=1
+		core_exit.sh
+	else
+		echo "================================="
+		echo "Expected result: FAIL"
+		echo "Actual result: FAIL"
+		fn_print_ok_nl "TEST PASSED"
+		echo ""
+	fi
+}
+
 echo "================================="
 echo "TravisCI Tests"
 echo "Linux Game Server Manager"
@@ -178,308 +239,313 @@ echo "by Daniel Gibbs"
 echo "https://gameservermanagers.com"
 echo "================================="
 echo ""
-sleep 1
 echo "================================="
 echo "Server Tests"
 echo "Using: ${gamename}"
 echo "Testing Branch: $TRAVIS_BRANCH"
 echo "================================="
 echo ""
-sleep 1
-mkdir ${rootdir}
 
+echo "0.1 - Create log dir's"
+echo "================================="
+echo "Description:"
+echo "Create log dir's"
+echo ""
+(install_logs.sh)
 
 
+echo "0.2 - Enable dev-debug"
+echo "================================="
+echo "Description:"
+echo "Enable dev-debug"
+echo ""
+(command_dev_debug.sh)
+fn_test_result_pass
+
 echo "1.0 - start - no files"
 echo "================================="
 echo "Description:"
 echo "test script reaction to missing server files."
+echo "Command: ./jc2server start"
 echo ""
 (command_start.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "1.1 - getopt"
 echo "================================="
 echo "Description:"
 echo "displaying options messages."
+echo "Command: ./jc2server"
 echo ""
 (core_getopt.sh)
+fn_test_result_pass
+
 echo ""
-echo "Test complete!"
-sleep 1
+echo "1.2 - getopt with incorrect args"
+echo "================================="
+echo "Description:"
+echo "displaying options messages."
+echo "Command: ./jc2server abc123"
 echo ""
+getopt="abc123"
+(core_getopt.sh)
+fn_test_result_fail
 
-
-
+echo ""
 echo "2.0 - install"
 echo "================================="
 echo "Description:"
 echo "install ${gamename} server."
-fn_autoinstall
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
+echo "Command: ./jc2server auto-install"
+(fn_autoinstall)
+fn_test_result_pass
 
 
+echo ""
 echo "3.1 - start"
 echo "================================="
 echo "Description:"
 echo "start ${gamename} server."
+echo "Command: ./jc2server start"
 requiredstatus="OFFLINE"
 fn_setstatus
-command_start.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_start.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.2 - start - online"
 echo "================================="
 echo "Description:"
 echo "start ${gamename} server while already running."
+echo "Command: ./jc2server start"
 requiredstatus="ONLINE"
 fn_setstatus
 (command_start.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "3.3 - start - updateonstart"
 echo "================================="
 echo "Description:"
 echo "will update server on start."
+echo "Command: ./jc2server start"
 requiredstatus="OFFLINE"
 fn_setstatus
-(
-	updateonstart="on"
-	command_start.sh
-)
-echo ""
-echo "Test complete!"
-sleep 1
+(updateonstart="on";command_start.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.4 - stop"
 echo "================================="
 echo "Description:"
 echo "stop ${gamename} server."
+echo "Command: ./jc2server stop"
 requiredstatus="ONLINE"
 fn_setstatus
-command_stop.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_stop.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.5 - stop - offline"
 echo "================================="
 echo "Description:"
 echo "stop ${gamename} server while already stopped."
+echo "Command: ./jc2server stop"
 requiredstatus="OFFLINE"
 fn_setstatus
 (command_stop.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "3.6 - restart"
 echo "================================="
 echo "Description:"
 echo "restart ${gamename}."
+echo "Command: ./jc2server restart"
 requiredstatus="ONLINE"
 fn_setstatus
-fn_restart
-echo ""
-echo "Test complete!"
-sleep 1
+(command_restart.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.7 - restart - offline"
 echo "================================="
 echo "Description:"
 echo "restart ${gamename} while already stopped."
+echo "Command: ./jc2server restart"
 requiredstatus="OFFLINE"
 fn_setstatus
-fn_restart
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
-
+(command_restart.sh)
+fn_test_result_pass
 
 echo "4.1 - update"
 echo "================================="
 echo "Description:"
 echo "check for updates."
+echo "Command: ./jc2server update"
 requiredstatus="OFFLINE"
 fn_setstatus
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_update.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.2 - update  - change buildid"
 echo "================================="
 echo "Description:"
 echo "change the buildid tricking SteamCMD to update."
+echo "Command: ./jc2server update"
 requiredstatus="OFFLINE"
 fn_setstatus
 fn_print_info_nl "changed buildid to 0."
-sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
+sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf"
+(command_update.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.3 - update  - change buildid - online"
 echo "================================="
 echo "Description:"
 echo "change the buildid tricking SteamCMD to update server while already running."
+echo "Command: ./jc2server update"
 requiredstatus="ONLINE"
 fn_setstatus
 fn_print_info_nl "changed buildid to 0."
-sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
+sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf"
+(command_update.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.4 - update  - remove appmanifest file"
 echo "================================="
 echo "Description:"
 echo "removing appmanifest file will cause script to repair."
+echo "Command: ./jc2server update"
 requiredstatus="OFFLINE"
 fn_setstatus
 fn_print_info_nl "removed appmanifest_${appid}.acf."
 rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf"
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_update.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.5 - force-update"
 echo "================================="
 echo "Description:"
 echo "force-update bypassing update check."
+echo "Command: ./jc2server force-update"
 requiredstatus="OFFLINE"
 fn_setstatus
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(forceupdate=1;command_update.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.6 - force-update - online"
 echo "================================="
 echo "Description:"
 echo "force-update bypassing update check server while already running."
+echo "Command: ./jc2server force-update"
 requiredstatus="ONLINE"
 fn_setstatus
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(forceupdate=1;command_update.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.7 - validate"
 echo "================================="
 echo "Description:"
 echo "validate server files."
+echo "Command: ./jc2server validate"
 requiredstatus="OFFLINE"
 fn_setstatus
-command_validate.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_validate.sh)
+fn_test_result_pass
+
 echo ""
 echo "4.8 - validate - online"
 echo "================================="
 echo "Description:"
 echo "validate server files while server while already running."
+echo ""
+echo "Command: ./jc2server validate"
 requiredstatus="ONLINE"
 fn_setstatus
-command_validate.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
-
+(command_validate.sh)
+fn_test_result_pass
 
+echo ""
 echo "5.1 - monitor - online"
 echo "================================="
 echo "Description:"
 echo "run monitor server while already running."
+echo "Command: ./jc2server monitor"
 requiredstatus="ONLINE"
 fn_setstatus
 (command_monitor.sh)
+fn_test_result_pass
+
+
 echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-echo "5.2 - monitor - offline - no lockfile"
+echo "5.2 - monitor - offline - with lockfile"
 echo "================================="
 echo "Description:"
-echo "run monitor while server is offline with no lockfile."
+echo "run monitor while server is offline with lockfile."
+echo "Command: ./jc2server monitor"
 requiredstatus="OFFLINE"
 fn_setstatus
+fn_print_info_nl "creating lockfile."
+date > "${rootdir}/${lockselfname}"
 (command_monitor.sh)
+fn_test_result_pass
+
+
 echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-echo "5.3 - monitor - offline - with lockfile"
+echo "5.3 - monitor - offline - no lockfile"
 echo "================================="
 echo "Description:"
 echo "run monitor while server is offline with no lockfile."
+echo "Command: ./jc2server monitor"
 requiredstatus="OFFLINE"
 fn_setstatus
-fn_print_info_nl "creating lockfile."
-date > "${rootdir}/${lockselfname}"
 (command_monitor.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "5.4 - monitor - gsquery.py failure"
 echo "================================="
 echo "Description:"
 echo "gsquery.py will fail to query port."
+echo "Command: ./jc2server monitor"
 requiredstatus="ONLINE"
 fn_setstatus
 sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
 (command_monitor.sh)
+fn_test_result_fail
 echo ""
-fn_print_info_nl "Reseting ${servercfg}."
+fn_print_info_nl "Re-generating ${servercfg}."
 install_config.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
-
+echo "================================="
 
+echo ""
 echo "6.0 - details"
 echo "================================="
 echo "Description:"
 echo "display details."
+echo "Command: ./jc2server details"
 requiredstatus="ONLINE"
 fn_setstatus
-command_details.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
+(command_details.sh)
+fn_test_result_pass
 
+echo ""
 echo "================================="
 echo "Server Tests - Complete!"
 echo "Using: ${gamename}"
 echo "================================="
-echo ""
 requiredstatus="OFFLINE"
 fn_setstatus
 sleep 1
 fn_print_info "Tidying up directories."
 sleep 1
-rm -rfv ${serverfiles}
-echo "END"
-
+rm -rfv "${serverfiles}"
+core_exit.sh

+ 200 - 155
tests/tests_ts3server.sh

@@ -1,20 +1,46 @@
 #!/bin/bash
-# TravisCI Tests
+# TravisCI Tests: Teamspeak 3
 # Server Management Script
 # Author: Daniel Gibbs
 # Website: https://gameservermanagers.com
-version="071115"
+version="101716"
+
+if [ -f ".dev-debug" ]; then
+	exec 5>dev-debug.log
+	BASH_XTRACEFD="5"
+	set -x
+fi
 
 #### Variables ####
 
-# Alert Email
+# Notification Alerts
 # (on|off)
+
+# Email
 emailalert="off"
-email=""
+email="email@example.com"
+
+# Pushbullet
+# https://www.pushbullet.com/#settings
+pushbulletalert="off"
+pushbullettoken="accesstoken"
 
 # Start Variables
 updateonstart="off"
 
+fn_parms(){
+parms=""
+}
+
+#### Advanced Variables ####
+
+# Github Branch Select
+# Allows for the use of different function files
+# from a different repo and/or branch.
+githubuser="dgibbs64"
+githubrepo="linuxgsm"
+githubbranch="$TRAVIS_BRANCH"
+
 # Server Details
 gamename="Teamspeak 3"
 servername="Teamspeak 3 Server"
@@ -24,6 +50,9 @@ servicename="ts3-server"
 rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
 selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 lockselfname=".${servicename}.lock"
+lgsmdir="${rootdir}/lgsm"
+functionsdir="${lgsmdir}/functions"
+libdir="${lgsmdir}/lib"
 filesdir="${rootdir}/serverfiles"
 systemdir="${filesdir}"
 executabledir="${filesdir}"
@@ -34,7 +63,6 @@ servercfgfullpath="${servercfgdir}/${servercfg}"
 servercfgdefault="${servercfgdir}/lgsm-default.ini"
 backupdir="${rootdir}/backups"
 
-
 # Logging
 logdays="7"
 gamelogdir="${filesdir}/logs"
@@ -45,67 +73,65 @@ emaillog="${scriptlogdir}/${servicename}-email.log"
 
 scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
 
-#### Advanced Variables ####
-
-# Github Branch Select
-# Allows for the use of different function files
-# from a different repo and/or branch.
-githubuser="dgibbs64"
-githubrepo="linuxgsm"
-githubbranch="$TRAVIS_BRANCH"
-
 ##### Script #####
 # Do not edit
 
-fn_getgithubfile(){
-filename=$1
-exec=$2
-fileurl=${3:-$filename}
-filepath="${rootdir}/${filename}"
-filedir=$(dirname "${filepath}")
-# If the function file is missing, then download
-if [ ! -f "${filepath}" ]; then
+# Fetches core_dl for file downloads
+fn_fetch_core_dl(){
+github_file_url_dir="lgsm/functions"
+github_file_url_name="${functionfile}"
+filedir="${functionsdir}"
+filename="${github_file_url_name}"
+githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
+# If the file is missing, then download
+if [ ! -f "${filedir}/${filename}" ]; then
 	if [ ! -d "${filedir}" ]; then
-		mkdir "${filedir}"
+		mkdir -p "${filedir}"
 	fi
-	githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
 	echo -e "    fetching ${filename}...\c"
-	if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
-		:
+	# Check curl exists and use available path
+	curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
+	for curlcmd in ${curlpaths}
+	do
+		if [ -x "${curlcmd}" ]; then
+			break
+		fi
+	done
+	# If curl exists download file
+	if [ "$(basename ${curlcmd})" == "curl" ]; then
+		curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
+		if [ $? -ne 0 ]; then
+			echo -e "\e[0;31mFAIL\e[0m\n"
+			echo "${curlfetch}"
+			echo -e "${githuburl}\n"
+			exit 1
+		else
+			echo -e "\e[0;32mOK\e[0m"
+		fi
 	else
 		echo -e "\e[0;31mFAIL\e[0m\n"
 		echo "Curl is not installed!"
 		echo -e ""
-		exit
-	fi
-	curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
-	if [ $? -ne 0 ]; then
-		echo -e "\e[0;31mFAIL\e[0m\n"
-		echo "${curl}"
-		echo -e "${githuburl}\n"
-		exit
-	else
-		echo -e "\e[0;32mOK\e[0m"
+		exit 1
 	fi
-	if [ "${exec}" ]; then
-		chmod +x "${filepath}"
-	fi
-fi
-if [ "${exec}" ]; then
-	source "${filepath}"
+	chmod +x "${filedir}/${filename}"
 fi
+source "${filedir}/${filename}"
 }
 
-fn_runfunction(){
-	fn_getgithubfile "functions/${functionfile}" 1
+core_dl.sh(){
+# Functions are defined in core_functions.sh.
+functionfile="${FUNCNAME}"
+fn_fetch_core_dl
 }
 
 core_functions.sh(){
 # Functions are defined in core_functions.sh.
 functionfile="${FUNCNAME}"
-fn_runfunction
+fn_fetch_core_dl
 }
 
+core_dl.sh
 core_functions.sh
 
 fn_currentstatus_tmux(){
@@ -118,7 +144,7 @@ fn_currentstatus_tmux(){
 }
 
 fn_currentstatus_ts3(){
-check_status.sh
+	check_status.sh
 	if [ "${status}" != "0" ]; then
 		currentstatus="ONLINE"
 	else
@@ -132,15 +158,15 @@ fn_setstatus(){
 	echo "Required status: ${requiredstatus}"
 	counter=0
 	echo "Current status:  ${currentstatus}"
-    while [  "${requiredstatus}" != "${currentstatus}" ]; do
-    	counter=$((counter+1))
-    	fn_currentstatus_ts3
+	while [  "${requiredstatus}" != "${currentstatus}" ]; do
+		counter=$((counter+1))
+		fn_currentstatus_ts3
 		echo -ne "New status:  ${currentstatus}\\r"
 
 		if [ "${requiredstatus}" == "ONLINE" ]; then
-			(command_start.sh)
+			(command_start.sh > /dev/null 2>&1)
 		else
-			(command_stop.sh)
+			(command_stop.sh > /dev/null 2>&1)
 		fi
     	if [ "${counter}" -gt "5" ]; then
     		currentstatus="FAIL"
@@ -157,6 +183,44 @@ fn_setstatus(){
     sleep 0.5
 }
 
+# End of every test will expect the result to either pass or fail
+# If the script does not do as intended the whole test will fail
+# if excpecting a pass
+fn_test_result_pass(){
+	if [ $? != 0 ]; then
+		echo "================================="
+		echo "Expected result: PASS"
+		echo "Actual result: FAIL"
+		fn_print_fail_nl "TEST FAILED"
+		exitcode=1
+		core_exit.sh
+	else
+		echo "================================="
+		echo "Expected result: PASS"
+		echo "Actual result: PASS"
+		fn_print_ok_nl "TEST PASSED"
+		echo ""
+	fi
+}
+
+# if excpecting a fail
+fn_test_result_fail(){
+	if [ $? == 0 ]; then
+		echo "================================="
+		echo "Expected result: FAIL"
+		echo "Actual result: PASS"
+		fn_print_fail_nl "TEST FAILED"
+		exitcode=1
+		core_exit.sh
+	else
+		echo "================================="
+		echo "Expected result: FAIL"
+		echo "Actual result: FAIL"
+		fn_print_ok_nl "TEST PASSED"
+		echo ""
+	fi
+}
+
 echo "================================="
 echo "TravisCI Tests"
 echo "Linux Game Server Manager"
@@ -164,232 +228,213 @@ echo "by Daniel Gibbs"
 echo "https://gameservermanagers.com"
 echo "================================="
 echo ""
-sleep 1
 echo "================================="
 echo "Server Tests"
 echo "Using: ${gamename}"
+echo "Testing Branch: $TRAVIS_BRANCH"
 echo "================================="
 echo ""
-sleep 1
 
+echo "0.1 - Create log dir's"
+echo "================================="
+echo "Description:"
+echo "Create log dir's"
+echo ""
+(install_logs.sh)
 
 
+echo "0.2 - Enable dev-debug"
+echo "================================="
+echo "Description:"
+echo "Enable dev-debug"
+echo ""
+(command_dev_debug.sh)
+fn_test_result_pass
+
 echo "1.0 - start - no files"
 echo "================================="
 echo "Description:"
 echo "test script reaction to missing server files."
+echo "Command: ./ts3server start"
 echo ""
 (command_start.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "1.1 - getopt"
 echo "================================="
 echo "Description:"
 echo "displaying options messages."
+echo "Command: ./ts3server"
 echo ""
 (core_getopt.sh)
+fn_test_result_pass
+
 echo ""
-echo "Test complete!"
-sleep 1
+echo "1.2 - getopt with incorrect args"
+echo "================================="
+echo "Description:"
+echo "displaying options messages."
+echo "Command: ./ts3server abc123"
 echo ""
+getopt="abc123"
+(core_getopt.sh)
+fn_test_result_fail
 
-
-
+echo ""
 echo "2.0 - install"
 echo "================================="
 echo "Description:"
 echo "install ${gamename} server."
-fn_autoinstall
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
+echo "Command: ./ts3server auto-install"
+(fn_autoinstall)
+fn_test_result_pass
 
 
+echo ""
 echo "3.1 - start"
 echo "================================="
 echo "Description:"
 echo "start ${gamename} server."
+echo "Command: ./ts3server start"
 requiredstatus="OFFLINE"
 fn_setstatus
-command_start.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_start.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.2 - start - online"
 echo "================================="
 echo "Description:"
 echo "start ${gamename} server while already running."
+echo "Command: ./ts3server start"
 requiredstatus="ONLINE"
 fn_setstatus
 (command_start.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "3.3 - start - updateonstart"
 echo "================================="
 echo "Description:"
 echo "will update server on start."
+echo "Command: ./ts3server start"
 requiredstatus="OFFLINE"
 fn_setstatus
-(
-	updateonstart="on"
-	command_start.sh
-)
-echo ""
-echo "Test complete!"
-sleep 1
+(updateonstart="on";command_start.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.4 - stop"
 echo "================================="
 echo "Description:"
 echo "stop ${gamename} server."
+echo "Command: ./ts3server stop"
 requiredstatus="ONLINE"
 fn_setstatus
-command_stop.sh
-echo ""
-echo "Test complete!"
-sleep 1
+(command_stop.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.5 - stop - offline"
 echo "================================="
 echo "Description:"
 echo "stop ${gamename} server while already stopped."
+echo "Command: ./ts3server stop"
 requiredstatus="OFFLINE"
 fn_setstatus
 (command_stop.sh)
-echo ""
-echo "Test complete!"
-sleep 1
+fn_test_result_fail
+
 echo ""
 echo "3.6 - restart"
 echo "================================="
 echo "Description:"
 echo "restart ${gamename}."
+echo "Command: ./ts3server restart"
 requiredstatus="ONLINE"
 fn_setstatus
-fn_restart
-echo ""
-echo "Test complete!"
-sleep 1
+(command_restart.sh)
+fn_test_result_pass
+
 echo ""
 echo "3.7 - restart - offline"
 echo "================================="
 echo "Description:"
 echo "restart ${gamename} while already stopped."
+echo "Command: ./ts3server restart"
 requiredstatus="OFFLINE"
 fn_setstatus
-fn_restart
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
-
+(command_restart.sh)
+fn_test_result_pass
 
 echo "4.1 - update"
 echo "================================="
 echo "Description:"
 echo "check for updates."
+echo "Command: ./jc2server update"
 requiredstatus="OFFLINE"
 fn_setstatus
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-echo "4.1 - update - old version"
-echo "================================="
-echo "Description:"
-echo "change the version number tricking LGSM to update."
-requiredstatus="OFFLINE"
-sed -i 's/[0-9]\+/0/g' ${gamelogdir}/ts3server*_0.log
-fn_setstatus
-update_check.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
+(command_update.sh)
+fn_test_result_pass
 
+echo ""
 echo "5.1 - monitor - online"
 echo "================================="
 echo "Description:"
 echo "run monitor server while already running."
+echo "Command: ./ts3server monitor"
 requiredstatus="ONLINE"
 fn_setstatus
 (command_monitor.sh)
+fn_test_result_pass
+
+
 echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-echo "5.2 - monitor - offline - no lockfile"
-echo "================================="
-echo "Description:"
-echo "run monitor while server is offline with no lockfile."
-requiredstatus="OFFLINE"
-fn_setstatus
-(command_monitor.sh)
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-echo "5.3 - monitor - offline - with lockfile"
+echo "5.2 - monitor - offline - with lockfile"
 echo "================================="
 echo "Description:"
-echo "run monitor while server is offline with no lockfile."
+echo "run monitor while server is offline with lockfile."
+echo "Command: ./ts3server monitor"
 requiredstatus="OFFLINE"
 fn_setstatus
 fn_print_info_nl "creating lockfile."
 date > "${rootdir}/${lockselfname}"
 (command_monitor.sh)
+fn_test_result_pass
+
+
 echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-echo "5.4 - monitor - gsquery.py failure"
+echo "5.3 - monitor - offline - no lockfile"
 echo "================================="
 echo "Description:"
-echo "gsquery.py will fail to query port."
-requiredstatus="ONLINE"
+echo "run monitor while server is offline with no lockfile."
+echo "Command: ./ts3server monitor"
+requiredstatus="OFFLINE"
 fn_setstatus
-sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
 (command_monitor.sh)
-echo ""
-fn_print_info_nl "Reseting ${servercfg}."
-install_config.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
-
-
+fn_test_result_fail
 
+echo ""
 echo "6.0 - details"
 echo "================================="
 echo "Description:"
 echo "display details."
+echo "Command: ./ts3server details"
 requiredstatus="ONLINE"
 fn_setstatus
-command_details.sh
-echo ""
-echo "Test complete!"
-sleep 1
-echo ""
+(command_details.sh)
+fn_test_result_pass
 
+echo ""
 echo "================================="
 echo "Server Tests - Complete!"
 echo "Using: ${gamename}"
 echo "================================="
-echo ""
 requiredstatus="OFFLINE"
 fn_setstatus
 sleep 1
 fn_print_info "Tidying up directories."
 sleep 1
-rm -rfv ${serverfiles}
-echo "END"
+rm -rfv "${serverfiles}"
+core_exit.sh