Procházet zdrojové kódy

Add support for runtime DEBUG

Zachary Kotlarek před 12 roky
rodič
revize
f6ddc8cbc9
1 změnil soubory, kde provedl 23 přidání a 1 odebrání
  1. 23 1
      folderFixup.sh

+ 23 - 1
folderFixup.sh

@@ -3,6 +3,12 @@
 # Parameters
 inFolder="`~/bin/video/mediaPath`/TV"
 
+# Debug
+if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+	echo -n "Starting `basename "${0}"`: "
+	date
+fi
+
 # Command line
 if [ -n "${1}" ]; then
 	inFolder="${1}"
@@ -15,17 +21,24 @@ fi
 # Bail if we're already running
 me="`basename "${0}"`"
 if [ `ps auwx | grep -v grep | grep "${me}" | wc -l` -gt 2 ]; then
+	if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+		echo 'Already running' 1>&2
+	fi
 	exit 0
 fi
 
 # Bail if the load is high
 if ! ~/bin/video/checkLoad.sh; then
+	if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+		echo 'Load too high' 1>&2
+	fi
 	exit 0
 fi
 
 # Bail if the media share isn't available
 if ! ~/bin/video/isMediaMounted; then
-	exit 0
+	echo 'Media not mounted' 1>&2
+	exit 1
 fi
 
 # Cache output
@@ -41,3 +54,12 @@ cat "${tmp}" | \
 	grep -v "ERROR: Unexpected Error. (-1401)  on file: " | \
 	grep -v "ERROR: Unexpected Error. (-5000)  on file: " | \
 	grep -v "^ *$"
+
+# Cleanup
+rm -rf "${tmp}"
+
+# Debug
+if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+	echo -n 'Complete: '
+	date
+fi