Beispiel #1
0
        private static void UpdateAtlas(AtlasServerManager AtlasMgr, string UpdateVersion)
        {
            AtlasMgr.FirstDl = false;

            if (AtlasMgr.DebugCheck.Checked)
            {
                AtlasMgr.Log("[Atlas->Debug] " + UpdatePaths.Count + " Update Paths found");
            }
            foreach (string UpdatePath in UpdatePaths)
            {
                AtlasMgr.Log("[Atlas] Updating Path: " + UpdatePath);
                UpdateProcess = new Process()
                {
                    StartInfo = new ProcessStartInfo(AtlasMgr.SteamPath + "steamcmd.exe", "+@NoPromptForPassword 1 +@sSteamCmdForcePlatformType windows +login anonymous +force_install_dir \"" + UpdatePath + "\" +app_update 1006030 validate +quit")
                    {
                        UseShellExecute        = false,
                        RedirectStandardOutput = !AtlasMgr.SteamWindowCheck.Checked,
                        CreateNoWindow         = !AtlasMgr.SteamWindowCheck.Checked,
                        WorkingDirectory       = AtlasMgr.SteamPath
                    }
                };

                if (!AtlasMgr.SteamWindowCheck.Checked)
                {
                    UpdateProcess.OutputDataReceived += (s, e) => UpdateData(e.Data);
                }
                UpdateProcess.Start();
                if (!AtlasMgr.SteamWindowCheck.Checked)
                {
                    UpdateProcess.BeginOutputReadLine();
                }
                UpdateProcess.WaitForExit();
            }
            UpdatePaths.Clear();
        }
        public static void CheckServerStatus(AtlasServerManager AtlasMgr, CancellationToken token)
        {
            int  ServerStatus = 0, SleepTime = 3000;
            bool SavedAfterLaunch = false;

            while (true)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }
                AtlasMgr.Invoke((System.Windows.Forms.MethodInvoker) delegate()
                {
                    if (!ServerUpdater.Updating && AtlasMgr.BootWhenOffCheck.Checked)
                    {
                        foreach (ArkServerListViewItem ASLVI in AtlasMgr.ServerList.Items)
                        {
                            if (ASLVI.Checked && (ServerStatus = ASLVI.GetServerData().IsRunning(AtlasMgr)) != 1)
                            {
                                switch (ServerStatus)
                                {
                                case 0:
                                    AtlasMgr.Log("Server: " + ASLVI.Text + " Was Offline Booting Now, Process was not running!");
                                    break;

                                case 2:
                                    AtlasMgr.Log("Server: " + ASLVI.Text + " Was Offline Booting Now, Query Port was not running!");
                                    break;

                                case 3:
                                    AtlasMgr.Log("Server: " + ASLVI.Text + " Booting Now!");
                                    break;

                                case 4:
                                    AtlasMgr.Log("Server: " + ASLVI.Text + " Game Port is offline Attempting Rcon Save Please wait 1 minute!");
                                    continue;
                                }
                                ASLVI.GetServerData().StartServer();
                                SavedAfterLaunch = false;
                                if (AtlasMgr.StartupDelayNum.Value > 0)
                                {
                                    Thread.Sleep((int)AtlasMgr.StartupDelayNum.Value * 1000);
                                }
                            }
                            ASLVI.UpdateStatus();
                        }

                        if (!SavedAfterLaunch)
                        {
                            SavedAfterLaunch = true;
                            Registry.SaveRegConfig(AtlasMgr);
                        }
                    }
                    SleepTime = (int)AtlasMgr.numServerMonitor.Value * 1000;
                });
                Thread.Sleep(SleepTime);
            }
        }
