Browse Source

custom config folders env vars (#1714)

* use custom config folder location

* allow customizing config and transcode folder locations
pull/1717/head
Jason Dove 1 year ago committed by GitHub
parent
commit
2c97c49763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      CHANGELOG.md
  2. 179
      ErsatzTV.Core/FileSystemLayout.cs
  3. 2
      ErsatzTV/Startup.cs
  4. 2
      docker/Dockerfile
  5. 4
      docker/arm32v7/Dockerfile
  6. 4
      docker/arm64/Dockerfile
  7. 4
      docker/docker-compose.yml
  8. 2
      docker/nvidia/Dockerfile
  9. 2
      docker/vaapi/Dockerfile

9
CHANGELOG.md

@ -58,6 +58,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -58,6 +58,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Every episode from Show 2 Season 3
- Every episode from Show 1 Season 3
- Playlist items with fewer media items will be re-shuffled (if applicable) before those with more media items
- Add two new environment variables to customize config and transcode folder locations
- `ETV_CONFIG_FOLDER`
- `ETV_TRANSCODE_FOLDER`
### Fixed
- Fix some cases of 404s from Plex when files were replaced and scanning the library from ETV didn't help
@ -95,6 +98,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -95,6 +98,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Serving playlists with gzip compression
- Use `HLS Segmenter V2` for channel preview when channel is configured for `HLS Segmenter V2`
- Detect and use `/dev/dri/card*` devices in addition to `/dev/dri/render*` devices
- Change default folder locations in docker using new environment variables
- `ETV_CONFIG_FOLDER` - now defaults to `/config`
- `ETV_TRANSCODE_FOLDER` - now defaults to `/transcode`
- If the old locations are still present in docker, these variables will be ignored, so you can migrate at your own pace
- Old config location: `/root/.local/share/ersatztv`
- Old transcode location: `/root/.local/share/etv-transcode`
## [0.8.6-beta] - 2024-04-03
### Added

179
ErsatzTV.Core/FileSystemLayout.cs

@ -1,67 +1,160 @@ @@ -1,67 +1,160 @@
namespace ErsatzTV.Core;
using System.Reflection;
namespace ErsatzTV.Core;
public static class FileSystemLayout
{
public static readonly string AppDataFolder = Path.Combine(
Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.Create),
"ersatztv");
static FileSystemLayout()
{
string version = Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? "unknown";
bool isDocker = version.Contains("docker", StringComparison.OrdinalIgnoreCase);
string defaultConfigFolder = Path.Combine(
Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.DoNotVerify),
"ersatztv");
string customConfigFolder = Environment.GetEnvironmentVariable("ETV_CONFIG_FOLDER");
bool useCustomConfigFolder = !string.IsNullOrWhiteSpace(customConfigFolder);
if (useCustomConfigFolder && isDocker)
{
// check for config at old location
if (Directory.Exists(defaultConfigFolder))
{
Serilog.Log.Logger.Warning(
"Ignoring ETV_CONFIG_FOLDER {Folder} and using default {Default}",
customConfigFolder,
defaultConfigFolder);
// ignore custom config folder
useCustomConfigFolder = false;
}
}
AppDataFolder = useCustomConfigFolder ? customConfigFolder : defaultConfigFolder;
string defaultTranscodeFolder = Path.Combine(
Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.DoNotVerify),
"etv-transcode");
string customTranscodeFolder = Environment.GetEnvironmentVariable("ETV_TRANSCODE_FOLDER");
bool useCustomTranscodeFolder = !string.IsNullOrWhiteSpace(customTranscodeFolder);
if (useCustomTranscodeFolder && isDocker)
{
// check for config at old location
if (Directory.Exists(defaultTranscodeFolder))
{
Serilog.Log.Logger.Warning(
"Ignoring ETV_TRANSCODE_FOLDER {Folder} and using default {Default}",
customTranscodeFolder,
defaultTranscodeFolder);
// ignore custom config folder
useCustomTranscodeFolder = false;
}
}
TranscodeFolder = useCustomTranscodeFolder ? customTranscodeFolder : defaultTranscodeFolder;
DataProtectionFolder = Path.Combine(AppDataFolder, "data-protection");
LogsFolder = Path.Combine(AppDataFolder, "logs");
DatabasePath = Path.Combine(AppDataFolder, "ersatztv.sqlite3");
LogFilePath = Path.Combine(LogsFolder, "ersatztv.log");
LegacyImageCacheFolder = Path.Combine(AppDataFolder, "cache", "images");
ResourcesCacheFolder = Path.Combine(AppDataFolder, "cache", "resources");
ChannelGuideCacheFolder = Path.Combine(AppDataFolder, "cache", "channel-guide");
PlexSecretsPath = Path.Combine(AppDataFolder, "plex-secrets.json");
JellyfinSecretsPath = Path.Combine(AppDataFolder, "jellyfin-secrets.json");
EmbySecretsPath = Path.Combine(AppDataFolder, "emby-secrets.json");
FFmpegReportsFolder = Path.Combine(AppDataFolder, "ffmpeg-reports");
SearchIndexFolder = Path.Combine(AppDataFolder, "search-index");
TempFilePoolFolder = Path.Combine(AppDataFolder, "temp-pool");
ArtworkCacheFolder = Path.Combine(AppDataFolder, "cache", "artwork");
ArtworkCacheFolder = Path.Combine(AppDataFolder, "cache", "artwork");
PosterCacheFolder = Path.Combine(ArtworkCacheFolder, "posters");
ThumbnailCacheFolder = Path.Combine(ArtworkCacheFolder, "thumbnails");
LogoCacheFolder = Path.Combine(ArtworkCacheFolder, "logos");
FanArtCacheFolder = Path.Combine(ArtworkCacheFolder, "fanart");
WatermarkCacheFolder = Path.Combine(ArtworkCacheFolder, "watermarks");
StreamsCacheFolder = Path.Combine(AppDataFolder, "cache", "streams");
SubtitleCacheFolder = Path.Combine(StreamsCacheFolder, "subtitles");
FontsCacheFolder = Path.Combine(StreamsCacheFolder, "fonts");
TemplatesFolder = Path.Combine(AppDataFolder, "templates");
MusicVideoCreditsTemplatesFolder = Path.Combine(TemplatesFolder, "music-video-credits");
ChannelGuideTemplatesFolder = Path.Combine(TemplatesFolder, "channel-guide");
ScriptsFolder = Path.Combine(AppDataFolder, "scripts");
MultiEpisodeShuffleTemplatesFolder = Path.Combine(ScriptsFolder, "multi-episode-shuffle");
// TODO: find a different spot for this; configurable?
public static readonly string TranscodeFolder = Path.Combine(
Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.Create),
"etv-transcode");
AudioStreamSelectorScriptsFolder = Path.Combine(ScriptsFolder, "audio-stream-selector");
}
public static readonly string DataProtectionFolder = Path.Combine(AppDataFolder, "data-protection");
public static readonly string AppDataFolder;
public static readonly string LogsFolder = Path.Combine(AppDataFolder, "logs");
public static readonly string TranscodeFolder;
public static readonly string DatabasePath = Path.Combine(AppDataFolder, "ersatztv.sqlite3");
public static readonly string DataProtectionFolder;
public static readonly string LogsFolder;
public static readonly string LogFilePath = Path.Combine(LogsFolder, "ersatztv.log");
public static readonly string DatabasePath;
public static readonly string LogFilePath;
public static readonly string LegacyImageCacheFolder = Path.Combine(AppDataFolder, "cache", "images");
public static readonly string ResourcesCacheFolder = Path.Combine(AppDataFolder, "cache", "resources");
public static readonly string ChannelGuideCacheFolder = Path.Combine(AppDataFolder, "cache", "channel-guide");
public static readonly string LegacyImageCacheFolder;
public static readonly string ResourcesCacheFolder;
public static readonly string ChannelGuideCacheFolder;
public static readonly string PlexSecretsPath = Path.Combine(AppDataFolder, "plex-secrets.json");
public static readonly string JellyfinSecretsPath = Path.Combine(AppDataFolder, "jellyfin-secrets.json");
public static readonly string EmbySecretsPath = Path.Combine(AppDataFolder, "emby-secrets.json");
public static readonly string PlexSecretsPath;
public static readonly string JellyfinSecretsPath;
public static readonly string EmbySecretsPath;
public static readonly string FFmpegReportsFolder = Path.Combine(AppDataFolder, "ffmpeg-reports");
public static readonly string SearchIndexFolder = Path.Combine(AppDataFolder, "search-index");
public static readonly string TempFilePoolFolder = Path.Combine(AppDataFolder, "temp-pool");
public static readonly string FFmpegReportsFolder;
public static readonly string SearchIndexFolder;
public static readonly string TempFilePoolFolder;
public static readonly string ArtworkCacheFolder = Path.Combine(AppDataFolder, "cache", "artwork");
public static readonly string ArtworkCacheFolder;
public static readonly string PosterCacheFolder = Path.Combine(ArtworkCacheFolder, "posters");
public static readonly string ThumbnailCacheFolder = Path.Combine(ArtworkCacheFolder, "thumbnails");
public static readonly string LogoCacheFolder = Path.Combine(ArtworkCacheFolder, "logos");
public static readonly string FanArtCacheFolder = Path.Combine(ArtworkCacheFolder, "fanart");
public static readonly string WatermarkCacheFolder = Path.Combine(ArtworkCacheFolder, "watermarks");
public static readonly string PosterCacheFolder;
public static readonly string ThumbnailCacheFolder;
public static readonly string LogoCacheFolder;
public static readonly string FanArtCacheFolder;
public static readonly string WatermarkCacheFolder;
public static readonly string StreamsCacheFolder = Path.Combine(AppDataFolder, "cache", "streams");
public static readonly string StreamsCacheFolder;
public static readonly string SubtitleCacheFolder = Path.Combine(StreamsCacheFolder, "subtitles");
public static readonly string FontsCacheFolder = Path.Combine(StreamsCacheFolder, "fonts");
public static readonly string SubtitleCacheFolder;
public static readonly string FontsCacheFolder;
public static readonly string TemplatesFolder = Path.Combine(AppDataFolder, "templates");
public static readonly string TemplatesFolder;
public static readonly string MusicVideoCreditsTemplatesFolder =
Path.Combine(TemplatesFolder, "music-video-credits");
public static readonly string MusicVideoCreditsTemplatesFolder;
public static readonly string ChannelGuideTemplatesFolder = Path.Combine(TemplatesFolder, "channel-guide");
public static readonly string ChannelGuideTemplatesFolder;
public static readonly string ScriptsFolder = Path.Combine(AppDataFolder, "scripts");
public static readonly string ScriptsFolder;
public static readonly string MultiEpisodeShuffleTemplatesFolder =
Path.Combine(ScriptsFolder, "multi-episode-shuffle");
public static readonly string MultiEpisodeShuffleTemplatesFolder;
public static readonly string AudioStreamSelectorScriptsFolder =
Path.Combine(ScriptsFolder, "audio-stream-selector");
public static readonly string AudioStreamSelectorScriptsFolder;
public static readonly string MacOsOldAppDataFolder = Path.Combine(
Environment.GetEnvironmentVariable("HOME") ?? string.Empty,

2
ErsatzTV/Startup.cs

@ -438,6 +438,8 @@ public class Startup @@ -438,6 +438,8 @@ public class Startup
TvContext.CaseInsensitiveCollation = "utf8mb4_general_ci";
}
Log.Logger.Information("Transcode folder is {Folder}", FileSystemLayout.TranscodeFolder);
services.AddMediatR(config => config.RegisterServicesFromAssemblyContaining<GetAllChannels>());
services.AddRefitClient<IPlexTvApi>()

