Browse Source

add check_series.sh

Bill Gianopoulos 3 years ago
parent
commit
b493d32533
1 changed files with 44 additions and 0 deletions
  1. 44 0
      scripts/check_series.sh

+ 44 - 0
scripts/check_series.sh

@@ -0,0 +1,44 @@
+#!/bin/bash
+ERRORS=0
+pushd $1
+if [ ! -f series ]
+then
+  echo no series file found
+  popd
+  exit 1
+fi
+for i in *
+do
+  if [ "$i" != "series" -a "$i" != "status" ]
+  then
+    COUNT=`grep ^$i$ series | wc | sed -e 's@^\s*@@g' -e 's@ .*$@@g'`
+    if [ "$COUNT" != "1" ]
+    then
+      ERRORS=`expr $ERRORS + 1`
+      echo $i appears $COUNT time in series
+    fi
+  fi
+done
+for i in `cat series`
+do
+  if [ ! -f $i ]
+  then
+    echo File $i in series does not exist.
+    ERRORS=`expr $ERRORS + 1`
+    echo $i
+  fi
+done
+popd
+if [ "$ERRORS" = "0" ]
+then
+  echo no errors detected
+  exit 0
+else
+  if [ "$ERRORS" = "1" ]
+  then
+    echo 1 error detected
+  else
+    echo $ERRORS errors detected
+  fi
+fi
+exit 1