Beispiel #3
0
        public static void BackupConfigs(AtlasServerManager AtlasMgr)
        {
            List <string> UpdatePaths = new List <string>();

            foreach (ArkServerListViewItem ASLVI in AtlasMgr.ServerList.Items)
            {
                string UpdatePath = ASLVI.GetServerData().ServerPath;
                if (UpdatePath.StartsWith("./") || UpdatePath.StartsWith(@".\"))
                {
                    UpdatePath = UpdatePath.Replace("./", System.AppDomain.CurrentDomain.BaseDirectory).Replace(@".\", System.AppDomain.CurrentDomain.BaseDirectory).Replace("//", "/").Replace(@"\\", @"\");
                }
                if (!Directory.Exists(Path.GetDirectoryName(UpdatePath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(UpdatePath));
                }
                if (UpdatePath.Contains(@"ShooterGame\Binaries\Win64"))
                {
                    UpdatePath = Regex.Split(UpdatePath, "\\ShooterGame")[0];
                }
                if (!UpdatePaths.Contains(UpdatePath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\')))
                {
                    UpdatePaths.Add(UpdatePath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\'));
                }
            }

            string BackupPath, FilesPath;

            string[] Files;
            foreach (string UpdatePath in UpdatePaths)
            {
                AtlasMgr.Log("[Atlas] Backing up INI and DB Configs at Path: " + UpdatePath);
                BackupPath = Path.Combine(UpdatePath + Path.DirectorySeparatorChar, @"ConfigRestore\");
                if (!Directory.Exists(BackupPath))
                {
                    Directory.CreateDirectory(BackupPath);
                }
                FilesPath = Path.Combine(UpdatePath + Path.DirectorySeparatorChar, @"ShooterGame\Config\");
                Files     = Directory.GetFiles(FilesPath, "*.ini", SearchOption.TopDirectoryOnly);
                foreach (string file in Files)
                {
                    File.Copy(file, BackupPath + Path.GetFileName(file), true);
                }

                FilesPath = Path.Combine(UpdatePath + Path.DirectorySeparatorChar, @"AtlasTools\RedisDatabase\");

                Files = Directory.GetFiles(FilesPath, "*.conf", SearchOption.TopDirectoryOnly);
                foreach (string file in Files)
                {
                    File.Copy(file, BackupPath + Path.GetFileName(file), true);
                }
            }

            AtlasMgr.Log("[Atlas] Backing up INI and DB Configs Completed!");
        }
Beispiel #4
0
 private static int GetAtlasServerBuildID(AtlasServerManager AtlasMgr)
 {
     try
     {
         if (!Directory.Exists(AtlasMgr.SteamPath))
         {
             Directory.CreateDirectory(AtlasMgr.SteamPath);
         }
         if (!File.Exists(AtlasMgr.SteamPath + "steamcmd.exe"))
         {
             File.WriteAllBytes(AtlasMgr.SteamPath + "steamcmd.exe", Properties.Resources.steamcmd);
         }
         UpdateProcess = new Process()
         {
             StartInfo = new ProcessStartInfo("cmd.exe", "/c steamcmd +@NoPromptForPassword 1 +@sSteamCmdForcePlatformType windows +login anonymous +app_info_update 1 +app_info_print 1006030 +app_info_print 1006030 +app_info_print 1006030 +quit > \"" + AtlasMgr.SteamPath + "CurrentVersion.dat\"")
             {
                 UseShellExecute  = false,
                 CreateNoWindow   = true,
                 WorkingDirectory = AtlasMgr.SteamPath
             }
         };
         UpdateProcess.Start();
         UpdateProcess.WaitForExit();
         if (File.Exists(AtlasMgr.SteamPath + "CurrentVersion.dat"))
         {
             using (StreamReader Sr = new StreamReader(AtlasMgr.SteamPath + "CurrentVersion.dat"))
             {
                 string output     = Sr.ReadToEnd();
                 int    Version    = 0;
                 int    BuildIndex = output.IndexOf("\"buildid\"		\"");
                 if (BuildIndex != -1)
                 {
                     BuildIndex += 12;
                     int EndIndex = output.IndexOf('"', BuildIndex) - BuildIndex;
                     if (EndIndex != -1)
                     {
                         int.TryParse(output.Substring(BuildIndex, EndIndex), out Version);
                     }
                 }
                 return(Version);
             }
         }
         AtlasMgr.Log("[Update] Failed to get latest Version Trying again shortly...");
         Thread.Sleep(5000);
     }
     catch { AtlasMgr.Log("[Update] Failed Checking For Updates..."); }
     return(0);
 }
        public static void CheckServerStatus(object Data)
        {
            AtlasServerManager ArkMgr = (AtlasServerManager)Data;

            while (true)
            {
                if (!ArkMgr.Updating && ArkMgr.checkBootWhenOff.Checked)
                {
                    ArkMgr.Invoke((System.Windows.Forms.MethodInvoker) delegate()
                    {
                        foreach (ArkServerListViewItem ASLVI in ArkMgr.ServerList.Items)
                        {
                            if (ASLVI.Checked && !ASLVI.GetServerData().IsRunning())
                            {
                                ArkMgr.Log("Server Port: " + ASLVI.Text + " Was Offline Booting Now!");
                                if (ASLVI.GetServerData().ServerProcess != null && !ASLVI.GetServerData().ServerProcess.HasExited&& ASLVI.GetServerData().ServerProcess.Id != 0)
                                {
                                    ASLVI.GetServerData().ServerProcess.Kill();
                                    ASLVI.GetServerData().ServerProcess = null;
                                }
                                ASLVI.GetServerData().StartServer();
                            }
                            ASLVI.UpdateStatus();
                        }
                    });
                }
                Thread.Sleep((int)(ArkMgr.numServerMonitor.Value) * 1000);
            }
        }
Beispiel #6
0
        private static void UpdateArk(AtlasServerManager ArkMgr, string UpdateVersion)
        {
            ArkMgr.Invoke((System.Windows.Forms.MethodInvoker) delegate()
            {
                foreach (ArkServerListViewItem ASLVI in ArkMgr.ServerList.Items)
                {
                    string UpdatePath = ASLVI.GetServerData().ServerPath;
                    if (UpdatePath.StartsWith("./") || UpdatePath.StartsWith(@".\"))
                    {
                        UpdatePath = UpdatePath.Replace("./", System.AppDomain.CurrentDomain.BaseDirectory).Replace(@".\", System.AppDomain.CurrentDomain.BaseDirectory).Replace("//", "/").Replace(@"\\", @"\");
                    }

                    if (!Directory.Exists(Path.GetDirectoryName(UpdatePath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(UpdatePath));
                    }

                    if (UpdatePath.Contains(@"ShooterGame\Binaries\Win64"))
                    {
                        UpdatePath = Regex.Split(UpdatePath, "\\ShooterGame")[0];
                    }

                    if (!UpdatePaths.Contains(UpdatePath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\')))
                    {
                        UpdatePaths.Add(UpdatePath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, '\\'));
                    }
                }
            });

            foreach (string UpdatePath in UpdatePaths)
            {
                ArkMgr.Log("[Ark] Updating Path: " + UpdatePath);
                ArkMgr.UpdateProcess = new Process()
                {
                    StartInfo = new ProcessStartInfo(ArkMgr.SteamPath + "steamcmd.exe", "+@NoPromptForPassword 1 +@sSteamCmdForcePlatformType windows +login anonymous +force_install_dir \"" + UpdatePath + "\" +app_update 1006030 validate +quit")
                    {
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        CreateNoWindow         = true,
                        WorkingDirectory       = ArkMgr.SteamPath
                    }
                };
                ArkMgr.UpdateProcess.OutputDataReceived += (s, e) => UpdateData(e.Data);
                ArkMgr.UpdateProcess.Start();
                ArkMgr.UpdateProcess.BeginOutputReadLine();
                ArkMgr.UpdateProcess.WaitForExit();
            }
            if (!UpdateError)
            {
                using (StreamWriter w = new StreamWriter(ArkMgr.SteamPath + "AtlasLatestVersion.txt")) w.WriteLine(UpdateVersion);
            }
        }
Beispiel #7
0
 private static int GetAtlasServerBuildID(AtlasServerManager ArkMgr)
 {
     try
     {
         if (!Directory.Exists(ArkMgr.SteamPath))
         {
             Directory.CreateDirectory(ArkMgr.SteamPath);
         }
         if (!File.Exists(ArkMgr.SteamPath + "steamcmd.exe"))
         {
             File.WriteAllBytes(ArkMgr.SteamPath + "steamcmd.exe", Properties.Resources.steamcmd);
         }
         ArkMgr.UpdateProcess = new Process()
         {
             StartInfo = new ProcessStartInfo(ArkMgr.SteamPath + "steamcmd.exe", "+@NoPromptForPassword 1 +@sSteamCmdForcePlatformType windows +login anonymous +app_info_update 1 +app_info_print 1006030 +app_info_print 1006030 +app_info_print 1006030 +quit")
             {
                 UseShellExecute        = false,
                 RedirectStandardOutput = true,
                 CreateNoWindow         = true,
                 WorkingDirectory       = ArkMgr.SteamPath
             }
         };
         ArkMgr.UpdateProcess.Start();
         string output = ArkMgr.UpdateProcess.StandardOutput.ReadToEnd();
         ArkMgr.UpdateProcess.WaitForExit();
         int Version    = 0;
         int BuildIndex = output.IndexOf("\"buildid\"		\"");
         if (BuildIndex != -1)
         {
             BuildIndex += 12;
             int EndIndex = output.IndexOf('"', BuildIndex) - BuildIndex;
             if (EndIndex != -1)
             {
                 int.TryParse(output.Substring(BuildIndex, EndIndex), out Version);
             }
         }
         return(Version);
     }
     catch { ArkMgr.Log("[Update] Failed Checking For Updates..."); }
     return(0);
 }
Beispiel #8
0
        public static void CheckForUpdates(object Data)
        {
            AtlasServerManager ArkMgr = (AtlasServerManager)Data;

            ArkMgr.Log("[Atlas] Checking for updates, can take up to 30 seconds...");
            string CurrentVersion = "";
            int    UpdateVersion = 0, CurrentVer = 0;

            while (true)
            {
                if (ArkMgr.checkAutoServerUpdate.Checked)
                {
                    UpdateVersion = GetAtlasServerBuildID(ArkMgr);
                    if (UpdateVersion != 0)
                    {
                        if (File.Exists(ArkMgr.SteamPath + "AtlasLatestVersion.txt"))
                        {
                            using (StreamReader r = new StreamReader(ArkMgr.SteamPath + "AtlasLatestVersion.txt")) CurrentVersion = r.ReadLine();
                        }
                        int.TryParse(CurrentVersion, out CurrentVer);
                        if (CurrentVer != UpdateVersion)
                        {
                            ArkMgr.Updating = true;
                            ArkMgr.Log("BuildID " + UpdateVersion + " Released!");
                            if (!SkipAnnounce && Process.GetProcessesByName("ShooterGameServer").Length > 0)
                            {
                                ArkMgr.Log("[Atlas] Update Broadcasting 30 Minutes");
                                BroadCastMessage("Atlas To Version: " + UpdateVersion + ", in 30 Minutes!");
                                Thread.Sleep(900000);
                                ArkMgr.Log("[Atlas] Update Broadcasting 15 Minutes");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + ", in 15 Minutes!");
                                Thread.Sleep(300000);
                                ArkMgr.Log("[Atlas] Update Broadcasting 10 Minutes");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + ", in 10 Minutes!");
                                Thread.Sleep(300000);
                                ArkMgr.Log("[Atlas] Update Broadcasting 5 Minutes");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + ", in 5 Minutes!");
                                Thread.Sleep(180000);
                                ArkMgr.Log("[Atlas] Update Broadcasting 2 Minutes");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + ", in 2 Minutes!");
                                Thread.Sleep(60000);
                                ArkMgr.Log("[Atlas] Update Broadcasting 1 Minute");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + ", in 1 Minute!");
                                Thread.Sleep(30000);
                                ArkMgr.Log("[Atlas] Update Broadcasting 30 Seconds");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + ", in 30 Seconds!");
                                Thread.Sleep(30000);
                                ArkMgr.Log("[Atlas] Update Saving World");
                                BroadCastMessage("Atlas Updating To Version: " + UpdateVersion + "!, Please relaunch and update your games.");
                                Thread.Sleep(5000);
                                if (!SaveWorld())
                                {
                                    ArkMgr.Log("[Atlas] Failed Saving World, Not Updating!");
                                    continue;
                                }
                            }
                            bool ServerStillOpen = true;
                            while (ServerStillOpen)
                            {
                                Thread.Sleep(1000);
                                ServerStillOpen = Process.GetProcessesByName("ShooterGameServer").Length > 0;
                                if (!ServerStillOpen)
                                {
                                    break;
                                }
                            }
                            ArkMgr.Log("[Atlas] Current BuildID: " + CurrentVersion + ", Updating To BuildID: " + UpdateVersion);
                            UpdateArk(ArkMgr, UpdateVersion.ToString());
                            if (UpdateError)
                            {
                                ArkMgr.Log("[Atlas] Update Error, Retrying...");
                                UpdateError = false;
                                continue;
                            }
                            ArkMgr.Log("[Atlas] Updated, Launching Servers!");
                            FirstLaunch = ArkMgr.Updating = false;
                            StartServers(ArkMgr);
                        }
                        else
                        {
                            ArkMgr.Updating = false;
                        }
                    }
                }
                else
                {
                    ArkMgr.Updating = false;
                }
                if (!FirstLaunch)
                {
                    ArkMgr.Log("[Atlas] No updates found, Booting servers!");
                    FirstLaunch = false;
                    StartServers(ArkMgr);
                }
                Thread.Sleep((int)(ArkMgr.numServerUpdate.Value * 60000));
            }
        }
Beispiel #9
0
        public static void CheckForUpdates(AtlasServerManager AtlasMgr, CancellationToken token)
        {
            if (AtlasMgr.checkAutoServerUpdate.Checked || ForcedUpdate)
            {
                AtlasMgr.Log("[Atlas] Checking for updates, can take up to 30 seconds...");
            }
            int UpdateVersion = 0, CurrentVer = 0;

            while (true)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }
                if (AtlasMgr.checkAutoServerUpdate.Checked || ForcedUpdate)
                {
                    if (AtlasMgr.DebugCheck.Checked)
                    {
                        AtlasMgr.Log("[Atlas->Debug] Checking for Update");
                    }
                    UpdateVersion = GetAtlasServerBuildID(AtlasMgr);
                    if (AtlasMgr.DebugCheck.Checked)
                    {
                        AtlasMgr.Log("[Atlas->Debug] Atlas Latest Build: " + UpdateVersion);
                    }
                    if (UpdateVersion != 0)
                    {
                        CurrentVer = GetCurrentBuildID(AtlasMgr);
                        if (AtlasMgr.DebugCheck.Checked)
                        {
                            AtlasMgr.Log("[Atlas->Debug] Atlas Current Build: " + CurrentVer);
                        }
                        if (CurrentVer != UpdateVersion)
                        {
                            Updating = true;
                            AtlasMgr.Log("[Atlas] BuildID " + UpdateVersion + " Released!");
                            if (AtlasMgr.DebugCheck.Checked)
                            {
                                AtlasMgr.Log("[Atlas->Debug] Checking if servers are still online");
                            }
                            bool ServerStillOpen = false;
                            AtlasMgr.Invoke((System.Windows.Forms.MethodInvoker) delegate()
                            {
                                foreach (ArkServerListViewItem ASLVI in AtlasMgr.ServerList.Items)
                                {
                                    if (ASLVI.GetServerData().IsRunning())
                                    {
                                        ServerStillOpen = true;
                                    }
                                }
                            });
                            if (ServerStillOpen)
                            {
                                int SleepTime = (int)AtlasMgr.numServerWarning.Value / 2;
                                AtlasMgr.Log("[Atlas] Update Broadcasting " + (int)AtlasMgr.numServerWarning.Value + " Minutes");
                                SourceRconTools.SendCommandToAll("broadcast " + GenerateUpdateMessage(AtlasMgr, (int)AtlasMgr.numServerWarning.Value));
                                Thread.Sleep(SleepTime * 60000);

                                AtlasMgr.Log("[Atlas] Update Broadcasting " + SleepTime + " Minutes");
                                SourceRconTools.SendCommandToAll("broadcast " + GenerateUpdateMessage(AtlasMgr, SleepTime));
                                SleepTime = (int)AtlasMgr.numServerWarning.Value / 4;
                                Thread.Sleep(SleepTime * 60000);

                                AtlasMgr.Log("[Atlas] Update Broadcasting " + SleepTime + " Minutes");
                                SourceRconTools.SendCommandToAll("broadcast " + GenerateUpdateMessage(AtlasMgr, SleepTime));
                                SleepTime = (int)AtlasMgr.numServerWarning.Value / 4;
                                Thread.Sleep((SleepTime * 60000) - 35000);

                                AtlasMgr.Log("[Atlas] Update Broadcasting 30 Seconds");
                                SourceRconTools.SendCommandToAll("broadcast " + GenerateUpdateMessage(AtlasMgr, 30, "Seconds"));
                                Thread.Sleep(30000);
                                AtlasMgr.Log("[Atlas] Update Saving World");
                                SourceRconTools.SendCommandToAll("broadcast " + AtlasMgr.ServerUpdatingMessage.Text);
                                Thread.Sleep(5000);
                                if (!SourceRconTools.SaveWorld())
                                {
                                    AtlasMgr.Log("[Atlas] Failed Saving World, Not Updating!");
                                    //continue;
                                }
                            }

                            while (ServerStillOpen)
                            {
                                ServerStillOpen = false;
                                AtlasMgr.Invoke((System.Windows.Forms.MethodInvoker) delegate()
                                {
                                    foreach (ArkServerListViewItem ASLVI in AtlasMgr.ServerList.Items)
                                    {
                                        if (ASLVI.GetServerData().IsRunning())
                                        {
                                            ServerStillOpen = true;
                                        }
                                    }
                                });
                                if (!ServerStillOpen)
                                {
                                    break;
                                }
                                Thread.Sleep(3000);
                                if (AtlasMgr.DebugCheck.Checked)
                                {
                                    AtlasMgr.Log("[Atlas->Debug] Waiting for all servers to close");
                                }
                            }
                            AtlasMgr.Log("[Atlas] Current BuildID: " + CurrentVer + ", Updating To BuildID: " + UpdateVersion);
                            UpdateAtlas(AtlasMgr, UpdateVersion.ToString());
                            if (UpdateError)
                            {
                                AtlasMgr.Log("[Atlas] Update Error, Retrying...");
                                UpdateError = false;
                                if (UpdateErrorText.Contains("606") || UpdateErrorText.Contains("602"))
                                {
                                    AtlasServerManager.GetInstance().Log("[Update] Attempting to fix update error!");
                                    try
                                    {
                                        Directory.Delete(AtlasServerManager.GetInstance().SteamPath + @"steamapps\", true);
                                        Directory.Delete(AtlasServerManager.GetInstance().SteamPath + @"steamapps\", true);
                                    }
                                    catch
                                    { }
                                }
                                continue;
                            }

                            if (token.IsCancellationRequested)
                            {
                                Updating = false;
                                break;
                            }
                            AtlasMgr.Log("[Atlas] Updated, Launching Servers if offline!");
                            FirstLaunch = ForcedUpdate = Updating = false;
                            StartServers(AtlasMgr);
                        }
                        else
                        {
                            Updating = false;
                        }
                    }
                }
                else
                {
                    Updating = false;
                }
                if (token.IsCancellationRequested)
                {
                    Updating = false;
                    break;
                }
                if (FirstLaunch)
                {
                    AtlasMgr.Log("[Atlas] No updates found, Booting servers if offline!");
                    FirstLaunch = false;
                    StartServers(AtlasMgr);
                }
                Thread.Sleep((int)(AtlasMgr.numServerUpdate.Value * 60000));
            }
        }