2
docker/Dockerfile

@ -44,4 +44,6 @@ RUN fc-cache update @@ -44,4 +44,6 @@ RUN fc-cache update
WORKDIR /app
EXPOSE 8409
COPY --from=build /app ./
ENV ETV_CONFIG_FOLDER=/config
ENV ETV_TRANSCODE_FOLDER=/transcode
ENTRYPOINT ["./ErsatzTV"]

4
docker/arm32v7/Dockerfile

@ -36,7 +36,7 @@ RUN dotnet publish ErsatzTV.Scanner.csproj --framework net8.0 -c release -o /app @@ -36,7 +36,7 @@ RUN dotnet publish ErsatzTV.Scanner.csproj --framework net8.0 -c release -o /app
WORKDIR /source/ErsatzTV
RUN sed -i '/Scanner/d' ErsatzTV.csproj
RUN dotnet publish ErsatzTV.csproj --framework net8.0 -c release -o /app --runtime linux-arm --no-self-contained --no-restore -p:DebugType=Embedded -p:PublishSingleFile=false -p:PublishTrimmed=false -p:InformationalVersion=${INFO_VERSION}
# final stage/image
FROM runtime-base
ENV FONTCONFIG_PATH=/etc/fonts
@ -44,4 +44,6 @@ RUN fc-cache update @@ -44,4 +44,6 @@ RUN fc-cache update
WORKDIR /app
EXPOSE 8409
COPY --from=build /app ./
ENV ETV_CONFIG_FOLDER=/config
ENV ETV_TRANSCODE_FOLDER=/transcode
ENTRYPOINT ["./ErsatzTV"]

