mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Fixes:
Fix Binhex container detection. Re-prioritize host detection; move MacOS detection higher up to avoid mis-identification.
This commit is contained in:
parent
b810055546
commit
2c85008dc3
162
DBRepair.sh
162
DBRepair.sh
@ -2,12 +2,12 @@
|
|||||||
#########################################################################
|
#########################################################################
|
||||||
# Plex Media Server database check and repair utility script. #
|
# Plex Media Server database check and repair utility script. #
|
||||||
# Maintainer: ChuckPa #
|
# Maintainer: ChuckPa #
|
||||||
# Version: v1.0.5 #
|
# Version: v1.0.6 #
|
||||||
# Date: 16-May-2023 #
|
# Date: 28-May-2023 #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
# Version for display purposes
|
# Version for display purposes
|
||||||
Version="v1.0.5"
|
Version="v1.0.6"
|
||||||
|
|
||||||
# Flag when temp files are to be retained
|
# Flag when temp files are to be retained
|
||||||
Retain=0
|
Retain=0
|
||||||
@ -466,45 +466,6 @@ HostConfig() {
|
|||||||
StopCommand="systemctl stop plexmediaserver"
|
StopCommand="systemctl stop plexmediaserver"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Arch Linux
|
|
||||||
elif [ -e /etc/os-release ] && [ "$(grep 'Arch Linux' /etc/os-release)" != "" ] && \
|
|
||||||
[ -d /usr/lib/plexmediaserver ] && \
|
|
||||||
[ -d /var/lib/plex ]; then
|
|
||||||
|
|
||||||
|
|
||||||
# Where is the software
|
|
||||||
PKGDIR="/usr/lib/plexmediaserver"
|
|
||||||
PLEX_SQLITE="$PKGDIR/Plex SQLite"
|
|
||||||
LOG_TOOL="logger"
|
|
||||||
|
|
||||||
# Where is the data
|
|
||||||
AppSuppDir="/var/lib/plex"
|
|
||||||
|
|
||||||
# Find the metadata dir if customized
|
|
||||||
if [ -e /etc/systemd/system/plexmediaserver.service.d ]; then
|
|
||||||
|
|
||||||
# Get custom AppSuppDir if specified
|
|
||||||
NewSuppDir="$(GetOverride PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR)"
|
|
||||||
|
|
||||||
if [ "$NewSuppDir" != "" ]; then
|
|
||||||
if [ -d "$NewSuppDir" ]; then
|
|
||||||
AppSuppDir="$NewSuppDir"
|
|
||||||
else
|
|
||||||
Output "Given application support directory override specified does not exist: '$NewSuppDir'. Ignoring."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
|
||||||
LOGFILE="$DBDIR/DBRepair.log"
|
|
||||||
LOG_TOOL="logger"
|
|
||||||
HostType="Arch Linux"
|
|
||||||
|
|
||||||
HaveStartStop=1
|
|
||||||
StartCommand="systemctl start plexmediaserver"
|
|
||||||
StopCommand="systemctl stop plexmediaserver"
|
|
||||||
return 0
|
|
||||||
|
|
||||||
# Netgear ReadyNAS
|
# Netgear ReadyNAS
|
||||||
elif [ -e /etc/os-release ] && [ "$(cat /etc/os-release | grep ReadyNASOS)" != "" ]; then
|
elif [ -e /etc/os-release ] && [ "$(cat /etc/os-release | grep ReadyNASOS)" != "" ]; then
|
||||||
|
|
||||||
@ -544,6 +505,54 @@ HostConfig() {
|
|||||||
HostType="ASUSTOR"
|
HostType="ASUSTOR"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
# Apple Mac
|
||||||
|
elif [ -d "/Applications/Plex Media Server.app" ] && \
|
||||||
|
[ -d "$HOME/Library/Application Support/Plex Media Server" ]; then
|
||||||
|
|
||||||
|
# Where is the software
|
||||||
|
PLEX_SQLITE="/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite"
|
||||||
|
AppSuppDir="$HOME/Library/Application Support"
|
||||||
|
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
||||||
|
PID_FILE="$DBDIR/dbtmp/plexmediaserver.pid"
|
||||||
|
LOGFILE="$DBDIR/DBRepair.log"
|
||||||
|
LOG_TOOL="logger"
|
||||||
|
|
||||||
|
# MacOS uses pgrep and uses different stat options
|
||||||
|
PIDOF="pgrep"
|
||||||
|
STATFMT="-f"
|
||||||
|
STATBYTES="%z"
|
||||||
|
STATPERMS="%A"
|
||||||
|
|
||||||
|
# make the TMP directory in advance to store plexmediaserver.pid
|
||||||
|
mkdir -p "$DBDIR/dbtmp"
|
||||||
|
|
||||||
|
# Remove stale PID file if it exists
|
||||||
|
[ -f "$PID_FILE" ] && rm "$PID_FILE"
|
||||||
|
|
||||||
|
# If PMS is running create plexmediaserver.pid
|
||||||
|
PIDVALUE=$($PIDOF "Plex Media Server")
|
||||||
|
[ $PIDVALUE ] && echo $PIDVALUE > "$PID_FILE"
|
||||||
|
|
||||||
|
HostType="Mac"
|
||||||
|
return 0
|
||||||
|
|
||||||
|
# Western Digital (OS5)
|
||||||
|
elif [ -f /etc/system.conf ] && [ -d /mnt/HD/HD_a2/Nas_Prog/plexmediaserver ] && \
|
||||||
|
grep "Western Digital Corp" /etc/system.conf >/dev/null; then
|
||||||
|
|
||||||
|
# Where things are
|
||||||
|
PLEX_SQLITE="/mnt/HD/HD_a2/Nas_Prog/plexmediaserver/binaries/Plex SQLite"
|
||||||
|
AppSuppDir="$(echo /mnt/HD/HD*/Nas_Prog/plex_conf)"
|
||||||
|
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||||
|
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
||||||
|
LOGFILE="$DBDIR/DBRepair.log"
|
||||||
|
LOG_TOOL="logger"
|
||||||
|
|
||||||
|
HostType="Western Digital"
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
# Containers:
|
# Containers:
|
||||||
# - Docker cgroup v1 & v2
|
# - Docker cgroup v1 & v2
|
||||||
# - Podman (libpod)
|
# - Podman (libpod)
|
||||||
@ -594,7 +603,8 @@ HostConfig() {
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# BINHEX Plex image
|
# BINHEX Plex image
|
||||||
elif [ -f /usr/lib/python3.10/binhex.py ] && [ -d "/config/Plex Media Server" ]; then
|
elif [ -e /etc/os-release ] && grep "IMAGE_ID=archlinux" /etc/os-release 1>/dev/null && \
|
||||||
|
[ -e /home/nobody/start.sh ] && [ grep PLEX_MEDIA /home/nobody/start.sh 1> /dev/null ]; then
|
||||||
|
|
||||||
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
||||||
AppSuppDir="/config"
|
AppSuppDir="/config"
|
||||||
@ -608,54 +618,48 @@ HostConfig() {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Arch Linux (must check for native Arch after binhex)
|
||||||
|
elif [ -e /etc/os-release ] && [ "$(grep 'Arch Linux' /etc/os-release)" != "" ] && \
|
||||||
|
[ -d /usr/lib/plexmediaserver ] && \
|
||||||
|
[ -d /var/lib/plex ]; then
|
||||||
|
|
||||||
# Western Digital (OS5)
|
|
||||||
elif [ -f /etc/system.conf ] && [ -d /mnt/HD/HD_a2/Nas_Prog/plexmediaserver ] && \
|
|
||||||
grep "Western Digital Corp" /etc/system.conf >/dev/null; then
|
|
||||||
|
|
||||||
# Where things are
|
|
||||||
PLEX_SQLITE="/mnt/HD/HD_a2/Nas_Prog/plexmediaserver/binaries/Plex SQLite"
|
|
||||||
AppSuppDir="$(echo /mnt/HD/HD*/Nas_Prog/plex_conf)"
|
|
||||||
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
|
||||||
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
|
||||||
LOGFILE="$DBDIR/DBRepair.log"
|
|
||||||
LOG_TOOL="logger"
|
|
||||||
|
|
||||||
HostType="Western Digital"
|
|
||||||
return 0
|
|
||||||
|
|
||||||
# Apple Mac
|
|
||||||
elif [ -d "/Applications/Plex Media Server.app" ] && \
|
|
||||||
[ -d "$HOME/Library/Application Support/Plex Media Server" ]; then
|
|
||||||
|
|
||||||
# Where is the software
|
# Where is the software
|
||||||
PLEX_SQLITE="/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite"
|
PKGDIR="/usr/lib/plexmediaserver"
|
||||||
AppSuppDir="$HOME/Library/Application Support"
|
PLEX_SQLITE="$PKGDIR/Plex SQLite"
|
||||||
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
|
||||||
PID_FILE="$DBDIR/dbtmp/plexmediaserver.pid"
|
|
||||||
LOGFILE="$DBDIR/DBRepair.log"
|
|
||||||
LOG_TOOL="logger"
|
LOG_TOOL="logger"
|
||||||
|
|
||||||
# MacOS uses pgrep and uses different stat options
|
# Where is the data
|
||||||
PIDOF="pgrep"
|
AppSuppDir="/var/lib/plex"
|
||||||
STATFMT="-f"
|
|
||||||
STATBYTES="%z"
|
|
||||||
STATPERMS="%A"
|
|
||||||
|
|
||||||
# make the TMP directory in advance to store plexmediaserver.pid
|
# Find the metadata dir if customized
|
||||||
mkdir -p "$DBDIR/dbtmp"
|
if [ -e /etc/systemd/system/plexmediaserver.service.d ]; then
|
||||||
|
|
||||||
# Remove stale PID file if it exists
|
# Get custom AppSuppDir if specified
|
||||||
[ -f "$PID_FILE" ] && rm "$PID_FILE"
|
NewSuppDir="$(GetOverride PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR)"
|
||||||
|
|
||||||
# If PMS is running create plexmediaserver.pid
|
if [ "$NewSuppDir" != "" ]; then
|
||||||
PIDVALUE=$($PIDOF "Plex Media Server")
|
if [ -d "$NewSuppDir" ]; then
|
||||||
[ $PIDVALUE ] && echo $PIDVALUE > "$PID_FILE"
|
AppSuppDir="$NewSuppDir"
|
||||||
|
else
|
||||||
|
Output "Given application support directory override specified does not exist: '$NewSuppDir'. Ignoring."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
HostType="Mac"
|
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
||||||
|
LOGFILE="$DBDIR/DBRepair.log"
|
||||||
|
LOG_TOOL="logger"
|
||||||
|
HostType="Arch Linux"
|
||||||
|
|
||||||
|
HaveStartStop=1
|
||||||
|
StartCommand="systemctl start plexmediaserver"
|
||||||
|
StopCommand="systemctl stop plexmediaserver"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Unknown / currently unsupported host
|
# Unknown / currently unsupported host
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
# Release Info:
|
# Release Info:
|
||||||
|
|
||||||
|
v1.0.6
|
||||||
|
- Correct detection conflict between Arch Linux native package and Binhex container.
|
||||||
|
|
||||||
v1.0.5
|
v1.0.5
|
||||||
- Add Arch Linux Support
|
- Add Arch Linux Support
|
||||||
- Put system override processing in function
|
- Put system override processing in function
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user