]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Now use hfExit and SetupPrivateTmp in util scripts
authorPatrice Fournier <pfournier@ifax.com>
Fri, 13 Jun 2008 19:06:28 +0000 (19:06 +0000)
committerPatrice Fournier <pfournier@ifax.com>
Fri, 13 Jun 2008 19:06:28 +0000 (19:06 +0000)
Util scripts now source common-functions and use SetupPrivateTmp when
requiring a tmp dir and always exit with hfExit.

util/faxcron.sh.in
util/faxrcvd.sh.in
util/notify.sh.in
util/pollrcvd.sh.in
util/recvstats.sh.in
util/xferfaxstats.sh.in

index c38a2755aeac758b60d90a4864696cc57eb2a9f3..fe1833442dad2af4dd524fd6c8f2f5e11490f75c 100644 (file)
@@ -47,6 +47,7 @@ XFERLOG=etc/xferfaxlog                # HylaFAX xferfaxlog file location
 LAST=etc/lastrun               # file where time+date of last run recorded
 
 cd @SPOOL@                     # NB: everything below assumes this
+. bin/common-functions
 
 test -f etc/setup.cache || {
     SPOOL=`pwd`
@@ -60,7 +61,7 @@ command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
 EOF
-    exit 1
+    hfExit 1
 }
 . etc/setup.cache
 
@@ -69,12 +70,7 @@ TEE=tee
 UPDATE="date +'%D %H:%M' >$LAST"
 
 # security
-TMPDIR=`(mktemp -d /tmp/.faxcron.XXXXXX) 2>/dev/null`
-if test X$TMPDIR = X; then
-    TMPDIR=/tmp/.faxcron$$
-fi
-@RM@ -fr $TMPDIR
-(umask 077 ; mkdir $TMPDIR) || exit 1
+SetupPrivateTmp
 
 JUNK=$TMPDIR/faxjunk$$         # temp file used multiple times
 AWKTMP=$TMPDIR/faxawk$$                # temp file for awk program
@@ -88,14 +84,11 @@ while [ x"$1" != x"" ] ; do
     -rcv)   shift; AGERCV="$1";;
     -tmp)   shift; AGETMP="$1";;
     -mode)  shift; LOGMODE="$1";;
-    -*)            echo "Usage: $0 [-n] [-l lastrun] [-info days] [-log days] [-rcv days] [-tmp days] [-mode logmode]"; exit 1;;
+    -*)            echo "Usage: $0 [-n] [-l lastrun] [-info days] [-log days] [-rcv days] [-tmp days] [-mode logmode]"; hfExit 1;;
     esac
     shift
 done
 
-trap "$RM \$AWKTMP \$JUNK; $RM -rf $TMPDIR; exit 1" 1 2 15
-
-
 test -z "$LASTRUN" && LASTRUN=`$CAT $LAST 2>/dev/null`
 
 echo "Facsimile transmitted since $LASTRUN:"
@@ -474,5 +467,4 @@ fi
 $RM $LAST; eval $UPDATE
 
 # cleanup
-$RM $AWKTMP $JUNK; $RM -rf $TMPDIR
-exit 0
+hfExit 0
index 67d8548f9c6aa05ba150232e2090e9298d4d22a2..fde22e87693e1acd3f53f917e645fce2197eedda 100644 (file)
 # OF THIS SOFTWARE.
 #
 
+. bin/common-functions
+
 #
 # faxrcvd file devID commID error-msg
 #
 if [ $# -lt 4 ]; then
     echo "Usage: $0 file devID commID error-msg [ callID-1 [ callID-2 [ ... [ callID-n ] ] ] ]"
-    exit 1
+    hfExit 1
 fi
 
 test -f etc/setup.cache || {
@@ -47,7 +49,7 @@ command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
 EOF
-    exit 1
+    hfExit 1
 }
 
 # These settings may not be present in setup.cache if user upgraded and
@@ -58,7 +60,6 @@ TIFF2PDF=bin/tiff2pdf
 TTYCMD=tty
 
 . etc/setup.cache
-. bin/common-functions
 
 INFO=$SBIN/faxinfo
 FAX2PS=$TIFFBIN/fax2ps
index b04ad557afb58b2a0cb9c24223d4444fd5c0be51..f70fc53ef9c17c80668290072f5e464aac8f3c1a 100644 (file)
 # whitespace; in that case a separate attachment for each filetype
 # will be created.
 
+. bin/common-functions
+
 if [ $# != 3 ] && [ $# != 4 ]; then
     echo "Usage: $0 qfile why jobtime [nextTry]"
-    exit 1
+    hfExit 1
 fi
 
 test -f etc/setup.cache || {
@@ -44,7 +46,7 @@ command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
 EOF
-    exit 1
+    hfExit 1
 }
 
 # need to parse out the command line here.  some may be needed
@@ -62,7 +64,6 @@ TIFF2PDF=bin/tiff2pdf
 TTYCMD=tty
 
 . etc/setup.cache
-. bin/common-functions
 
 INFO=$SBIN/faxinfo
 TIFFINFO=tiffinfo
index 12b085be558e5a1dc8796df0cf619fd2faae8eb7..3a2edfbb6e6bf7e803cecf9f6d9803de2ee4a536 100644 (file)
 # OF THIS SOFTWARE.
 #
 
+. bin/common-functions
+
 #
 # pollrcvd mailaddr faxfile devID commID error-msg
 #
 if [ $# != 5 ]
 then
     echo "Usage: $0 mailaddr faxfile devID commID error-msg"
-    exit 1
+    hfExit 1
 fi
 
 test -f etc/setup.cache || {
@@ -48,7 +50,7 @@ command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
 EOF
-    exit 1
+    hfExit 1
 }
 
 # These settings may not be present in setup.cache if user upgraded and
@@ -59,7 +61,6 @@ TIFF2PDF=bin/tiff2pdf
 TTYCMD=tty
 
 . etc/setup.cache
-. bin/common-functions
 
 INFO=$SBIN/faxinfo
 FAX2PS=$TIFFBIN/fax2ps
index 043e14973ab26207255f833866a174aa775441a8..2c51f827ae5d0a2da83eeaddc6cc239502357d30 100644 (file)
@@ -34,6 +34,7 @@ NOCLOBBER_OFF=@NOCLOBBER_OFF@
 # Print Statistics about Received Facsimile.
 #
 SPOOL=@SPOOL@
+. $SPOOL/bin/common-functions
 
 test -f $SPOOL/etc/setup.cache || {
     cat<<EOF
@@ -46,7 +47,7 @@ command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
 EOF
-    exit 1
+    hfExit 1
 }
 . $SPOOL/etc/setup.cache
 
@@ -65,7 +66,7 @@ while [ x"$1" != x"" ] ; do
     -since) shift; SINCEDT=$1;;
     -end) shift; ENDDT=$1;;
     -*)            echo "Usage: $0 [-sortkey] [-age days] [-since date] [-end date] [files]"
