public void ReturnCorrectValuesAccordingToArgs()
        {
            var serverBackupDir     = "1";
            var serverInstallDir    = "2";
            var steamcmdDownloadUrl = "3";
            var steamcmdInstallDir  = "4";
            var timeZone            = "5";

            var settings = SettingsParser.ParseArgs(CesxSettings.Default, new[]
            {
                "--server_backup_dir",
                serverBackupDir,
                "--server_install_dir",
                serverInstallDir,
                "--steamcmd_download_url",
                steamcmdDownloadUrl,
                "--steamcmd_install_dir",
                steamcmdInstallDir,
                "--time_zone",
                timeZone,
                "--skip_backup",
                "--skip_update"
            });

            Assert.Equal(serverBackupDir, settings.ServerBackupDir);
            Assert.Equal(serverInstallDir, settings.ServerInstallDir);
            Assert.Equal(steamcmdDownloadUrl, settings.SteamCmdDownloadUrl);
            Assert.Equal(steamcmdInstallDir, settings.SteamCmdInstallDir);
            Assert.Equal(timeZone, settings.TimeZone);
            Assert.True(settings.SkipBackup);
            Assert.True(settings.SkipUpdate);
        }
        public void ReturnDefaultValues()
        {
            var settings = SettingsParser.ParseArgs(CesxSettings.Default, null);

            Assert.Equal(@"C:\ConanServer\Backups\", settings.ServerBackupDir);
            Assert.Equal(@"C:\ConanServer\Server\", settings.ServerInstallDir);
            Assert.Equal(@"https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip", settings.SteamCmdDownloadUrl);
            Assert.Equal(@"C:\ConanServer\Updater\", settings.SteamCmdInstallDir);
            Assert.Equal("W. Europe Standard Time", settings.TimeZone);
        }
예제 #3
0
        private static async Task <int> Execute(string[] args, CancellationToken token)
        {
            var settings = SettingsParser.ParseArgs(CesxSettings.Default, args);

            Console.WriteLine("CESX: starting with settings");
            Console.WriteLine(settings);

            if (!settings.SkipBackup)
            {
                Console.WriteLine("CESX: Creating backup...");
                var backuper = new ServerBackuper(settings);
                backuper.DoBackup();
                Console.WriteLine("CESX: Done!");
            }

            if (!settings.SkipUpdate)
            {
                Console.WriteLine("CESX: Try updating server files");
                _updater = new ServerUpdater(settings);

                Console.WriteLine("CESX: Downloading SteamCmd...");
                await _updater.EnsureSteamCmdExistsAsync(token);

                Console.WriteLine("CESX: Done!");

                Console.WriteLine("CESX: Running steamcmd...");
                await _updater.RunSteamCmdUpdaterAsync(token);

                Console.WriteLine("CESX: Done!");

                //_updater.Dispose();
            }

            Console.WriteLine("CESX: Starting the server instance");
            _server = new ServerRunner(settings);
            _server.Run();

            return((int)ExitCode.Success);
        }