Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --eula argument and environment variable to accept EULA without prompting #93

Merged
merged 18 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 48 additions & 33 deletions Core/LocalAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,47 +181,59 @@ internal async Task Start(string[] args)
{
await LoadJsonOrTerminate();

var autoEula = false;

if (DataJson!.EulaAccepted == null)
{
ConsoleUtil.WriteLine($"Welcome to LocalAdmin version {VersionString}!", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("Before starting please read and accept the SCP:SL EULA.", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("You can find it on the following website: https://link.scpslgame.com/eula", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("Do you accept the EULA? [yes/no]", ConsoleColor.Cyan);
if (args.Contains("--acceptEULA", StringComparer.Ordinal) ||
Environment.GetEnvironmentVariable("ACCEPT_SCPSL_EULA")?.ToUpperInvariant() is "1" or "TRUE")
{
DataJson!.EulaAccepted = DateTime.UtcNow;
autoEula = true;

ReadInput((input) =>
{
if (input == null)
return false;
await SaveJsonOrTerminate();
}
else
{
ConsoleUtil.WriteLine($"Welcome to LocalAdmin version {VersionString}!", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("Before starting please read and accept the SCP:SL EULA.", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("You can find it on the following website: https://link.scpslgame.com/eula", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("", ConsoleColor.Cyan);
ConsoleUtil.WriteLine("Do you accept the EULA? [yes/no]", ConsoleColor.Cyan);

switch (input.ToLowerInvariant())
ReadInput((input) =>
{
case "y":
case "yes":
case "1":
DataJson.EulaAccepted = DateTime.UtcNow;
return true;

case "n":
case "no":
case "nope":
case "0":
ConsoleUtil.WriteLine("You have to accept the EULA to use LocalAdmin and SCP: Secret Laboratory Dedicated Server.", ConsoleColor.Red);
Terminate();
return true;

default:
if (input == null)
return false;
}

}, () => { },
() =>
{
ConsoleUtil.WriteLine("Do you accept the EULA? [yes/no]", ConsoleColor.Red);
});
switch (input.ToLowerInvariant())
{
case "y":
case "yes":
case "1":
DataJson.EulaAccepted = DateTime.UtcNow;
return true;

case "n":
case "no":
case "nope":
case "0":
ConsoleUtil.WriteLine(
"You have to accept the EULA to use LocalAdmin and SCP: Secret Laboratory Dedicated Server.",
ConsoleColor.Red);
Terminate();
return true;

default:
return false;
}

if (!_exit)
await SaveJsonOrTerminate();
}, () => { },
() => { ConsoleUtil.WriteLine("Do you accept the EULA? [yes/no]", ConsoleColor.Red); });

if (!_exit)
await SaveJsonOrTerminate();
}
}

var reconfigure = false;
Expand Down Expand Up @@ -535,6 +547,9 @@ internal async Task Start(string[] args)

_readerTask!.Start();

if (autoEula)
ConsoleUtil.WriteLine("SCP: Secret Laboratory EULA (https://link.scpslgame.com/eula) was accepted by providing a startup argument or setting an environment variable.", ConsoleColor.Yellow);

if (!EnableLogging)
ConsoleUtil.WriteLine("Logging has been disabled.", ConsoleColor.Red);
else if (!AutoFlush)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Linux: `./LocalAdmin [port] [arguments] [-- arguments passthrough]`
| --restartsTimeWindow | | Specifies a time window (in seconds) for the auto-restarts limit.<br>Setting this argument to 0 disables resetting the amount of auto-restarts after a specified amount of time.<br>*Default value: 480* |
| --logLengthLimit | | Specifies the limit of characters in LocalAdmin log file.<br>Suffixes `k`, `M`, `G` and `T` are supported, eg. `5G` is equal to `5000000000` characters.<br>Setting this argument to 0 disables the limit.<br>*Default value: 25G* |
| --logEntriesLimit | | Specifies the limit of entries in LocalAdmin log file.<br>Suffixes `k`, `M`, `G` and `T` are supported, eg. `5G` is equal to `5000000000` entries.<br>Setting this argument to 0 disables the limit.<br>*Default value: 10G* |
| --acceptEULA | | Accepts the [End User License Agreement (EULA)](https://link.scpslgame.com/eula) without prompting. Alternatively, you can set `ACCEPT_SCPSL_EULA=TRUE` in environment variables to automatically accept the [EULA](https://link.scpslgame.com/eula). |
Loading