Add PMS interlock

Prevents database actions when PMS is active.
This commit is contained in:
ChuckPa 2022-11-16 13:50:02 -05:00
parent 972b03c575
commit 3fda441b32
No known key found for this signature in database
GPG Key ID: 3CE28A0F6BC31B5B
2 changed files with 30 additions and 13 deletions

View File

@ -486,6 +486,14 @@ if ! HostConfig; then
exit 1 exit 1
fi fi
# Is PMS already running?
if $PIDOF 'Plex Media Server' > /dev/null ; then
Output "Plex Media Server is currently running, cannot continue."
Output "Please stop Plex Media Server and restart this utility."
WriteLog "PMS running. Could not continue."
exit 1
fi
echo " " echo " "
# echo Detected Host: $HostType # echo Detected Host: $HostType
WriteLog "============================================================" WriteLog "============================================================"
@ -530,21 +538,13 @@ cd "$DBDIR"
while true while true
do do
# Is PMS already running?
if [ -f "$PID_FILE" ] && [ "$($PIDOF 'Plex Media Server')" != "" ] ; then
Output "Plex Media Server is currently running, cannot continue."
Output "Please stop Plex Media Server and restart this utility."
WriteLog "PMS running. Could not continue."
exit 1
fi
# Main menu loop # Main menu loop
Choice=0; Exit=0 Choice=0; Exit=0
while [ $Choice -eq 0 ] while [ $Choice -eq 0 ]
do do
echo " " echo " "
echo " " echo " "
echo " (DEVELOPMENT) Plex Media Server Database Repair Utility ($HostType)" echo " Plex Media Server Database Repair Utility ($HostType)"
echo " " echo " "
echo "Select" echo "Select"
echo " " echo " "
@ -585,6 +585,16 @@ do
TimeStamp="$(date "+%Y-%m-%d_%H.%M.%S")" TimeStamp="$(date "+%Y-%m-%d_%H.%M.%S")"
done done
# Don't get caught; Is PMS already running?
if $PIDOF 'Plex Media Server' > /dev/null ; then
if [ $Choice -lt 8 ]; then
Output "Plex Media Server is currently running, cannot continue."
Output "Please stop Plex Media Server and restart this utility."
WriteLog "PMS running. Could not continue."
continue
fi
fi
# Spacing for legibility # Spacing for legibility
echo ' ' echo ' '

View File

@ -58,14 +58,14 @@ It is a simple menu-driven utility with a command line backend.
Linux (wkstn/svr) | N/A | Anywhere Linux (wkstn/svr) | N/A | Anywhere
Apple | Downloads | ~/Downloads Apple | Downloads | ~/Downloads
``` ```
### To install & launch: ### To install & launch on general Linux or most Linux NAS platforms:
1. Place the tar/zip/sh file in the appropriate directory 1. Place the tar/zip/sh file in the appropriate directory
2. Open a command line session (usually SSH) 2. Open a command line session (usually SSH)
3. Elevate privilege level to root 3. Elevate privilege level to root
4. Extract the utility from the tar or zip file 4. Extract the utility from the tar or zip file
4. Invoke the utility 4. Invoke the utility
(Synology DSM 6 used as example) #### (Synology DSM 6 used as example)
``` ```
cd /volume1/Plex cd /volume1/Plex
sudo bash sudo bash
@ -74,10 +74,17 @@ It is a simple menu-driven utility with a command line backend.
./DBRepair.sh ./DBRepair.sh
``` ```
### To launch in a container: ### To launch in a Docker container:
``` ```
sudo docker exec -it plex /bin/bash sudo docker exec -it plex /bin/bash
/plex_service.sh -d # Stop Plex
# Stop Plex when using official Plex,inc image
/plex_service.sh -d
--or--
# Stop Plex when using Linuxserver.io Plex image
s6-svc -d /var/run/service/svc-plex
tar xf DBRepair.tar tar xf DBRepair.tar
chmod +x DBRepair.sh chmod +x DBRepair.sh
./DBRepair.sh ./DBRepair.sh