CanI try to upgrade my 1.19.4 version to the package shown in thi sthread? I am using Qnap TS-453BE, and it will not start,. Getting this message:
This thread is centered on the PlexData share
1.19.4 did not have this capability.
If you wish to try this for the sole purpose of getting easy access to the logs, Please do.
We can work with it from there in a separate thread for your specific issue.
Hi @ChuckPa
After updating to Version 1.20.1.3232 the"PlexData" share will be recreated every time the Plex service starts…
Reproduced:
Stopped Plex
Deleted share
Started Plex
Share is back.
How can I prevent creating it?
Thanks JO!
I can only apologize for what’s happened. I’m just getting my morning started here.
I had no idea there was a new build of PMS which was pushed without the change in it. I know the change is to be in 1.20.2. I’m going to make this a priority today and find out what/why/how to bump this up in the release schedule and into PlexPass before it gets pushed to public.
To provide you with what will be the released code for plex.sh which is a partial workaround for now (it will stop interfering with you)
#!/bin/sh
#########################################################################
# Plex Media Server init-script used to control start and stop. #
# Maintainer: Plex Build Team #
# Credit: Initial work and ongoing feedback by Dane22 #
#########################################################################
# Location of QPKG conf file.
CONF=/etc/config/qpkg.conf
# Name of Plex Media Server install directory.
QPKG_NAME="PlexMediaServer"
# Grab Plex Media Server install directory, regardless of disk layout.
QPKG_DIR=$(getcfg -f $CONF $QPKG_NAME Install_path)
PID_FILE="${QPKG_DIR}/Library/Plex Media Server/plexmediaserver.pid"
case "$1" in
start)
# Is PMS enabled in QTS App Center?
ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
if [ "$ENABLED" != "TRUE" ]; then
echo "$QPKG_NAME is disabled."
exit 1
fi
# Is PMS already running?
if [ -f "$PID_FILE" ]; then
# Pid file was present, but sadly QNAP does a very brutal kill when shutting down.
# Verify we only have a stray PID file (no active processes).
ProcessCount=$(ps -ef | grep plex | wc -l)
if [ $ProcessCount -gt 1 ]; then
logMsg="Plex Media Server is currently running or hasn't been shutdown properly. Please stop it from QNAP AppCenter and start it again."
echo $logMsg
/sbin/log_tool -t 2 -a "$logMsg"
exit 0
fi
fi
# Obtain list and count of all installed GPUs.
if [ -e /sbin/gpuhal_app ]; then
TEMPFILE=/tmp/PMS.GPU.$$.TMP
/sbin/gpuhal_app -l > $TEMPFILE
GPU_COUNT=$(wc -l $TEMPFILE | awk '{print $1}')
# Start with the first GPU we find.
CURRENT_GPU=1
# False until we find a supported, and properly configured GPU.
SUPPORTED_GPU=0
# Loop through the list of GPUs, starting with the first, until one first found -or- none found.
while [ $CURRENT_GPU -le $GPU_COUNT ]
do
# Test this card, get the entire line
CANDIDATE=$(head -$CURRENT_GPU $TEMPFILE | tail -1)
# Test if NVIDIA card installed
NVIDIA=$(echo $CANDIDATE | grep NVIDIA | wc -l)
if [ $NVIDIA -gt 0 ]; then
# Extract GPU_ID from candidate info, and get status.
GPU_ID=$(echo $CANDIDATE | awk -F: '{print $1}')
GPU_STATUS=$(/sbin/gpuhal_app -s $GPU_ID)
# Are the GPU Drivers installed?
if [ $(echo $GPU_STATUS | grep driver_installed=1 | wc -l) -gt 0 ]; then
# Is the GPU in QTS mode?
if [ $(echo $GPU_STATUS | grep real_status=2 | wc -l) -gt 0 ]; then
# Get the QPKG package name.
GPU_QPKG=$(echo $GPU_STATUS | sed -e 's/^.*driverqpkg=//' | sed -e 's/,.*$//')
# Get NVIDIA driver-env.sh information. (where all the variables are)
GPU_SH=$(/sbin/getcfg $GPU_QPKG Install_Path -f /etc/config/qpkg.conf)/driver-env.sh
# Translate the name to avoid collision and resolve absolute paths.
DRIVER_ROOT="$(grep DRIVER_ROOT= $GPU_SH | awk -F= '{print $2}')"
DRIVER_ROOT="$(echo $DRIVER_ROOT | sed -e s+\${QPKG_NAME}+$GPU_QPKG+)"
GPU_LD_PATH=$(grep LD_LIBRARY_PATH= $GPU_SH | awk '{print $2}' | awk -F= '{print $2}' | sed -e 's/:$LD_LIBRARY_PATH//')
GPU_LD_PATH="$(echo $GPU_LD_PATH | sed -e s+\${DRIVER_ROOT}+$DRIVER_ROOT+g)"
# We have a viable GPU.
SUPPORTED_GPU=1
else
# Log at INFO level that card is not in QTS mode an unable to be used by PMS.
# User may not want PMS using it and/or user may already have a QSV-compatible CPU.
log_tool -t 0 -a "NVIDIA GPU detected and the drivers are installed. Please switch card to 'QTS' mode for PMS to access it."
fi
else
# GPU detected but no Driver is installed.
log_tool -t 0 -a "NVIDIA GPU detected but the drivers are not installed. Please install the NVIDIA drivers to use this card with Plex Media Server."
fi
# Do we have a viable GPU to use?
if [ $SUPPORTED_GPU -eq 1 ]; then
# Yes, we are done.
break;
fi
fi
# Default to an unsupported GPU, resetting flags along the way.
SUPPORTED_GPU=0
unset GPU_LD_PATH; unset GPU_ID; unset DRIVER_ROOT;
unset QPKG_SH; unset DRV_NAME
# Set next candate.
CURRENT_GPU=$(( $CURRENT_GPU + 1 ))
done
# Remove GPU temp file.
rm -f $TEMPFILE
fi
# Is the PlexData feature (NOT) disabled?
if [ ! -e "${QPKG_DIR}/Library/Plex Media Server/.disablePlexDataSymlink" ]; then
# If a shared folder, named PlexData, exists, create a link there
# Otherwise, do nothing
if [ -e "/share/PlexData" ]; then
# And there's a real directory backing it
PlexDataDir="/share/$(readlink /share/PlexData)"
if [ -d "$PlexDataDir" ]; then
# Update linkage
rm -f "$PlexDataDir/Plex Media Server"
ln -s "${QPKG_DIR}/Library/Plex Media Server" "$PlexDataDir/Plex Media Server"
fi
fi
fi
logMsg="Starting Plex Media Server..."
echo $logMsg
/sbin/log_tool -t 0 -a "$logMsg"
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${QPKG_DIR}/Library"
export TMPDIR="${QPKG_DIR}/Library/tmp"
export LD_LIBRARY_PATH="${QPKG_DIR}/lib"
export PLEX_MEDIA_SERVER_DEFAULT_PREFERENCES="HardwareAcceleratedCodecs=true&TranscoderCanOnlyRemuxVideo=false"
# Set identification variables
export PLEX_MEDIA_SERVER_INFO_VENDOR=QNAP
export PLEX_MEDIA_SERVER_INFO_DEVICE="$(getsysinfo model)"
export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="QTS $(getcfg system version).$(getcfg system Number)"
# Append GPU Library path to LD_LIBRARY_PATH
if [ "$GPU_LD_PATH" != "" ]; then
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GPU_LD_PATH}
fi
# Wait a bit, since new firmware seems to cause a race condition.
sleep 5
ulimit -s 3000
cd ${QPKG_DIR}
./Plex\ Media\ Server &
;;
stop)
if [ -f "$PID_FILE" ]; then
logMsg="Stopping Plex Media Server..."
echo $logMsg
/sbin/log_tool -t 0 -a "$logMsg"
kill $(cat "$PID_FILE")
sleep 5
# If pid file is a leftover from not shutting down properly, remove it now.
if [ -f "$PID_FILE" ]; then
rm "$PID_FILE"
fi
else
logMsg="Plex Media Server hasn't been enabled or started..."
echo $logMsg
/sbin/log_tool -t 0 -a "$logMsg"
exit 0
fi
;;
restart)
$0 stop
sleep 5
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
As I promised, the flag file to disable it is ${QPKG_DIR}/Library/Plex Media Server/.disablePlexDataSymlink
If this file exists, then plex.sh does not attempt to do anything at all.
If this will hold you for now, great.
I’m going to go chat with Engineering and get them to make certain to include it when they build releases.
They need to get both parts of this (package creation scripting AND plex.sh) into what they release.
Hi @ChuckPa
thanks for your update.
Strange, I have updated from your developer build to the next official Plex Pass Beta release which solves the issue without recreating the share and it fixed the error while starting the Plex services.
Now, after updating today the recreation of the folder is back
BR/JO!
I was able to confirm,
- What you have is what Engineering still has as production in their latest 1.20.1 - final.
- My changes, which I shared in the developer build - will be official in 1.20.2
You’re free to (and I do request you) use the plex.sh
I’ve provided. It will respect the disable flag as we’ve set it up.
Reiterating: 1.20.2
- Will not create the share during package installation (QPKG master script changes)
- plex.sh will not attempt to operate on the PlexData share if disabled.
Would it be possible, for the Linux noobs, to provide a little more detail as to how to create a .sh file. Location of said plex.sh and how to create flag file? Myself I am 90% comfortable, but would sure be nice for everyone to get set of instructions.
I’ve considered it but the amount of bullet-proofing in written instructions would be an impossible task. It’s impossible because too many folks use Windows on their computer. When you copy/paste with Windows from the web into a file, Windows will always add CR & LF as the end-of-line marker. Linux uses LF as the end-of-line marker. This results in CR (carriage returns) on every line and breaks the script. The shell interpreter doesn’t know what to do with them.
The best I can offer is repackaging the existing released packages and sharing them here in UNSIGNED form. If I do this, I can be guaranteed Windows will respect the QPKG as the binary file it is. The new version of plex.sh
will get dropped in exactly as it should be by the QDK routines.
Should I repackage and post temporary links ?
Sounds like the more reliable approach. Unfortunately just puts more burden on you to create the packages. Myself running on QNAP and my first attempt at create .sh, making executable and creating flag file did not work. Plex did not load, but I am guessing it is my plex.sh file and CR.
Where is your PMS installed? CACHEDEV1_DATA ?
Let me know and I’ll give you the steps. You can try it and see what you think.
/share/CACHEDEV1_DATA/.qpkg/PlexMediaServer. Created the flag file with touch command.
NON-OFFICIAL QPKG MODIFICATION TECHNIQUE.
(note: This example shows CACHEDEV3_DATA. Most systems are installed on CACHEDEV1_DATA. Please use the correct location for your system)
-
Install QNAP Text Editor app (App Center)
-
Create a share, manually specifying the location of where Plex is installed on your system. This example is on CACHEDEV3_DATA. Most systems will be CACHEDEV1_DATA. Please adjust accordingly
-
Install the QNAP Text Editor app in App Center
-
Open File Station. Migrate into this new special purpose share to expose the raw Plex package files which are normally hidden.
-
Make certain PMS is STOPPED
-
Right-click plex.sh → Open with Text Editor
6a. Observe it looks like this:
THIS IS WHERE IT GETS TRICKY – BE CAREFUL
-
Scroll up in this thread to get the updated
plex.sh
I posted -
Highlight all the text in that window and right-click “Copy” (it’s usually easier to start highlighting from the bottom of the forum inset text window .. I don’t know why)
-
Flip to the Text Editor window
-
Staring with the first characters of line 1
#!/bin/sh
highlight ALL the text (All 220+ lines) -
Right-click and PASTE what you copied from the forum on top of what exists.
-
CONFIRM – 212 lines.
-
Go to the upper left corner of the Text Editor: File → Save
-
Exit from the text editor.
-
Start Plex.
This is working for me .
what’s the verdict?
Reviewed my work. Too late tonight. Missed the CR at the end of the new file after cut/paste. Kinda a big deal. Plex Starts/Stops normally now, but still cannot access Plex. I put in the original plex.sh and aside from the Share issue it runs. So it has something to do with the new plex.sh file. Either code or I am not doing something right. Created the new file with the Text Editor as you showed and with Notepad++ with correct EOL and chmod a+x on the new file. Feel like I am missing something simple.
Just to test. I copy/paste the original plex.sh script into a new file I created and saved, chmod, etc. Works fine so I am guessing it has something to do with the new code as file creation does not seem to be the hold up.
Late here too. Will deal with it tomorrow
It automatically works today! In reviewing the new working file and old unsuccessful plex.sh it appears with copying the code from the browser I was getting both CR and LF. The working script has just the LF. Kinda as you were mentioning above.
I assumed using the QNAP Text Editor from your instructions would remove the CR, but I was wrong as I can see them with using Notepad++.
As to why the current plex.sh on my system now has no CR thus making it work is unknown to me. Again just automatically happened over night.
I feel this is a noob issue on my side as I should know how to remove those CR when copy/paste.
This really isn’t a NOOB issue. Moving across disparate philosophies (CR/LF vs LF) requires a certain level of technical understanding.
To show you how CR/LF looks in Linux,
hello^M
there^M
The CR (which is Control-M key) looks like any normal character to Linux. It does see the LF and ends the line.
If you are willing to paste the text in, then find and remove that ^M
(the CR character) from the end of each line (all 212 of them in plex.sh
) then you’d be fine.
When I looked at the PlexData folder, I could not edit permissions, properties, and it had no volume. I deleted the folder, recreated it, stopped Plex, and when I restarted it no error.
I’m thoroughly confused!?
There are already 38 replies to this thread and lots of different instructions and methods to solving this problem .
My situation is, I can only see the PlexData folder in Windows Explorer, not In File Station, despite having hidden folders set to be visible.
The PlexData is at the root of my NAS (DataVol1) and the folder is empty.
So…what’s the simplest way to resolve this issue?
Thanks!
- Restart the QNAP (it seems you’ve taken the steps to export it in SMB for Windows)
- If this fails to add it FileStation for you, Go to Control Panel - Shared Folders - Edit Permissions and give your login name permission to see it.
- Close and reopen FileStation
Restarting QTS will also restart Plex.
Plex will do what it needs to do when it starts.
The only syncing needed here is within QTS