Beispiel #1
0
        public async Task <Process> Start()
        {
            string shipExePath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath);

            if (!File.Exists(shipExePath))
            {
                Error = $"{Path.GetFileName(shipExePath)} not found ({shipExePath})";
                return(null);
            }

            string param = string.IsNullOrWhiteSpace(_serverData.ServerIP) ? string.Empty : $" -MultiHome={_serverData.ServerIP}";

            param += string.IsNullOrWhiteSpace(_serverData.ServerPort) ? string.Empty : $" -Port={_serverData.ServerPort}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerQueryPort) ? string.Empty : $" -QueryPort={_serverData.ServerQueryPort}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerMaxPlayer) ? string.Empty : $" -MaxPlayers={_serverData.ServerMaxPlayer}";
            param += $" {_serverData.ServerParam}" + (ToggleConsole ? " -log" : string.Empty);

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        FileName        = shipExePath,
                        Arguments       = param,
                        WindowStyle     = ProcessWindowStyle.Minimized,
                        UseShellExecute = false
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        FileName               = shipExePath,
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Hidden,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #2
0
        public async Task <Process> Start()
        {
            string configPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "Server.cfg");

            if (!File.Exists(configPath))
            {
                Notice = $"{Path.GetFileName(configPath)} not found ({configPath})";
            }

            string param = $"-batchmode -dedicated {_serverData.ServerParam}";

            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName         = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized,
                        UseShellExecute  = false
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName               = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #3
0
        public async Task <Process> Start()
        {
            string  param = $"-batchmode -nographics -silent-crashes {_serverData.ServerParam}";
            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName         = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized,
                        UseShellExecute  = false
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName               = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #4
0
        public async Task <Process> Start(string param)
        {
            string workingDir = Functions.ServerPath.GetServerFiles(_serverId);
            string hldsPath   = Path.Combine(workingDir, "hlds.exe");

            if (!File.Exists(hldsPath))
            {
                Error = $"hlds.exe not found ({hldsPath})";
                return(null);
            }

            if (string.IsNullOrWhiteSpace(param))
            {
                Error = "Start Parameter not set";
                return(null);
            }

            Process p = new Process
            {
                StartInfo =
                {
                    WorkingDirectory       = workingDir,
                    FileName               = hldsPath,
                    Arguments              = param,
                    WindowStyle            = ProcessWindowStyle.Minimized,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true
                },
                EnableRaisingEvents = true
            };
            var serverConsole = new Functions.ServerConsole(_serverId);

            p.OutputDataReceived += serverConsole.AddOutput;
            p.ErrorDataReceived  += serverConsole.AddOutput;
            p.Start();
            p.BeginOutputReadLine();
            p.BeginErrorReadLine();

            return(p);
        }
Beispiel #5
0
        public async Task <Process> Start()
        {
            string configPath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"AppData\Roaming\SpaceEngineersDedicated", "SpaceEngineers-Dedicated.cfg");

            if (!File.Exists(configPath))
            {
                Notice = $"{Path.GetFileName(configPath)} not found ({configPath})";
            }

            string param = (ToggleConsole ? "-console" : "-noconsole") + " -ignorelastsession";

            param += string.IsNullOrEmpty(_serverData.ServerIP) ? "" : $" -ip {_serverData.ServerIP}";
            param += string.IsNullOrEmpty(_serverData.ServerPort) ? "" : $" -port {_serverData.ServerPort}";
            param += $" {_serverData.ServerParam}";

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Path.GetDirectoryName(Functions.ServerPath.GetServerFiles(_serverData.ServerID, StartPath)),
                        FileName         = Functions.ServerPath.GetServerFiles(_serverData.ServerID,                       StartPath),
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized
                    },
                    EnableRaisingEvents = true
                };
                p.StartInfo.EnvironmentVariables["USERPROFILE"] = Functions.ServerPath.GetServerFiles(_serverData.ServerID);
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Path.GetDirectoryName(Functions.ServerPath.GetServerFiles(_serverData.ServerID, StartPath)),
                        FileName               = Functions.ServerPath.GetServerFiles(_serverData.ServerID,                       StartPath),
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                p.StartInfo.EnvironmentVariables["USERPROFILE"] = Functions.ServerPath.GetServerFiles(_serverData.ServerID);
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #6
0
        public async Task <Process> Start()
        {
            string javaPath = JavaHelper.FindJavaExecutableAbsolutePath();

            if (javaPath.Length == 0)
            {
                Error = "Java is not installed";
                return(null);
            }

            string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID);

            string serverJarPath = Path.Combine(workingDir, "server.jar");

            if (!File.Exists(serverJarPath))
            {
                Error = $"server.jar not found ({serverJarPath})";
                return(null);
            }

            string configPath = Path.Combine(workingDir, "server.properties");

            if (!File.Exists(configPath))
            {
                Notice = $"server.properties not found ({configPath}). Generated a new one.";
            }

            WindowsFirewall firewall = new WindowsFirewall("java.exe", javaPath);

            if (!await firewall.IsRuleExist())
            {
                firewall.AddRule();
            }

            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = workingDir,
                        FileName         = javaPath,
                        Arguments        = $"{_serverData.ServerParam} -jar server.jar nogui",
                        WindowStyle      = ProcessWindowStyle.Minimized,
                        UseShellExecute  = false
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = workingDir,
                        FileName               = javaPath,
                        Arguments              = $"{_serverData.ServerParam} -jar server.jar nogui",
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #7
0
        public async Task <Process> Start()
        {
            string fxServerPath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"server\FXServer.exe");

            if (!File.Exists(fxServerPath))
            {
                Error = $"FXServer.exe not found ({fxServerPath})";
                return(null);
            }

            string citizenPath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"server\citizen");

            if (!Directory.Exists(citizenPath))
            {
                Error = $"Directory citizen not found ({citizenPath})";
                return(null);
            }

            string serverDataPath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, "cfx-server-data-master");

            if (!Directory.Exists(serverDataPath))
            {
                Error = $"Directory cfx-server-data-master not found ({serverDataPath})";
                return(null);
            }

            string configPath = Path.Combine(serverDataPath, "server.cfg");

            if (!File.Exists(configPath))
            {
                Notice = $"server.cfg not found ({configPath})";
            }

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = serverDataPath,
                        FileName         = fxServerPath,
                        Arguments        = $"+set citizen_dir \"{citizenPath}\" {_serverData.ServerParam}",
                        WindowStyle      = ProcessWindowStyle.Minimized
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = serverDataPath,
                        FileName               = fxServerPath,
                        Arguments              = $"+set citizen_dir \"{citizenPath}\" {_serverData.ServerParam}",
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #8
0
        public async Task <Process> Start()
        {
            string hldsPath = Functions.ServerPath.GetServersServerFiles(serverData.ServerID, StartPath);

            if (!File.Exists(hldsPath))
            {
                Error = $"{StartPath} not found ({hldsPath})";
                return(null);
            }

            string configPath = Functions.ServerPath.GetServersServerFiles(serverData.ServerID, Game, "server.cfg");

            if (!File.Exists(configPath))
            {
                Notice = $"server.cfg not found ({configPath})";
            }

            StringBuilder sb = new StringBuilder();

            sb.Append($"-console -game {Game}");
            sb.Append(string.IsNullOrWhiteSpace(serverData.ServerIP) ? "" : $" -ip {serverData.ServerIP}");
            sb.Append(string.IsNullOrWhiteSpace(serverData.ServerPort) ? "" : $" -port {serverData.ServerPort}");
            sb.Append(string.IsNullOrWhiteSpace(serverData.ServerMaxPlayer) ? "" : $" -maxplayers {serverData.ServerMaxPlayer}");
            sb.Append(string.IsNullOrWhiteSpace(serverData.ServerGSLT) ? "" : $" +sv_setsteamaccount {serverData.ServerGSLT}");
            sb.Append(string.IsNullOrWhiteSpace(serverData.ServerParam) ? "" : $" {serverData.ServerParam}");
            sb.Append(string.IsNullOrWhiteSpace(serverData.ServerMap) ? "" : $" +map {serverData.ServerMap}");
            string param = sb.ToString();

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Functions.ServerPath.GetServersServerFiles(serverData.ServerID),
                        FileName         = hldsPath,
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized,
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Functions.ServerPath.GetServersServerFiles(serverData.ServerID),
                        FileName               = hldsPath,
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #9
0
        public async Task <Process> Start()
        {
            string dataPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "galaxies");

            Directory.CreateDirectory(dataPath);

            string param = $"--datapath \"{dataPath}\"";

            param += string.IsNullOrWhiteSpace(_serverData.ServerMap) ? string.Empty : $" --galaxy-name {_serverData.ServerMap}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerName) ? string.Empty : $" --server-name \"{_serverData.ServerName}\"";
            param += string.IsNullOrWhiteSpace(_serverData.ServerIP) ? string.Empty : $" --ip {_serverData.ServerIP}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerPort) ? string.Empty : $" --port {_serverData.ServerPort}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerQueryPort) ? string.Empty : $" --query-port {_serverData.ServerQueryPort}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerMaxPlayer) ? string.Empty : $" --max-players {_serverData.ServerMaxPlayer}";
            param += $" {_serverData.ServerParam}";

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName         = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName               = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #10
0
        public async Task <Process> Start()
        {
            /*
             * string configFile = "SpaceEngineers-Dedicated.cfg";
             * string configPath = Functions.Path.GetServerFiles(_serverData.ServerID, "Config", configFile);
             * if (!File.Exists(configPath))
             * {
             *  Notice = $"{configFile} not found ({configPath})";
             * }
             */

            string param = (ToggleConsole ? "-console" : "-noconsole") + " -ignorelastsession";

            param += (string.IsNullOrEmpty(_serverData.ServerIP)) ? "" : $" -ip {_serverData.ServerIP}";
            param += (string.IsNullOrEmpty(_serverData.ServerPort)) ? "" : $" -port {_serverData.ServerPort}";
            param += $" {_serverData.ServerParam}";


            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        FileName    = Functions.ServerPath.GetServerFiles(_serverData.ServerID, StartPath),
                        Arguments   = param,
                        WindowStyle = ProcessWindowStyle.Minimized
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        FileName               = Functions.ServerPath.GetServerFiles(_serverData.ServerID, StartPath),
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };

                /*
                 * I had tried to change APPDATA value but fail... seems there is no way to change config dir...
                 */
                //Environment.CurrentDirectory = Functions.Path.GetServerFiles(_serverData.ServerID, "Instance");
                //Environment.SetEnvironmentVariable("APPDATA", Functions.Path.GetServerFiles(_serverData.ServerID, "Instance"), EnvironmentVariableTarget.User);
                //Environment.appdata
                //p.StartInfo.EnvironmentVariables["APPDATA"] = Functions.Path.GetServerFiles(_serverData.ServerID, "Instance");
                //p.StartInfo.EnvironmentVariables.Add("AppData", Functions.Path.GetServerFiles(_serverData.ServerID, "Instance"));
                //p.StartInfo.Environment["APPDATA"] = Functions.Path.GetServerFiles(_serverData.ServerID, "Config");
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #11
0
        public async Task <Process> Start()
        {
            string workingDir = Functions.ServerPath.GetServerFiles(_serverData.ServerID);

            string exePath = Path.Combine(workingDir, StartPath);

            if (!File.Exists(exePath))
            {
                Error = $"{Path.GetFileName(exePath)} not found ({exePath})";
                return(null);
            }

            string serverConfigPath = Path.Combine(workingDir, "server.properties");

            if (!File.Exists(serverConfigPath))
            {
                Error = $"{Path.GetFileName(serverConfigPath)} not found ({serverConfigPath})";
                return(null);
            }

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = workingDir,
                        FileName         = exePath,
                        WindowStyle      = ProcessWindowStyle.Minimized,
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = workingDir,
                        FileName               = exePath,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #12
0
        public async Task <Process> Start()
        {
            Java isJavaInstalled = IsJavaJREInstalled();

            if (isJavaInstalled == Java.NotInstall)
            {
                Error = "Java is not installed";
                return(null);
            }

            string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID);

            string serverJarPath = Path.Combine(workingDir, "server.jar");

            if (!File.Exists(serverJarPath))
            {
                Error = $"server.jar not found ({serverJarPath})";
                return(null);
            }

            string configPath = Path.Combine(workingDir, "server.properties");

            if (!File.Exists(configPath))
            {
                Notice = $"server.properties not found ({configPath}). Generated a new one.";
            }

            string javaPath = (isJavaInstalled == Java.InstalledGlobal) ? "java" : "C:\\Program Files (x86)\\Java\\jre1.8.0_231\\bin\\java.exe";

            if (isJavaInstalled == Java.InstalledAbsolute)
            {
                WindowsFirewall firewall = new WindowsFirewall("java.exe", javaPath);
                if (!await firewall.IsRuleExist())
                {
                    firewall.AddRule();
                }
            }

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = workingDir,
                        FileName         = javaPath,
                        Arguments        = $"{_serverData.ServerParam} -jar server.jar nogui",
                        WindowStyle      = ProcessWindowStyle.Minimized,
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = workingDir,
                        FileName               = javaPath,
                        Arguments              = $"{_serverData.ServerParam} -jar server.jar nogui",
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #13
0
        public async Task <Process> Start()
        {
            string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID);

            string phpPath = Path.Combine(workingDir, @"bin\php\php.exe");

            if (!File.Exists(phpPath))
            {
                Error = $"php.exe not found ({phpPath})";
                return(null);
            }

            string PMMPPath = Path.Combine(workingDir, "PocketMine-MP.phar");

            if (!File.Exists(PMMPPath))
            {
                Error = $"PocketMine-MP.phar not found ({PMMPPath})";
                return(null);
            }

            string serverConfigPath = Path.Combine(workingDir, "server.properties");

            if (!File.Exists(serverConfigPath))
            {
                Error = $"server.properties not found ({serverConfigPath})";
                return(null);
            }

            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = workingDir,
                        FileName         = phpPath,
                        Arguments        = @"-c bin\php PocketMine-MP.phar",
                        WindowStyle      = ProcessWindowStyle.Minimized,
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = workingDir,
                        FileName               = phpPath,
                        Arguments              = @"-c bin\php PocketMine-MP.phar",
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #14
0
        public async Task <Process> Start()
        {
            string exePath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath);

            if (!File.Exists(exePath))
            {
                Error = $"{Path.GetFileName(exePath)} not found ({exePath})";
                return(null);
            }

            string param = "-batchmode --nographics";

            param += string.IsNullOrWhiteSpace(_serverData.ServerPort) ? string.Empty : $" -port:{_serverData.ServerPort}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerMaxPlayer) ? string.Empty : $" -players:{_serverData.ServerMaxPlayer}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerMap) ? string.Empty : $" -{_serverData.ServerMap}";
            param += $" {_serverData.ServerParam}";

            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName         = exePath,
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized,
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName               = exePath,
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #15
0
        public async Task <Process> Start()
        {
            string configPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, @"SquadGame\ServerConfig", "Server.cfg");

            if (!File.Exists(configPath))
            {
                Notice = $"{Path.GetFileName(configPath)} not found ({configPath})";
            }

            StringBuilder sb = new StringBuilder();

            sb.Append($"-log");
            sb.Append(string.IsNullOrWhiteSpace(_serverData.ServerIP) ? string.Empty : $" MULTIHOME={_serverData.ServerIP}");
            sb.Append(string.IsNullOrWhiteSpace(_serverData.ServerPort) ? string.Empty : $" Port={_serverData.ServerPort}");
            sb.Append(string.IsNullOrWhiteSpace(_serverData.ServerQueryPort) ? string.Empty : $" QueryPort={_serverData.ServerQueryPort}");
            sb.Append(string.IsNullOrWhiteSpace(_serverData.ServerMaxPlayer) ? string.Empty : $" FIXEDMAXPLAYERS={_serverData.ServerMaxPlayer}");
            sb.Append(string.IsNullOrWhiteSpace(_serverData.ServerParam) ? string.Empty : $" {_serverData.ServerParam}");
            string param = sb.ToString();

            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName         = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized,
                        UseShellExecute  = false
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID),
                        FileName               = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath),
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #16
0
        public async Task <Process> Start()
        {
            string exeName    = "7DaysToDieServer.exe";
            string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID);
            string exePath    = Path.Combine(workingDir, exeName);

            if (!File.Exists(exePath))
            {
                Error = $"{exeName} not found ({exePath})";
                return(null);
            }

            string configPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "serverconfig.xml");

            if (!File.Exists(configPath))
            {
                Notice = $"serverconfig.xml not found ({configPath})";
            }

            string logFile = @"7DaysToDieServer_Data\output_log_dedi__" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".txt";
            string param   = $"-logfile \"{Path.Combine(workingDir, logFile)}\" -quit -batchmode -nographics -configfile=serverconfig.xml -dedicated {_serverData.ServerParam}";

            WindowsFirewall firewall = new WindowsFirewall(exeName, exePath);

            if (!await firewall.IsRuleExist())
            {
                firewall.AddRule();
            }

            Process p;

            if (!AllowsEmbedConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = workingDir,
                        FileName         = exePath,
                        Arguments        = param,
                        WindowStyle      = ProcessWindowStyle.Minimized
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory       = workingDir,
                        FileName               = exePath,
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Minimized,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }
Beispiel #17
0
        public async Task <Process> Start()
        {
            string exeFile = "MordhauServer.exe";
            string exePath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, exeFile);

            if (!File.Exists(exePath))
            {
                Error = $"{exeFile} not found ({exePath})";
                return(null);
            }

            string          shipExeFile = "MordhauServer-Win64-Shipping.exe";
            string          shipExePath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"Mordhau\Binaries\Win64", shipExeFile);
            WindowsFirewall firewall    = new WindowsFirewall(shipExeFile, shipExePath);

            if (!await firewall.IsRuleExist())
            {
                firewall.AddRule();
            }

            if (!File.Exists(shipExePath))
            {
                Error = $"{shipExeFile} not found ({shipExePath})";
                return(null);
            }

            string configFile = "Game.ini";
            string configPath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"Mordhau\Saved\Config\WindowsServer", configFile);

            if (!File.Exists(configPath))
            {
                Notice = $"{configFile} not found ({configPath})";
            }

            string param = string.IsNullOrWhiteSpace(_serverData.ServerMap) ? "" : $"{_serverData.ServerMap}";

            param += string.IsNullOrWhiteSpace(_serverData.ServerIP) ? "" : $" -MultiHome={_serverData.ServerIP}";
            param += string.IsNullOrWhiteSpace(_serverData.ServerPort) ? "" : $" -Port={_serverData.ServerPort}";
            param += $" {_serverData.ServerParam}" + ((ToggleConsole) ? " -log" : "");

            Process p;

            if (ToggleConsole)
            {
                p = new Process
                {
                    StartInfo =
                    {
                        FileName    = shipExePath,
                        Arguments   = param,
                        WindowStyle = ProcessWindowStyle.Minimized,
                    },
                    EnableRaisingEvents = true
                };
                p.Start();
            }
            else
            {
                p = new Process
                {
                    StartInfo =
                    {
                        FileName               = shipExePath,
                        Arguments              = param,
                        WindowStyle            = ProcessWindowStyle.Hidden,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                    EnableRaisingEvents = true
                };
                var serverConsole = new Functions.ServerConsole(_serverData.ServerID);
                p.OutputDataReceived += serverConsole.AddOutput;
                p.ErrorDataReceived  += serverConsole.AddOutput;
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }

            return(p);
        }