File: efax-convert

package info (click to toggle)
efax 1%3A0.9a-19.1
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 456 kB
  • ctags: 572
  • sloc: ansic: 4,629; sh: 932; makefile: 77
file content (69 lines) | stat: -rw-r--r-- 1,424 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# fax conversion script for the efax package:
#   called by /usr/bin/fax when a fax is received.  Convert it to a
#   multipage compressed postscript document and e-mail it to $MAILTO
#   (default is postmaster)
#
# Copyright 1998, 1999 by Avery Pennarun <apenwarr@worldvisions.ca>
# Use, modify, and redistribute freely.
#

SENDMAIL=/usr/sbin/sendmail
FAXMGR=root
FAXDIR=/var/spool/fax

# override all options from the efax config file
source /etc/efax.rc

# process the command line
REMID="$(echo "$1" | sed 's/\(^\| \) */\1/g')"
shift
FILES="$*"

#set -x

xmit()
{
    SUBJECT="$1"

    (
	cat <<-EOF
		From: <efax@$HOSTNAME>
		MIME-Version: 1.0
		Subject: $SUBJECT
		Content-Type: multipart/mixed; boundary="xyz"
		Content-Transfer-Encoding: 7bit
		
		This is a MIME encoded message.  Use a MIME-compatible e-mail
		package if you want to read it.
		
		EOF

	cat <<-EOF
		--xyz
		Content-Type: application/postscript; name="fax.ps.gz"
		Content-Disposition: attachment; filename="$(basename fax.ps.gz)"
		Content-Transfer-Encoding: base64
		
		EOF
	
	shift
	cat | gzip -c | mimencode
	
	echo "--xyz"
	
    ) | $SENDMAIL $FAXMGR
}

set -e

cd $FAXDIR

PAGES="$(echo $FILES | wc -w | sed 's/[ 	]*//g')"

echo "Processing fax from $REMID ($PAGES pages)"
efix -ops $FILES </dev/null 2>/dev/null \
	| xmit "Fax: $PAGES pages from "\""$REMID"\"
mkdir done 2>/dev/null || true
mv $FILES done/ 2>/dev/null || true