فهرست منبع

Better scan tracking. Consolidate code.

Zachary Kotlarek 14 سال پیش
والد
کامیت
00dfd4aeb4
5فایلهای تغییر یافته به همراه37 افزوده شده و 5 حذف شده
  1. 1 1
      pms/PMSCheck.sh
  2. 5 4
      pms/PMSHelper.sh
  3. 6 0
      pms/isScanning.sh
  4. 5 0
      pms/killPMS.sh
  5. 20 0
      pms/scan.sh

+ 1 - 1
pms/PMSCheck.sh

@@ -31,7 +31,7 @@ while [ $LOOP -ne 0 ]; do
 		ERR_MSG="PMS is non-responsive (${FAILED}). Killing..."
 		echo "${ERR_MSG}" 1>&2
 
-		killall 'Plex Media Server'
+		~/bin/video/pms/killPMS.sh
 		if [ $LOOP -lt 1 ]; then
 			exit 1
 		elif [ -n "${ADMIN_EMAIL}" ]; then

+ 5 - 4
pms/PMSHelper.sh

@@ -1,12 +1,13 @@
 #!/bin/bash
 
-killall 'Plex Media Server' >/dev/null 2>&1
-killall 'Plex Media Scanner' >/dev/null 2>&1
-sleep 1
-
+# Wait for the media share to be mounted
 if ! ~/bin/video/isMediaMounted; then
 	sleep 5
 	exit 1
 fi
 
+# Kill previous instances
+~/bin/video/pms/killPMS.sh
+
+# Exec
 exec '/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Server'

+ 6 - 0
pms/isScanning.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+if ps auwx | grep -v grep | grep -q 'Plex Media Scanner'; then
+	exit 0
+fi
+exit 1

+ 5 - 0
pms/killPMS.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+killall 'Plex Media Server' >/dev/null 2>&1
+killall 'Plex Media Scanner' >/dev/null 2>&1
+sleep 1

+ 20 - 0
pms/scan.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Bail if the media share isn't mounted
+if ! ~/bin/video/isMediaMounted; then
+	exit 0
+fi
+
+# Bail if we are already scanning
+if ~/bin/video/pms/isScanning.sh; then
+	exit 0
+fi
+
+# Scan, appending any parameters passed to us
+/Applications/Zach/Media/Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Scanner --scan ${@}
+
+# Check the return; kill the PMS if things did not go well
+if [ $? -ne 0 ]; then
+	~/bin/video/pms/killPMS.sh
+fi
+