1 |
unnilennium |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
## More sample jobcontrol programs can be found at |
4 |
|
|
## http://www.hylafax.org/content/JobControl |
5 |
|
|
|
6 |
|
|
## |
7 |
|
|
## This is a sample jobcontrol program for HylaFAX that can be used |
8 |
|
|
## to Virtualize a fax service for various "client" companies in a |
9 |
|
|
## single HylaFAX installation |
10 |
|
|
## |
11 |
|
|
## This virtualization does a few things: |
12 |
|
|
## 1) Verifies client |
13 |
|
|
## 2) Rejects jobs that the client submitted that we consider |
14 |
|
|
## Malicious |
15 |
|
|
## 3) Set's Modem based on destination and client settings |
16 |
|
|
## 4) Set's faxsend options to make the job appear from the client's own |
17 |
|
|
## FAX service |
18 |
|
|
## |
19 |
|
|
## This assumes that by default, faxsend is configured not allow TSI |
20 |
|
|
## modification, and is branded with our fax service branding/numbers/etc. |
21 |
|
|
## |
22 |
|
|
## To get full milage from this type of JobControl, you should have the |
23 |
|
|
## following settings in $SPOOL/etc/config for FaxQueuer: |
24 |
|
|
## MaxBatchJobs: 1 |
25 |
|
|
## JobControlCmd: bin/jcontrol.sh |
26 |
|
|
## JobControlWait: false |
27 |
|
|
## |
28 |
|
|
|
29 |
|
|
JOBID=$1 |
30 |
|
|
|
31 |
|
|
## GetClient <owner> <email> |
32 |
|
|
## - returns a string - the client identifier |
33 |
|
|
|
34 |
|
|
## Result of "REJECT" is a non-authorized submitter, and |
35 |
|
|
## should be rejected. |
36 |
|
|
## Result of "" means it's not a virtualized client and |
37 |
|
|
## should be subject to our default modem settings |
38 |
|
|
GetClient () |
39 |
|
|
{ |
40 |
|
|
# Pretend to lookup the user |
41 |
|
|
case "$1" in |
42 |
|
|
# aidan) |
43 |
|
|
# echo "1234" |
44 |
|
|
# ;; |
45 |
|
|
# root) |
46 |
|
|
# echo "REJECT" |
47 |
|
|
# ;; |
48 |
|
|
*) |
49 |
|
|
# All others are not full virtual clients |
50 |
|
|
echo "" |
51 |
|
|
esac |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
## |
55 |
|
|
## GetJobParam <param> |
56 |
|
|
## - returns the value of the job param |
57 |
|
|
GetJobParam () |
58 |
|
|
{ |
59 |
|
|
grep "^$1:" sendq/q$JOBID | cut -d : -f 2- |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
## |
63 |
|
|
## SetControlParam <tag> <value> |
64 |
|
|
SetControlParam () |
65 |
|
|
{ |
66 |
|
|
echo "$1: \"$2\"" |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
OWNER=$(GetJobParam owner) |
70 |
|
|
EMAIL=$(GetJobParam mailaddr) |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
CLIENT=$(GetClient "$OWNER" "$EMAIL") |
74 |
|
|
|
75 |
|
|
if [ "$CLIENT" == "REJECT" ] |
76 |
|
|
then |
77 |
|
|
SetControlParam RejectNotice "Not authorized" |
78 |
|
|
exit |
79 |
|
|
fi |
80 |
|
|
|
81 |
|
|
# Only client 1234 is allowed to specify ModemGroups |
82 |
|
|
#if [ "$CLIENT" != 1234 ] |
83 |
|
|
#then |
84 |
|
|
# MODEM=$(GetJobParam modem) |
85 |
|
|
# if [ "$MODEM" != "any" ] |
86 |
|
|
# then |
87 |
|
|
# SetControlParam RejectNoctice "Modem setting of $MODEM not allowed - use any" |
88 |
|
|
# exit |
89 |
|
|
# fi |
90 |
|
|
#fi |
91 |
|
|
|
92 |
|
|
# Set the modemgroup based on the destination |
93 |
|
|
# We're strict on the given number format - it must be a cannonical |
94 |
|
|
# number (including the +) |
95 |
|
|
DEST=$(GetJobParam number) |
96 |
|
|
#case "$DEST" in |
97 |
|
|
# 82??) ## Our local extensions |
98 |
|
|
# SetControlParam Modem "PBX" |
99 |
|
|
# ;; |
100 |
|
|
# +1215*) |
101 |
|
|
# SetControlParam Modem "Local" |
102 |
|
|
# ;; |
103 |
|
|
# +1*) |
104 |
|
|
# SetControlParam Modem "NA" |
105 |
|
|
# ;; |
106 |
|
|
# +44*) |
107 |
|
|
# SetControlParam Modem "UK" |
108 |
|
|
# ;; |
109 |
|
|
# *) |
110 |
|
|
# SetControlParam RejectNotice "Not a number we support - see numbering FAQ" |
111 |
|
|
# ;; |
112 |
|
|
#esac |
113 |
|
|
|
114 |
|
|
|
115 |
|
|
## |
116 |
|
|
## And now client-specific settings |
117 |
|
|
|
118 |
|
|
#case "$CLIENT" in |
119 |
|
|
# 1234) |
120 |
|
|
# # These guys can do whatever they want - they pay big bucks for the |
121 |
|
|
# # privilege |
122 |
|
|
# SetControlParam UseJOBTSI true |
123 |
|
|
# SetControlParam UseJobTagLine true |
124 |
|
|
# ;; |
125 |
|
|
# 5678) |
126 |
|
|
# # These guys aren't nice |
127 |
|
|
# SetControlParam LocalIdentifier "Company XYX" |
128 |
|
|
# SetControlParam DesiredBR 14400 |
129 |
|
|
# SetControlParam TagLineFormat "From %%n|%c|Page %%P of %%T" |
130 |
|
|
# SetControlParam TimeOfDay "000000-065959,190000-235900" |
131 |
|
|
# ;; |
132 |
|
|
# *) |
133 |
|
|
# # And our regular guys |
134 |
|
|
# SetControlParam DesiredBR 9600 |
135 |
|
|
#esac |
136 |
|
|
|