Skip to content

Commit

Permalink
Added --eula argument and environment variable to accept EULA witho…
Browse files Browse the repository at this point in the history
…ut prompting (#93)

* feat: `--eula` argument to accept EULA without prompting

* fix: change argument check condition. Added check for env variable.

* docs(readme): env variable notation, hyperlinks to eula

* feat: added log for auto-accepted eula

* docs(readme): fix formatter bomb

* feat: rename env variable to `SLLA_EULA`

* refactor: Moved if statement. Moved console message.

* refactor: removed empty space

* feat: add SaveJsonOrTerminate when using auto eula

* docs(readme): fix typo

Co-authored-by: Łukasz Jurczyk <zabszk@protonmail.ch>

* feat: changed eula auto-accept log

Co-authored-by: Łukasz Jurczyk <zabszk@protonmail.ch>

* refactor: replaced `_autoEula` to local variable

* refactor: rename env variable to ACCEPT_SLLA_EULA

* Update Core/LocalAdmin.cs

* Update README.md

---------

Co-authored-by: Łukasz Jurczyk <zabszk@protonmail.ch>
  • Loading branch information
fakeman2332 and zabszk committed Aug 20, 2024
1 parent 2a3eaa0 commit 579e2ea
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
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). |

0 comments on commit 579e2ea

Please sign in to comment.