Пример #1
0
            public async Task RestartServer()
            {
                using (var client = CmSsh.CreateSshClient(_config))
                {
                    try
                    {
                        SshCommand cmd = null;
                        client.Connect();
                        cmd = client.RunCommand("sudo /bin/systemctl stop csgo");
                        if (cmd.ExitStatus != 0)
                        {
                            await ReplyAsync(cmd.Error);

                            return;
                        }

                        cmd = client.RunCommand("sudo /bin/systemctl start csgo");
                        if (cmd.ExitStatus != 0)
                        {
                            await ReplyAsync(cmd.Error);

                            return;
                        }

                        client.Disconnect();
                        await ReplyAsync("Restarting server");
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
Пример #2
0
            public async Task SshCommand(string message)
            {
                using (var client = CmSsh.CreateSshClient(_config))
                {
                    try
                    {
                        client.Connect();
                        var cmd = client.RunCommand(message);
                        await ReplyAsync(cmd.Result);

                        client.Disconnect();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
Пример #3
0
            public async Task GameModes()
            {
                using (var client = CmSsh.CreateSshClient(_config))
                {
                    string runCommand     = @"ls /srv/steam/hlserver/csgo/cfg/gamemode*.cfg -1 | grep -oP 'gamemode_\K\w+'";
                    string seperator      = "\n";
                    string fileStartsWith = "gamemode_";
                    string fileEndsWith   = ".cfg";
                    string joinSeperator  = ", ";

                    client.Connect();
                    var cmd    = client.RunCommand(runCommand);
                    var result = cmd.Result
                                 .Split(seperator)
                                 .ToArray();

                    await ReplyAsync(String.Join(joinSeperator, result));
                }
            }