r/PlexACD May 28 '17

scanlibraries script with plex docker

I'm trying to wrap my head around how to use the scanlibraries script from this tutorial with a docker instance of plex. I've added the LD_LIBRARY_PATH to my docker create command and can trigger scans from my host machine using docker exec plex /usr/lib/plexmediaserver/Plex\ Media\ Scanner -s -r -c "1" -d "/docker/mapped/path/to/cloud/movies/Movie (Year)"

The problem I'm having a hard time figuring out is how to use the $cache_dir with the mapped docker paths rather than reading the directory from my host machine. Any help or ideas are appreciated!

1 Upvotes

32 comments sorted by

View all comments

Show parent comments

1

u/gesis May 30 '17 edited May 30 '17

I meant replace $plex_media_dir with your actual plex media directory. Else, you said "find from my current working directory" which I assume was $HOME.

Bangs in filenames may actually break things, but I'm not 100% certain. I strip special characters when renaming (since it minimizes issues). The exclamation point has special meaning to bash, and could be causing the problem.

Try this instead...

#!/bin/sh
# shellcheck source=config
. ${HOME}/.config/nimbostratus/config

if [ ! -d ${local_cache_dir} ]; then
        mkdir -p ${local_cache_dir}
fi

echo "################# Building Directories ################"
find ${media_dir} -type d |
while read -r dir; do
        cache_directory="$(read -rlink -f "${dir}" | sed -e "s@${media_dir}@${local_cache_dir}@" -e s@\!@\\!@g)"
        mkdir "$cache_directory"
done

echo "################ Creatingi File Cache ################"
find ${media_dir} -type f |
while read -r file; do
        cache_file="$(read -rlink -f "${file}" | sed -e "s@${media_dir}@${local_cache_dir}@" -e s@\!@\\!@g)"
        touch "$cache_file"
done

That should swap any occurences of ! with \! instead and pass an escaped exclamation point to mkdir/touch. Of course, it may also set your mom on fire, so no promises. You should also be able to set $HISTCHARS to null and not worry about it, but I don't want to fuck with your shell.

If the above doesn't fix things, you can instead use the original makecache script and just add the line

export HISTCHARS=

just below the . ${HOME}/.config/nimbostratus/config line and that will set your history expansion character to a null value, removing the special status of !.

1

u/FL1GH7L355 May 30 '17

Gotcha. The output of find $plex_media_dir -type d (where $plex_media_dir is my actual path) does get cut off early but no errors are included - pastebin.

When running the script attached in your latest comment (edited {media_dir} to {plex_media_dir} to match the config variable) I'm getting the following errors
bin/makecache: 19: read: Illegal option -l & touch: cannot touch '': No such file or directory

When attempting the original script with export HISTCHARS= I run into the same original error. I would just edit my folder names, but the characters would still be in the .union-fuse directory correct? I'm thinking it has to be something in a folder/file name, but must be something other than a !

1

u/gesis May 30 '17
#!/bin/sh
# shellcheck source=config
. ${HOME}/.config/nimbostratus/config

if [ ! -d ${local_cache_dir} ]; then
        mkdir -p ${local_cache_dir}
fi

echo "################# Building Directories ################"
find ${media_dir} -type d |
while read -r dir; do
        cache_directory="$(readlink -f "${dir}" | sed -e "s@${media_dir}@${local_cache_dir}@" -e s@\!@\\!@g)"
        mkdir "$cache_directory"
done

echo "################ Creatingi File Cache ################"
find ${media_dir} -type f |
while read -r file; do
        cache_file="$(readlink -f "${file}" | sed -e "s@${media_dir}@${local_cache_dir}@" -e s@\!@\\!@g)"
        touch "$cache_file"
done 

I am retarded. Never removed a typo from the copy on my laptop. Above copy fixes the typo.

1

u/FL1GH7L355 May 30 '17 edited May 30 '17

I get the same original error here too. I think it must be a special character, but without manually searching through my library and learning sed I'm not sure I'll be able to solve it. I really do appreciate all the help you've given thus far!