[freeside-commits] freeside/bin billco-upload,1.4,1.5

Jeff Finucane,420,, jeff at wavetail.420.am
Fri Jul 17 07:58:25 PDT 2009


Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail.420.am:/tmp/cvs-serv11354

Modified Files:
	billco-upload 
Log Message:
add mutex and commit changes found on installed system

Index: billco-upload
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/billco-upload,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- billco-upload	3 Jan 2006 08:45:27 -0000	1.4
+++ billco-upload	17 Jul 2009 14:58:22 -0000	1.5
@@ -1,11 +1,26 @@
 #!/bin/sh
 
-AGENTNUMS="1 2 3"
+AGENTNUMS="1 2 3 5 8 9 10"
 
 date=`date +"%Y%m%d"`
 dir="/usr/local/etc/freeside/export.DBI:Pg:dbname=freeside/cust_bill"
+lock=".billco-upload.lock"
 cd "$dir"
 
+failed_mutex()
+{
+  echo "billco-upload already running; exiting"
+  exit 1
+}
+
+#acquire mutex
+[ -f $lock ] && {
+  failed_mutex
+} || {
+  echo $$ > $lock
+  [ $(cat $lock 2>/dev/null) -eq $$ ] || failed_mutex
+}
+
 for AGENTNUM in $AGENTNUMS; do
 
   for a in header detail; do
@@ -14,7 +29,12 @@
 
   zip agentnum$AGENTNUM-$date.zip agentnum$AGENTNUM-$date-header.csv agentnum$AGENTNUM-$date-detail.csv
 
+# Remove if trying to find problems with billco upload files
+  rm *$AGENTNUM-$date*.csv
+
   echo $dir/agentnum$AGENTNUM-$date.zip
 
 done
 
+#release mutex
+rm -f $lock



More information about the freeside-commits mailing list