mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Merge pull request #9 from 2bits/2bits/support-mac
Changes to support MacOS
This commit is contained in:
commit
972b03c575
46
DBRepair.sh
46
DBRepair.sh
@ -246,7 +246,7 @@ RestoreSaved() {
|
||||
# Get the size of the given DB in MB
|
||||
GetSize() {
|
||||
|
||||
Size=$(stat -c %s "$1")
|
||||
Size=$(stat $STATFMT $STATBYTES "$1")
|
||||
Size=$(expr $Size / 1048576)
|
||||
[ $Size -eq 0 ] && Size=1
|
||||
echo $Size
|
||||
@ -255,6 +255,11 @@ GetSize() {
|
||||
# Determine which host we are running on and set variables
|
||||
HostConfig() {
|
||||
|
||||
# On all hosts except Mac
|
||||
PIDOF="pidof"
|
||||
STATFMT="-c"
|
||||
STATBYTES="%s"
|
||||
|
||||
# Synology (DSM 7)
|
||||
if [ -d /var/packages/PlexMediaServer ] && \
|
||||
[ -d "/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData/Plex Media Server" ]; then
|
||||
@ -419,6 +424,35 @@ HostConfig() {
|
||||
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
|
||||
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"
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
# Unknown / currently unsupported host
|
||||
@ -448,7 +482,7 @@ SetLast "" ""
|
||||
# Identify this host
|
||||
HostType="" ; LOG_TOOL="echo"
|
||||
if ! HostConfig; then
|
||||
Output 'Error: Unknown host. Currently supported hosts are: QNAP, Synology, Netgear, ASUSTOR, WD (OS5) and Linux Workstation/Server'
|
||||
Output 'Error: Unknown host. Currently supported hosts are: QNAP, Synology, Netgear, Mac, ASUSTOR, WD (OS5) and Linux Workstation/Server'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -497,7 +531,7 @@ while true
|
||||
do
|
||||
|
||||
# Is PMS already running?
|
||||
if [ -f "$PID_FILE" ] && [ "$(pidof 'Plex Media Server')" != "" ] ; then
|
||||
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."
|
||||
@ -728,7 +762,7 @@ do
|
||||
fi
|
||||
|
||||
# Check size
|
||||
Size=$(stat -c '%s' $CPPL.db)
|
||||
Size=$(stat $STATFMT $STATBYTES $CPPL.db)
|
||||
|
||||
# Exit if not valid
|
||||
if [ $Size -lt 300000 ]; then
|
||||
@ -743,7 +777,7 @@ do
|
||||
Fail=0
|
||||
|
||||
# Get the owning UID/GID before we proceed so we can restore
|
||||
Owner="$(stat -c '%u:%g' $CPPL.db)"
|
||||
Owner="$(stat $STATFMT '%u:%g' $CPPL.db)"
|
||||
|
||||
# Attempt to export main db to SQL file (Step 1)
|
||||
printf 'Export: (main)..'
|
||||
@ -1044,7 +1078,7 @@ do
|
||||
done
|
||||
|
||||
Output "Undo complete."
|
||||
WriteLog "Undo - Undo $LastName , TimeStamp $LastTimestamp"
|
||||
WriteLog "Undo - Undo ${LastName}, TimeStamp $LastTimestamp"
|
||||
SetLast "Undo" ""
|
||||
fi
|
||||
|
||||
|
||||
12
README.md
12
README.md
@ -38,6 +38,7 @@ It is a simple menu-driven utility with a command line backend.
|
||||
5. Synology (DSM 6 & DSM 7)
|
||||
6. Docker (via 'docker exec' command line)
|
||||
7. Western Digital (OS5)
|
||||
8. Apple (MacOS)
|
||||
|
||||
## How to install
|
||||
|
||||
@ -55,6 +56,7 @@ It is a simple menu-driven utility with a command line backend.
|
||||
Western Digital | Public | /mnt/HD/HD_a2/Public (Does not support 'MyCloudHome' series)
|
||||
Docker | N/A | Container root (adjacent /config)
|
||||
Linux (wkstn/svr) | N/A | Anywhere
|
||||
Apple | Downloads | ~/Downloads
|
||||
```
|
||||
### To install & launch:
|
||||
1. Place the tar/zip/sh file in the appropriate directory
|
||||
@ -89,6 +91,16 @@ It is a simple menu-driven utility with a command line backend.
|
||||
./DBRepair.sh
|
||||
```
|
||||
|
||||
### To launch in MacOS (on the administrator account)
|
||||
```
|
||||
osascript -e 'quit app "Plex Media Server"'
|
||||
cd ~/Downloads
|
||||
tar xvf PlexDBRepair-0.3.4.tar.gz
|
||||
cd PlexDBRepair-0.3.4
|
||||
chmod +x DBRepair.sh
|
||||
./DBRepair.sh
|
||||
```
|
||||
|
||||
|
||||
## The menu
|
||||
Plex Media Server Database Repair Utility
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user