From b029ccebbbd0cd57807c02b6e543f879fe4521ec Mon Sep 17 00:00:00 2001 From: 2bits <1025689+2bits@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:49:13 -0700 Subject: [PATCH] Support Mac Start Stop Use osascript to Start and Stop PMS on Apple Mac. --- DBRepair.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/DBRepair.sh b/DBRepair.sh index 27f3b22..e43ee59 100755 --- a/DBRepair.sh +++ b/DBRepair.sh @@ -575,7 +575,6 @@ HostConfig() { AppSuppDir="$HOME/Library/Application Support" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" CACHEDIR="$HOME/Library/Caches/PlexMediaServer/PhotoTranscoder" - PID_FILE="$DBDIR/dbtmp/plexmediaserver.pid" LOGFILE="$DBDIR/DBRepair.log" LOG_TOOL="logger" @@ -588,15 +587,11 @@ HostConfig() { # Root not required on MacOS. PMS runs as username. RootRequired=0 - # 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" + # You can set haptic to 0 for silence. + HaveStartStop=1 + StartCommand=startMacPMS + StopCommand=stopMacPMS + HapticOkay=1 HostType="Mac" return 0 @@ -1545,6 +1540,12 @@ DoStop(){ return $Result } +# Mac Helper Functions +startMacPMS() { TMPDIR=/tmp osascript -e 'tell app "Plex Media Server" to launch'; sleep 2; IsRunning && sayStarted; } +stopMacPMS() { osascript -e 'tell app "Plex Media Server" to quit'; sleep 2; IsRunning || sayStopped; } +sayStarted() { [ $HapticOkay -eq 1 ] && osascript -e 'say "started"'; } +sayStopped() { [ $HapticOkay -eq 1 ] && osascript -e 'say "Its stopped"'; } + # Do command line switches #DoOptions() {