Skip to content

Commit

Permalink
Add hacky environment variable loading on first run
Browse files Browse the repository at this point in the history
This is done via environment variables prepended with SHOKO_
variables are the same as if we are directly editing the JSON
closes #706
  • Loading branch information
Cazzar committed Jun 18, 2018
1 parent 3da8ea8 commit 97bde94
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Shoko.Server/ServerSettings.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
Expand Down Expand Up @@ -574,6 +575,21 @@ public static bool HasAllNecessaryFields(Dictionary<string, string> settings)
public static void LoadSettings()
{
LoadSettingsFromFile(string.Empty);
LoadSettingsFromEnv();
}

private static void LoadSettingsFromEnv(bool force = false)
{
if (!FirstRun && !force) return;

foreach (DictionaryEntry envPair in Environment.GetEnvironmentVariables())
{
string name = envPair.Key.ToString();
if (!name.StartsWith("SHOKO_")) continue;

name = name.Substring(6);
Set(name, envPair.Value.ToString());
}
}

public static event EventHandler MigrationStarted;
Expand Down

0 comments on commit 97bde94

Please sign in to comment.