Merge pull request #139553 from andrew-d/andrew/plex-scanners
This commit is contained in:
commit
a0a5e0be1c
@ -65,6 +65,29 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraScanners = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
A list of paths to extra scanners to install in Plex's scanners
|
||||||
|
directory.
|
||||||
|
|
||||||
|
Every time the systemd unit for Plex starts up, all of the symlinks
|
||||||
|
in Plex's scanners directory will be cleared and this module will
|
||||||
|
symlink all of the paths specified here to that directory.
|
||||||
|
'';
|
||||||
|
example = literalExample ''
|
||||||
|
[
|
||||||
|
(fetchFromGitHub {
|
||||||
|
owner = "ZeroQI";
|
||||||
|
repo = "Absolute-Series-Scanner";
|
||||||
|
rev = "773a39f502a1204b0b0255903cee4ed02c46fde0";
|
||||||
|
sha256 = "4l+vpiDdC8L/EeJowUgYyB3JPNTZ1sauN8liFAcK+PY=";
|
||||||
|
})
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.plex;
|
default = pkgs.plex;
|
||||||
@ -113,6 +136,7 @@ in
|
|||||||
# Configuration for our FHS userenv script
|
# Configuration for our FHS userenv script
|
||||||
PLEX_DATADIR=cfg.dataDir;
|
PLEX_DATADIR=cfg.dataDir;
|
||||||
PLEX_PLUGINS=concatMapStringsSep ":" builtins.toString cfg.extraPlugins;
|
PLEX_PLUGINS=concatMapStringsSep ":" builtins.toString cfg.extraPlugins;
|
||||||
|
PLEX_SCANNERS=concatMapStringsSep ":" builtins.toString cfg.extraScanners;
|
||||||
|
|
||||||
# The following variables should be set by the FHS userenv script:
|
# The following variables should be set by the FHS userenv script:
|
||||||
# PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
|
# PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
|
||||||
|
@ -63,13 +63,9 @@ buildFHSUserEnv {
|
|||||||
test -d "$pluginDir" || mkdir -p "$pluginDir"
|
test -d "$pluginDir" || mkdir -p "$pluginDir"
|
||||||
|
|
||||||
# First, remove all of the symlinks in the plugins directory.
|
# First, remove all of the symlinks in the plugins directory.
|
||||||
echo "Removing old symlinks"
|
while IFS= read -r -d $'\0' f; do
|
||||||
for f in $(ls "$pluginDir/"); do
|
echo "Removing plugin symlink: $f"
|
||||||
if [[ -L "$pluginDir/$f" ]]; then
|
done < <(find "$pluginDir" -type l -print0)
|
||||||
echo "Removing plugin symlink: $pluginDir/$f"
|
|
||||||
rm "$pluginDir/$f"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Symlinking plugins"
|
echo "Symlinking plugins"
|
||||||
IFS=':' read -ra pluginsArray <<< "$PLEX_PLUGINS"
|
IFS=':' read -ra pluginsArray <<< "$PLEX_PLUGINS"
|
||||||
@ -87,6 +83,39 @@ buildFHSUserEnv {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "''${PLEX_SCANNERS:-}" ]]; then
|
||||||
|
for scannerType in Common Movies Music Series; do
|
||||||
|
echo "Preparing $scannerType scanners directory"
|
||||||
|
|
||||||
|
scannerDir="$PLEX_DATADIR/Plex Media Server/Scanners/$scannerType"
|
||||||
|
test -d "$scannerDir" || mkdir -p "$scannerDir"
|
||||||
|
|
||||||
|
# First, remove all of the symlinks in the scanners directory.
|
||||||
|
echo "Removing old symlinks"
|
||||||
|
while IFS= read -r -d $'\0' f; do
|
||||||
|
echo "Removing scanner symlink: $f"
|
||||||
|
done < <(find "$scannerDir" -type l -print0)
|
||||||
|
|
||||||
|
echo "Symlinking scanners"
|
||||||
|
IFS=':' read -ra scannersArray <<< "$PLEX_SCANNERS"
|
||||||
|
for path in "''${scannersArray[@]}"; do
|
||||||
|
# The provided source should contain a 'Scanners' directory; symlink
|
||||||
|
# from inside that.
|
||||||
|
subpath="$path/Scanners/$scannerType"
|
||||||
|
while IFS= read -r -d $'\0' file; do
|
||||||
|
dest="$scannerDir/$(basename "$file")"
|
||||||
|
|
||||||
|
if [[ -f "$dest" || -L "$dest" ]]; then
|
||||||
|
echo "Error symlinking scanner from $file to $dest: file or directory already exists"
|
||||||
|
else
|
||||||
|
echo "Symlinking scanner at: $file"
|
||||||
|
ln -s "$file" "$dest"
|
||||||
|
fi
|
||||||
|
done < <(find "$subpath" -type f -print0)
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Tell Plex to use the data directory as the "Application Support"
|
# Tell Plex to use the data directory as the "Application Support"
|
||||||
# directory, otherwise it tries to write things into the user's home
|
# directory, otherwise it tries to write things into the user's home
|
||||||
# directory.
|
# directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user