X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fbillco-upload;h=a5f67cda44182e581a3cab92aa28cd909033ec6d;hp=3a02ec8bbb34a74dee790bbcf9a8f062ead4d2a4;hb=29d80a8582103ead0b5910391cabc45cb85fa836;hpb=4bfca794e2bd03379d11b9efe437676323e7eb31 diff --git a/bin/billco-upload b/bin/billco-upload index 3a02ec8bb..a5f67cda4 100644 --- a/bin/billco-upload +++ b/bin/billco-upload @@ -1,40 +1,15 @@ -#!/bin/sh +#!/usr/bin/perl -AGENTNUMS="1 2 3 5 8 9 10" +use FS::UID qw(adminsuidsetup); +use FS::Cron::upload; -date=`date +"%Y%m%d"` -dir="/usr/local/etc/freeside/export.DBI:Pg:dbname=freeside/cust_bill" -lock=".billco-upload.lock" -cd "$dir" +adminsuidsetup shift or die "usage: billco-upload username agentnum\n"; +my $agentnum = shift or die "usage: billco-upload username agentnum\n"; -failed_mutex() -{ - echo "billco-upload already running; exiting" - exit 1 -} +FS::Cron::upload::billco_upload( 'agentnum' => $agentnum, + 'date' => time, + 'v' => 1, + 'l' => 2, + ); -#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 - mv agentnum$AGENTNUM-$a.csv agentnum$AGENTNUM-$date-$a.csv - done - - 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 +1;