Explorar o código

Allow interactive use

Zachary Kotlarek %!s(int64=11) %!d(string=hai) anos
pai
achega
a177138751
Modificáronse 2 ficheiros con 31 adicións e 11 borrados
  1. 30 11
      pms/PMSHelper.sh
  2. 1 0
      pms/pms-interactive

+ 30 - 11
pms/PMSHelper.sh

@@ -1,16 +1,35 @@
 #!/bin/bash
 
-# Always re-trigger a mount (to fix links if the network changes)
-~/bin/video/mountMedia
-
-# Wait for the media share to be mounted
-if ! ~/bin/video/isMediaMounted; then
-	sleep 5
-	exit 1
+# Run interactively if requested
+INTERACTIVE=0
+if basename "${0}" | grep -iq interactive; then
+	INTERACTIVE=1
 fi
 
-# Kill previous instances
-~/bin/video/pms/killPMS.sh
+# This looks like it always loops
+# But if we exec at the end bash just goes away and the loop doesn't matter
+while [ 1 ]; do
+
+	# Always re-trigger a mount (to fix links if the network changes)
+	~/bin/video/mountMedia
+
+	# Wait for the media share to be mounted
+	if ! ~/bin/video/isMediaMounted; then
+		sleep 5
+		if [ $INTERACTIVE -gt 0 ]; then
+			continue
+		else
+			exit 1
+		fi
+	fi
+
+	# Kill previous instances
+	~/bin/video/pms/killPMS.sh
 
-# Exec
-exec '/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Server'
+	# Exec
+	EXEC=""
+	if [ $INTERACTIVE -le 0 ]; then
+		EXEC="exec"
+	fi
+	$EXEC '/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Server'
+done

+ 1 - 0
pms/pms-interactive

@@ -0,0 +1 @@
+PMSHelper.sh