-           exit 1
+           hfExit 1
            ;;
     *)     FILES="$FILES $1";;
     esac
@@ -154,14 +155,8 @@ esac
 #
 # Generate an awk program to process the statistics file.
 #
-TMPDIR=`(mktemp -d /tmp/.recvstats.XXXXXX) 2>/dev/null`
-if test X$TMPDIR = X; then
-    TMPDIR=/tmp/.recvstats$$
-fi
-@RM@ -fr $TMPDIR
-(umask 077 ; mkdir $TMPDIR) || exit 1
+SetupPrivateTmp
 tmpAwk=$TMPDIR/xferfax$$
-trap "@RM@ -f $tmpAwk; @RM@ -fr $TMPDIR; exit 1" 1 2 15
 
 ($CAT<<'EOF'
 #
@@ -471,5 +466,4 @@ echo "$AWKRULES"
 $AWK -f $tmpAwk -v TODAY="$TODAY" -v AGE="$AGE" -v SINCEDT="$SINCEDT" -v ENDDT="$ENDDT" $FILES
 
 # cleanup
-@RM@ -f $tmpAwk; @RM@ -fr $TMPDIR
-exit 0
+hfExit 0
index e1ad1dad79354f79ba9f21f59be2af68c35e7ae4..0351ac3f6b4703ec04d09b4dfbf69ab410656c7f 100644 (file)
@@ -31,6 +31,7 @@
 # Print Statistics about Transmitted Facsimile.
 #
 SPOOL=@SPOOL@
+. $SPOOL/bin/common-functions
 
 test -f $SPOOL/etc/setup.cache || {
     cat<<EOF
@@ -43,7 +44,7 @@ command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
 EOF
-    exit 1
+    hfExit 1
 }
 . $SPOOL/etc/setup.cache
 
@@ -64,7 +65,7 @@ while [ x"$1" != x"" ] ; do
     -age)   shift; AGE=$1;;
     -since) shift; SINCEDT=$1;;
     -end) shift; ENDDT=$1;;
-    -*)            echo "Usage: $0 [-sortkey] [-age days] [-since date] [-end date] [-nomap] [files]"; exit 1;;
+    -*)            echo "Usage: $0 [-sortkey] [-age days] [-since date] [-end date] [-nomap] [files]"; hfExit 1;;
     *)     FILES="$FILES $1";;
     esac
     shift
@@ -183,14 +184,8 @@ esac
 #
 # Generate an awk program to process the statistics file.
 #
-TMPDIR=`(mktemp -d /tmp/.xferfaxstats.XXXXXX) 2>/dev/null`
-if test X$TMPDIR = X; then
-    TMPDIR=/tmp/.xferfaxstats$$
-fi
-@RM@ -fr $TMPDIR
-(umask 077 ; mkdir $TMPDIR) || exit 1
+SetupPrivateTmp
 tmpAwk=$TMPDIR/xferfax$$
-trap "@RM@ -fr $TMPDIR; exit 1" 1 2 15
 
 ($CAT<<'EOF'
 #
@@ -623,5 +618,4 @@ echo "$AWKRULES"
 $AWK -f $tmpAwk -v TODAY="$TODAY" -v AGE="$AGE" -v SINCEDT="$SINCEDT" -v ENDDT="$ENDDT" $FILES
 
 # cleanup
-@RM@ -fr $TMPDIR
-exit 0
+hfExit 0