HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-users] backup script



Hey There!

I'd like to backup the incoming faxes on the server in pdf format.
I send the incoming faxes via email as pdf attachements. I've wrote a
script which i would like to invoke from faxrecvd.

Here's the script:

#!/bin/bash
#Beerkezo faxot archival az $ARCHIV konyvtarba ev, honap bontasban.
#Ket lehetoseg van:
#       - hylafax hivja meg a $faxrecvd szkriptbol, vagy
#       - cronbol fut
#
# Gabri Mate
# 2008-02-08
#

#celkonyvtar
echo "Inicializalas" >> /tmp/fax.log

CEL=/srv/fax/`date +%Y`/`date +%B`
FILE=$1
TELSZAM="$2"

celkonyvtar()
{
#celkonyvtar ellenorzese
if [ -e "$CEL" ]
then
    sleep 0
else
    mkdir -p $CEL
    chown -R nobody:nogroup $CEL
fi
}


cron()
{
celkonyvtar

FORRAS=/tmp/faxbackup
#ARCHIVALANDO=`ls -1 | head -n 1`

#bejovo faxok athelyezese a munkakonyvtarba
mv /var/spool/hylafax/recvq/*.tif $FORRAS

#pdf-e alakitas
for FILE in $FORRAS/*
do
    tiff2pdf $FILE -o $FORRAS/fax_`date +%F-%H_%M_%S`.pdf

#forras eltavolitasa
    rm $FILE
    sleep 1
done
chown nobody:nogroup $FORRAS/*.pdf
cp -p $FORRAS/*.pdf $CEL
rm $FORRAS/*.pdf
}

hylafax()
{
echo "Celkonyvtar ellenorzese" >> /tmp/fax.log
celkonyvtar

FORRAS=/tmp
#archivalas tenyleges lepese
echo "Archivalas tenyleges lepese" >> /tmp/fax.log
cp $FORRAS/$FILE.pdf $CEL/fax_$TELSZAM_`date +%F-%H_%M_%S`.pdf
2>/tmp/fax_error.log

#archivalt fajl jogosultsaganak megvaltoztatasa
echo "jogosultsag modositasa" >> /tmp/fax.log
FILE=`ls -1 $CEL | tail -n 1`
chown nobody:nogroup $FILE
}

##########################
#globalis beallitasok    #
##########################

#mukodesi modok
#cron/hylafax
echo "Mod kivalasztasa" >> /tmp/fax.log
OP="hylafax"

case $OP in
    cron)       cron;;
    hylafax)    hylafax;;
    *)          echo "Hibas vezerles!";;
esac

echo "kilepes" >> /tmp/fax.log
exit 0


I've put the script here in faxrecvd:

CreateMailMessage
$template                                                     \
tmp/$FILENAME.pdf application/pdf "$FILENAME.pdf" "FAX
Document"            \ 2>$ERRORSTO | $SENDMAIL -f"$FROMADDR" -oi
"$SENDTO" 
#/usr/local/bin/faxbackup $FILENAME $CIDNUMBER
2>/tmp/fax_error_hyla.log rm -f tmp/$FILENAME.pdf
rm -f tmp/$FILENAME.ps

When a fax arrives the script says that it can't find the appropriate
pdf file under /tmp.

Can You help me with this? I dont have any idea what to do now.

Thank You!
-- 
Gabri Mate
gabrimate@xxxxxxxxx
DUOSOL Bt.
http://www.duosol.hu

Attachment: signature.asc
Description: PGP signature




Project hosted by iFAX Solutions