[TUTO] configure Plex Media Scanner to be "linux runnable" (centos)

Found this page on Plex Support website

I wanted to improve Plex Refresh mecanism which is not really working, especially when you've just put a new subtitle file for the film you want to see it NOW...

There is command line support (named 'Plex Media Scanner'), but the file is named with multiple space, and it's not really linux friendly ;) So I decided to make small shortcuts, to have those commands usable easily

sudo touch /usr/local/bin/plexmediascanner.sh
sudo chmod +x /usr/local/bin/plexmediascanner.sh
sudo vi /usr/local/bin/plexmediascanner.sh
PLEX_RUNNABLE="`which Plex\ Media\ Scanner`"

You can also create one for the server :

sudo touch /usr/local/bin/plexmediaserver.sh
sudo chmod +x /usr/local/bin/plexmediaserver.sh
sudo vi /usr/local/bin/plexmediaserver.sh
PLEX_RUNNABLE="`which Plex\ Media\ Server`"

I've also created a small script to have Plex variables online (into profile.d to make things clean) :

sudo touch /etc/profile.d/plex.sh
sudo chmod +x /etc/profile.d/plex.sh
sudo vi /etc/profile.d/plex.sh
#set the Plex homedir
#add Plex homedir to libpath
#add Plex homedir to PATH
pathmunge ${PLEX_PATH}

Then you have to edit SUDO config file to allow a simple user to execute the command, or restart Plex service without password, which is done by launching visudo :

Defaults    env_keep += "LD_LIBRARY_PATH"
Defaults    env_keep += "PLEX_PATH"
%agroup      ALL=(ALL)       NOPASSWD: /usr/lib/plexmediaserver/Plex\ Media\ Scanner
%agroup      ALL=(ALL)       NOPASSWD: /sbin/service plexmediaserver*

That's all folks... :D any comments are welcome !