4
docker/arm64/Dockerfile

@ -36,7 +36,7 @@ RUN dotnet publish ErsatzTV.Scanner.csproj --framework net8.0 -c release -o /app @@ -36,7 +36,7 @@ RUN dotnet publish ErsatzTV.Scanner.csproj --framework net8.0 -c release -o /app
WORKDIR /source/ErsatzTV
RUN sed -i '/Scanner/d' ErsatzTV.csproj
RUN dotnet publish ErsatzTV.csproj --framework net8.0 -c release -o /app --runtime linux-arm64 --no-self-contained --no-restore -p:DebugType=Embedded -p:PublishSingleFile=false -p:PublishTrimmed=false -p:InformationalVersion=${INFO_VERSION}
# final stage/image
FROM runtime-base
ENV FONTCONFIG_PATH=/etc/fonts
@ -44,4 +44,6 @@ RUN fc-cache update @@ -44,4 +44,6 @@ RUN fc-cache update
WORKDIR /app
EXPOSE 8409
COPY --from=build /app ./
ENV ETV_CONFIG_FOLDER=/config
ENV ETV_TRANSCODE_FOLDER=/transcode
ENTRYPOINT ["./ErsatzTV"]

4
docker/docker-compose.yml

@ -10,7 +10,9 @@ @@ -10,7 +10,9 @@
ports:
- "8409:8409"
volumes:
- ersatztv:/root/.local/share/ersatztv
- ersatztv:/config
#- /media/shared:/media/shared:ro
tmpfs:
- /transcode
volumes:
ersatztv:

2
docker/nvidia/Dockerfile

@ -50,4 +50,6 @@ RUN fc-cache update @@ -50,4 +50,6 @@ RUN fc-cache update
WORKDIR /app
EXPOSE 8409
COPY --from=build /app ./
ENV ETV_CONFIG_FOLDER=/config
ENV ETV_TRANSCODE_FOLDER=/transcode
ENTRYPOINT ["./ErsatzTV"]

2
docker/vaapi/Dockerfile

@ -44,4 +44,6 @@ RUN fc-cache update @@ -44,4 +44,6 @@ RUN fc-cache update
WORKDIR /app
EXPOSE 8409
COPY --from=build /app ./
ENV ETV_CONFIG_FOLDER=/config
ENV ETV_TRANSCODE_FOLDER=/transcode
ENTRYPOINT ["./ErsatzTV"]

Loading…
Cancel
Save