diff --git a/frontend/src/Settings/General/GeneralSettings.js b/frontend/src/Settings/General/GeneralSettings.js index 1fd14b924..25cef72a6 100644 --- a/frontend/src/Settings/General/GeneralSettings.js +++ b/frontend/src/Settings/General/GeneralSettings.js @@ -20,6 +20,7 @@ const requiresRestartKeys = [ 'bindAddress', 'port', 'urlBase', + 'instanceName', 'enableSsl', 'sslPort', 'sslCertHash', diff --git a/frontend/src/Settings/General/HostSettings.js b/frontend/src/Settings/General/HostSettings.js index 73ca53520..7133d926e 100644 --- a/frontend/src/Settings/General/HostSettings.js +++ b/frontend/src/Settings/General/HostSettings.js @@ -19,6 +19,7 @@ function HostSettings(props) { bindAddress, port, urlBase, + instanceName, enableSsl, sslPort, sslCertHash, @@ -71,6 +72,22 @@ function HostSettings(props) { /> + + Instance Name + + + + , string SslCertHash { get; } string UrlBase { get; } string UiFolder { get; } + string InstanceName { get; } bool UpdateAutomatically { get; } UpdateMechanism UpdateMechanism { get; } string UpdateScriptPath { get; } @@ -205,6 +206,19 @@ public string UrlBase // public string UiFolder => GetValue("UiFolder", "UI", false);GetValue("UiFolder", "UI", false); public string UiFolder => "UI"; + public string InstanceName + { + get + { + var instanceName = GetValue("InstanceName", BuildInfo.AppName); + + if (instanceName.StartsWith(BuildInfo.AppName) || instanceName.EndsWith(BuildInfo.AppName) ) + { + return instanceName; + } + return BuildInfo.AppName; + } + } public bool UpdateAutomatically => GetValueBoolean("UpdateAutomatically", false, false); @@ -218,7 +232,6 @@ public string UrlBase public string SyslogLevel => GetValue("SyslogLevel", LogLevel, persist: false).ToLowerInvariant(); - public int GetValueInt(string key, int defaultValue, bool persist = true) { return Convert.ToInt32(GetValue(key, defaultValue)); diff --git a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs index df9043fd0..8699d156c 100644 --- a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs +++ b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs @@ -62,5 +62,11 @@ public static IRuleBuilderOptions AsWarning(this IRuleBuilde { return ruleBuilder.WithState(v => NzbDroneValidationState.Warning); } + + public static IRuleBuilderOptions StartsOrEndsWithSonarr(this IRuleBuilder ruleBuilder) + { + ruleBuilder.SetValidator(new NotEmptyValidator(null)); + return ruleBuilder.SetValidator(new RegularExpressionValidator("^Sonarr|Sonarr$")).WithMessage("Must start or end with Sonarr"); + } } } diff --git a/src/Sonarr.Api.V3/Config/HostConfigModule.cs b/src/Sonarr.Api.V3/Config/HostConfigModule.cs index eb9021929..10d74562c 100644 --- a/src/Sonarr.Api.V3/Config/HostConfigModule.cs +++ b/src/Sonarr.Api.V3/Config/HostConfigModule.cs @@ -38,6 +38,7 @@ public HostConfigModule(IConfigFileProvider configFileProvider, IConfigService c SharedValidator.RuleFor(c => c.Port).ValidPort(); SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase(); + SharedValidator.RuleFor(c => c.InstanceName).StartsOrEndsWithSonarr(); SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None); SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None); diff --git a/src/Sonarr.Api.V3/Config/HostConfigResource.cs b/src/Sonarr.Api.V3/Config/HostConfigResource.cs index 8fd147dac..ff3bc777f 100644 --- a/src/Sonarr.Api.V3/Config/HostConfigResource.cs +++ b/src/Sonarr.Api.V3/Config/HostConfigResource.cs @@ -24,6 +24,7 @@ public class HostConfigResource : RestResource public string ApiKey { get; set; } public string SslCertHash { get; set; } public string UrlBase { get; set; } + public string InstanceName { get; set; } public bool UpdateAutomatically { get; set; } public UpdateMechanism UpdateMechanism { get; set; } public string UpdateScriptPath { get; set; } @@ -63,6 +64,7 @@ public static HostConfigResource ToResource(this IConfigFileProvider model, ICon ApiKey = model.ApiKey, SslCertHash = model.SslCertHash, UrlBase = model.UrlBase, + InstanceName = model.InstanceName, UpdateAutomatically = model.UpdateAutomatically, UpdateMechanism = model.UpdateMechanism, UpdateScriptPath = model.UpdateScriptPath,