summaryrefslogtreecommitdiff
path: root/sys/lib/fax/receiverc
blob: 8ea0ad754c506920520cecd440ab7b45cf9aad4c (plain)
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
#!/bin/rc
spool=/mail/faxqueue
recipients=/mail/faxqueue/faxrecipients

# run mail as if we're on fs
rm /srv/fs
9fs fs
bind -c /n/fs/mail/faxqueue /mail/faxqueue

#
# Arguments should be
#	time Y|N pages [ftsi]
#
switch($#*){

case 4
	#
	# Check for the NYT. It's 9 pages from 'Via Fax             '.
	#
	nyt=false
	if(~ $2 Y && {~ $4 'Via Fax             '}){
		switch(`{date|sed 's/ .*//'}){
		case Mon Tue Wed Thu Fri
			hour=`{date|sed 's/.* ([0-9][0-9]):.*/\1/'}
			if(test $3 -gt 7 -a '(' $hour -lt 7 -o $hour -ge 21 ')')
				nyt=true
		case *
			if(test $3 -gt 7)
				nyt=true
		}
	}
	switch($nyt){

	case true
		to=`{seq 0 1 $3}
		for(i in `{seq 2 1 $3}){
			switch($i){
	
			case ?
				ext=00$i
			case ??
				ext=0$i
			case ???
				ext=$i
			}
			cp $spool/$1.$ext /n/fs/lib/nyt/nyt.$to($i)
		}
		cp $spool/$1.1 /n/fs/lib/nyt/nyt.$3
		rm -f $spool/$1.*
	case *
		{echo $*; echo FAX: page -w $spool/$1.'*'} | mail `{cat $recipients}
	}
case 3
	{echo $*; echo FAX: page -w $spool/$1.'*'} | mail `{cat $recipients}
case *
	{echo $*; echo FAX: page -w $spool/$1.'*'} | mail jmk
}
exit 0